[PATCH 1/2] mtd: move code adding master MTD out of mtd_add_device_partitions
Rafał Miłecki
zajec5 at gmail.com
Mon Jan 15 02:58:18 PST 2018
On 12 January 2018 at 16:01, Boris Brezillon
<boris.brezillon at free-electrons.com> wrote:
>> diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
>> index f80e911b8843..f6460862e2ad 100644
>> --- a/drivers/mtd/mtdcore.c
>> +++ b/drivers/mtd/mtdcore.c
>> @@ -641,20 +641,12 @@ static int mtd_add_device_partitions(struct mtd_info *mtd,
>> {
>> const struct mtd_partition *real_parts = parts->parts;
>> int nbparts = parts->nr_parts;
>> - int ret;
>>
>> - if (nbparts == 0 || IS_ENABLED(CONFIG_MTD_PARTITIONED_MASTER)) {
>> - ret = add_mtd_device(mtd);
>> - if (ret)
>> - return ret;
>> - }
>> + if (nbparts == 0 && !IS_ENABLED(CONFIG_MTD_PARTITIONED_MASTER))
>> + return add_mtd_device(mtd);
>
> Why not moving this part in mtd_device_parse_register() as well.
I move that in 2/2. I prefer to handle these changes in 2 steps as it
should be quite easier to review it that way.
> And I'd prefer something like:
>
> if (!nbparts && !device_is_registered(&mtd->dev))
> ...
Nice idea with that device_is_registered.
More information about the linux-mtd
mailing list