Re: [PATCH v2 03/46] mtd: Don't unconditionally unregister reboot notifier
From: Daniel Walter
Date: Wed Sep 21 2016 - 10:33:51 EST
On 09/21/2016 04:31 PM, Boris Brezillon wrote:
> On Wed, 21 Sep 2016 11:45:12 +0200
> Daniel Walter <dwalter@xxxxxxxxxxxxx> wrote:
>
>> From: Richard Weinberger <richard@xxxxxx>
>>
>> del_mtd_device() is allowed to fail.
>> i.e. when the MTD is busy.
>> Unregister the reboot notifier only when we're really
>> about to delete the MTD.
>>
>> Signed-off-by: Richard Weinberger <richard@xxxxxx>
>> ---
>> drivers/mtd/mtdcore.c | 15 ++++++++++-----
>> 1 file changed, 10 insertions(+), 5 deletions(-)
>>
>> diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
>> index e3936b8..36e5fb0 100644
>> --- a/drivers/mtd/mtdcore.c
>> +++ b/drivers/mtd/mtdcore.c
>> @@ -654,17 +654,22 @@ int mtd_device_unregister(struct mtd_info *master)
>> {
>> int err;
>>
>> - if (master->_reboot)
>> - unregister_reboot_notifier(&master->reboot_notifier);
>> -
>> err = del_mtd_partitions(master);
>> if (err)
>> return err;
>>
>> if (!device_is_registered(&master->dev))
>> - return 0;
>> + goto unregister;
>>
>> - return del_mtd_device(master);
>> + err = del_mtd_device(master);
>> + if (err)
>> + return err;
>> +
>> +unregister:
>> + if (master->_reboot)
>> + unregister_reboot_notifier(&master->reboot_notifier);
>> +
>> + return 0;
>
> How about:
>
> if (device_is_registered(&master->dev)) {
> err = del_mtd_device(master);
> if (err)
> return err;
> }
>
> if (master->_reboot)
> unregister_reboot_notifier(&master->reboot_notifier);
>
> return 0;
>
> This way you get rid of the unregister label, which IMHO improves
> readability.
Agree, will fix this in v3 of the series.
--
sigma star gmbh | Eduard-Bodem-Gasse 6, 6020 Innsbruck, Austria
UID/VAT Nr: ATU 66964118 | FN: 374287y