[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAFv8NwLos-XcB9K8315vmmfKn+z0XaBph3QxSwrmqhfYqoju2Q@mail.gmail.com>
Date: Tue, 9 Jul 2019 19:55:29 +0800
From: Cheng-yi Chiang <cychiang@...omium.org>
To: Cezary Rojewski <cezary.rojewski@...el.com>
Cc: linux-kernel <linux-kernel@...r.kernel.org>,
Hans Verkuil <hverkuil@...all.nl>,
Mark Brown <broonie@...nel.org>,
Liam Girdwood <lgirdwood@...il.com>,
Takashi Iwai <tiwai@...e.com>,
Jaroslav Kysela <perex@...ex.cz>,
Russell King <rmk+kernel@...linux.org.uk>,
Andrzej Hajda <a.hajda@...sung.com>,
Laurent Pinchart <Laurent.pinchart@...asonboard.com>,
David Airlie <airlied@...ux.ie>,
Daniel Vetter <daniel@...ll.ch>,
Heiko Stuebner <heiko@...ech.de>,
Doug Anderson <dianders@...omium.org>,
Dylan Reid <dgreid@...omium.org>, tzungbi@...omium.org,
"moderated list:SOUND - SOC LAYER / DYNAMIC AUDIO POWER MANAGEM..."
<alsa-devel@...a-project.org>, dri-devel@...ts.freedesktop.org,
linux-arm-kernel@...ts.infradead.org,
linux-rockchip@...ts.infradead.org
Subject: Re: [PATCH 1/4] ASoC: hdmi-codec: Add an op to set callback function
for plug event
On Tue, Jul 9, 2019 at 7:47 PM Cezary Rojewski
<cezary.rojewski@...el.com> wrote:
>
> On 2019-07-05 06:26, Cheng-Yi Chiang wrote:
> > +static void hdmi_codec_jack_report(struct hdmi_codec_priv *hcp,
> > + unsigned int jack_status)
> > +{
> > + if (!hcp->jack)
> > + return;
> > +
> > + if (jack_status != hcp->jack_status) {
> > + snd_soc_jack_report(hcp->jack, jack_status, SND_JACK_LINEOUT);
> > + hcp->jack_status = jack_status;
> > + }
> > +}
>
> Single "if" statement instead? The first "if" does not even cover all
> cases - if the secondary check fails, you'll "return;" too.
>
ACK.
I will fix in v2.
> > +/**
> > + * hdmi_codec_set_jack_detect - register HDMI plugged callback
> > + * @component: the hdmi-codec instance
> > + * @jack: ASoC jack to report (dis)connection events on
> > + */
> > +int hdmi_codec_set_jack_detect(struct snd_soc_component *component,
> > + struct snd_soc_jack *jack)
> > +{
> > + struct hdmi_codec_priv *hcp = snd_soc_component_get_drvdata(component);
> > + int ret;
> > +
> > + if (hcp->hcd.ops->hook_plugged_cb) {
> > + hcp->jack = jack;
> > + ret = hcp->hcd.ops->hook_plugged_cb(component->dev->parent,
> > + hcp->hcd.data,
> > + plugged_cb);
> > + if (ret) {
> > + hcp->jack = NULL;
> > + return ret;
> > + }
> > + return 0;
> > + }
> > + return -EOPNOTSUPP;
> > +}
> > +EXPORT_SYMBOL_GPL(hdmi_codec_set_jack_detect);
>
> int ret = -EOPNOTSUPP;
> (...)
>
> return ret;
>
> In consequence, you can reduce the number of "return(s)" and also remove
> the redundant parenthesis for the if-statement used to set jack to NULL.
>
> Czarek
ACK
will fix in v2.
Thanks a lot for the review!
Powered by blists - more mailing lists