From: Martin Fuzzey <mfuzzey@parkeon.com>
To: Timur Tabi <timur@tabi.org>
Cc: alsa-devel@alsa-project.org, linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH V2] Sound: sgtl5000 Allow codec clock frequency to be set.
Date: Tue, 26 Mar 2013 11:28:11 +0100 [thread overview]
Message-ID: <5151783B.7050105@parkeon.com> (raw)
In-Reply-To: <CAOZdJXWi2pph-=vQg+FAty+yVVk9fJBU6rxYOf0J-J2f=Lwgxw@mail.gmail.com>
On 22/03/13 15:08, Timur Tabi wrote:
> On Fri, Mar 22, 2013 at 4:33 AM, Martin Fuzzey <mfuzzey@parkeon.com> wrote:
>
>> diff --git a/sound/soc/fsl/imx-sgtl5000.c b/sound/soc/fsl/imx-sgtl5000.c
>> index 424347e..71ce1f6 100644
>> --- a/sound/soc/fsl/imx-sgtl5000.c
>> +++ b/sound/soc/fsl/imx-sgtl5000.c
>> @@ -128,18 +128,30 @@ static int imx_sgtl5000_probe(struct platform_device *pdev)
>> goto fail;
>> }
>>
>> + ret = of_property_read_u32(codec_np, "clock-frequency",
>> + &data->clk_frequency);
> I just noticed that you assign 'ret' here, but you never check the
> value. So I think you should either:
>
> 1) Check the value of 'ret'
> 2) Remove the "ret = "
Initially I did check the value of 'ret', instead of checking
data->clk_frequency.
However I found that checking a generic return variable 'ret' several
lines later
to be not very clear (to see what 'ret' refers to you have to backtrack
while
reading the code).
The ret can't be checked directly after assigning it as it's not always
an error
condition (in the phandle only case an error here is normal).
Checking data->clk_frequency, IMHO makes the code more readable.
If I remove the "ret =" no error code will be propagated back to the
caller.
Sure I could add an assignment of ret to -EINVAL in the error case like
this:
of_property_read_u32(codec_np, "clock-frequency",
&data->clk_frequency);
data->codec_clk = clk_get(&codec_dev->dev, NULL);
if (IS_ERR(data->codec_clk)) {
/* assuming clock enabled by default (frequency required) */
data->codec_clk = NULL;
if (!data->clk_frequency) {
dev_err(&codec_dev->dev,
"clock-frequency missing or invalid\n");
ret = -EINVAL;
goto fail;
}
} else {
But I don't think this is better than just propating the value from
of_property_read_u32()
as it loses information.
Martin
WARNING: multiple messages have this Message-ID (diff)
From: mfuzzey@parkeon.com (Martin Fuzzey)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH V2] Sound: sgtl5000 Allow codec clock frequency to be set.
Date: Tue, 26 Mar 2013 11:28:11 +0100 [thread overview]
Message-ID: <5151783B.7050105@parkeon.com> (raw)
In-Reply-To: <CAOZdJXWi2pph-=vQg+FAty+yVVk9fJBU6rxYOf0J-J2f=Lwgxw@mail.gmail.com>
On 22/03/13 15:08, Timur Tabi wrote:
> On Fri, Mar 22, 2013 at 4:33 AM, Martin Fuzzey <mfuzzey@parkeon.com> wrote:
>
>> diff --git a/sound/soc/fsl/imx-sgtl5000.c b/sound/soc/fsl/imx-sgtl5000.c
>> index 424347e..71ce1f6 100644
>> --- a/sound/soc/fsl/imx-sgtl5000.c
>> +++ b/sound/soc/fsl/imx-sgtl5000.c
>> @@ -128,18 +128,30 @@ static int imx_sgtl5000_probe(struct platform_device *pdev)
>> goto fail;
>> }
>>
>> + ret = of_property_read_u32(codec_np, "clock-frequency",
>> + &data->clk_frequency);
> I just noticed that you assign 'ret' here, but you never check the
> value. So I think you should either:
>
> 1) Check the value of 'ret'
> 2) Remove the "ret = "
Initially I did check the value of 'ret', instead of checking
data->clk_frequency.
However I found that checking a generic return variable 'ret' several
lines later
to be not very clear (to see what 'ret' refers to you have to backtrack
while
reading the code).
The ret can't be checked directly after assigning it as it's not always
an error
condition (in the phandle only case an error here is normal).
Checking data->clk_frequency, IMHO makes the code more readable.
If I remove the "ret =" no error code will be propagated back to the
caller.
Sure I could add an assignment of ret to -EINVAL in the error case like
this:
of_property_read_u32(codec_np, "clock-frequency",
&data->clk_frequency);
data->codec_clk = clk_get(&codec_dev->dev, NULL);
if (IS_ERR(data->codec_clk)) {
/* assuming clock enabled by default (frequency required) */
data->codec_clk = NULL;
if (!data->clk_frequency) {
dev_err(&codec_dev->dev,
"clock-frequency missing or invalid\n");
ret = -EINVAL;
goto fail;
}
} else {
But I don't think this is better than just propating the value from
of_property_read_u32()
as it loses information.
Martin
next prev parent reply other threads:[~2013-03-26 10:28 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-22 9:33 [PATCH V2] Sound: sgtl5000 Allow codec clock frequency to be set Martin Fuzzey
2013-03-22 9:33 ` Martin Fuzzey
2013-03-22 14:08 ` Timur Tabi
2013-03-22 14:08 ` Timur Tabi
2013-03-26 10:28 ` Martin Fuzzey [this message]
2013-03-26 10:28 ` Martin Fuzzey
2013-03-25 20:22 ` Matt Sealey
2013-03-25 20:22 ` Matt Sealey
2013-03-26 9:54 ` Martin Fuzzey
2013-03-26 9:54 ` Martin Fuzzey
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5151783B.7050105@parkeon.com \
--to=mfuzzey@parkeon.com \
--cc=alsa-devel@alsa-project.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=timur@tabi.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.