From: Richard Weinberger <richard@nod.at>
To: Brian Norris <computersforpeace@gmail.com>
Cc: linux-mtd@lists.infradead.org, dwmw2@infradead.org,
maximlevitsky@gmail.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 6/6] mtd: docg3: Don't do ERR_PTR(0)
Date: Tue, 23 Jun 2015 08:27:45 +0200 [thread overview]
Message-ID: <5588FC61.5070202@nod.at> (raw)
In-Reply-To: <20150617184144.GH4917@ld-irv-0074>
Am 17.06.2015 um 20:41 schrieb Brian Norris:
> On Mon, Jun 01, 2015 at 11:10:54PM +0200, Richard Weinberger wrote:
>> Don't return a obfuscated null pointer using ERR_PTR(0).
>> If the no device is found clearly return -ENODEV.
>> This makes the code more clear and matches the comment
>> of doc_probe_device().
>>
>> Signed-off-by: Richard Weinberger <richard@nod.at>
>> ---
>
> Have you tested this patch?
nah, I don't own such a device.
>> drivers/mtd/devices/docg3.c | 16 ++++++----------
>> 1 file changed, 6 insertions(+), 10 deletions(-)
>>
>> diff --git a/drivers/mtd/devices/docg3.c b/drivers/mtd/devices/docg3.c
>> index 5e67b4a..630e29a 100644
>> --- a/drivers/mtd/devices/docg3.c
>> +++ b/drivers/mtd/devices/docg3.c
>> @@ -1902,7 +1902,7 @@ doc_probe_device(struct docg3_cascade *cascade, int floor, struct device *dev)
>> chip_id = doc_register_readw(docg3, DOC_CHIPID);
>> chip_id_inv = doc_register_readw(docg3, DOC_CHIPID_INV);
>>
>> - ret = 0;
>> + ret = -ENODEV;
>> if (chip_id != (u16)(~chip_id_inv)) {
>> goto nomem4;
>> }
>> @@ -2068,13 +2068,10 @@ static int __init docg3_probe(struct platform_device *pdev)
>> mtd = doc_probe_device(cascade, floor, dev);
>> if (IS_ERR(mtd)) {
>> ret = PTR_ERR(mtd);
>> - goto err_probe;
>> - }
>> - if (!mtd) {
>> - if (floor == 0)
>> - goto notfound;
>> - else
>> + if (ret == -ENODEV && floor == 0)
>
> I think you might have changed the logic when refactoring here. I think
> the right refactoring would be the following, no?
>
> if (ret == -ENODEV && floor != 0)
> continue;
> else
> goto err_probe;
>
You are right, the logic changed. ;-\
Please drop this patch, I'll resend it for 4.3.
Thanks,
//richard
WARNING: multiple messages have this Message-ID (diff)
From: Richard Weinberger <richard@nod.at>
To: Brian Norris <computersforpeace@gmail.com>
Cc: dwmw2@infradead.org, maximlevitsky@gmail.com,
linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 6/6] mtd: docg3: Don't do ERR_PTR(0)
Date: Tue, 23 Jun 2015 08:27:45 +0200 [thread overview]
Message-ID: <5588FC61.5070202@nod.at> (raw)
In-Reply-To: <20150617184144.GH4917@ld-irv-0074>
Am 17.06.2015 um 20:41 schrieb Brian Norris:
> On Mon, Jun 01, 2015 at 11:10:54PM +0200, Richard Weinberger wrote:
>> Don't return a obfuscated null pointer using ERR_PTR(0).
>> If the no device is found clearly return -ENODEV.
>> This makes the code more clear and matches the comment
>> of doc_probe_device().
>>
>> Signed-off-by: Richard Weinberger <richard@nod.at>
>> ---
>
> Have you tested this patch?
nah, I don't own such a device.
>> drivers/mtd/devices/docg3.c | 16 ++++++----------
>> 1 file changed, 6 insertions(+), 10 deletions(-)
>>
>> diff --git a/drivers/mtd/devices/docg3.c b/drivers/mtd/devices/docg3.c
>> index 5e67b4a..630e29a 100644
>> --- a/drivers/mtd/devices/docg3.c
>> +++ b/drivers/mtd/devices/docg3.c
>> @@ -1902,7 +1902,7 @@ doc_probe_device(struct docg3_cascade *cascade, int floor, struct device *dev)
>> chip_id = doc_register_readw(docg3, DOC_CHIPID);
>> chip_id_inv = doc_register_readw(docg3, DOC_CHIPID_INV);
>>
>> - ret = 0;
>> + ret = -ENODEV;
>> if (chip_id != (u16)(~chip_id_inv)) {
>> goto nomem4;
>> }
>> @@ -2068,13 +2068,10 @@ static int __init docg3_probe(struct platform_device *pdev)
>> mtd = doc_probe_device(cascade, floor, dev);
>> if (IS_ERR(mtd)) {
>> ret = PTR_ERR(mtd);
>> - goto err_probe;
>> - }
>> - if (!mtd) {
>> - if (floor == 0)
>> - goto notfound;
>> - else
>> + if (ret == -ENODEV && floor == 0)
>
> I think you might have changed the logic when refactoring here. I think
> the right refactoring would be the following, no?
>
> if (ret == -ENODEV && floor != 0)
> continue;
> else
> goto err_probe;
>
You are right, the logic changed. ;-\
Please drop this patch, I'll resend it for 4.3.
Thanks,
//richard
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
Please read the FAQ at http://www.tux.org/lkml/
next prev parent reply other threads:[~2015-06-23 6:28 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-01 21:10 Some fixes for MTD drivers Richard Weinberger
2015-06-01 21:10 ` Richard Weinberger
2015-06-01 21:10 ` [PATCH 1/6] mtd: r852: Fix device_create_file() usage Richard Weinberger
2015-06-01 21:10 ` Richard Weinberger
2015-06-17 2:07 ` Brian Norris
2015-06-17 2:07 ` Brian Norris
2015-06-01 21:10 ` [PATCH 2/6] mtd: nandsim: Fix kasprintf() usage Richard Weinberger
2015-06-01 21:10 ` Richard Weinberger
2015-06-17 2:07 ` Brian Norris
2015-06-17 2:07 ` Brian Norris
2015-06-17 4:42 ` Joe Perches
2015-06-01 21:10 ` [PATCH 3/6] mtd: cs553x_nand: " Richard Weinberger
2015-06-01 21:10 ` Richard Weinberger
2015-06-01 21:10 ` [PATCH 4/6] mtd: docg3: Don't leak docg3->bbt in error path Richard Weinberger
2015-06-01 21:10 ` Richard Weinberger
2015-06-01 21:10 ` [PATCH 5/6] mtd: docg3: Fix kasprintf() usage Richard Weinberger
2015-06-01 21:10 ` Richard Weinberger
2015-06-01 21:10 ` [PATCH 6/6] mtd: docg3: Don't do ERR_PTR(0) Richard Weinberger
2015-06-01 21:10 ` Richard Weinberger
2015-06-17 18:41 ` Brian Norris
2015-06-17 18:41 ` Brian Norris
2015-06-23 6:27 ` Richard Weinberger [this message]
2015-06-23 6:27 ` Richard Weinberger
2015-06-23 20:41 ` Robert Jarzmik
2015-06-23 20:41 ` Robert Jarzmik
2015-06-25 2:29 ` Brian Norris
2015-06-25 2:29 ` Brian Norris
2015-06-25 17:14 ` Robert Jarzmik
2015-06-25 17:14 ` Robert Jarzmik
2015-06-26 0:23 ` Brian Norris
2015-06-26 0:23 ` Brian Norris
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=5588FC61.5070202@nod.at \
--to=richard@nod.at \
--cc=computersforpeace@gmail.com \
--cc=dwmw2@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=maximlevitsky@gmail.com \
/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.