[PATCH v3 03/25] mtd: spi-nor: Introduce spi_nor_set_mtd_info()

Tudor.Ambarus at microchip.com Tudor.Ambarus at microchip.com
Wed Nov 17 06:36:38 PST 2021


On 11/16/21 8:11 PM, Pratyush Yadav wrote:

>>
>>> - spi_nor_try_unlock_all(), which is called by spi_nor_init(). I don't
>>>   think it actually uses any values you initialize here but still worth
>>>   pointing out.
>>
>> we are safe here, the pointer to mtd is used just to get the pointer to
>> nor.
> 
> Yeah, but who knows if that might change some time later. I would prefer
> we don't use a member we haven't initialized yet.

If it weren't for the SPI NOR controller drivers that use
spi_nor_scan(), I would put the spi_nor_set_mtd_info() just
above the mtd_device_register(). It will indicate that no mtd_info
field is used up to that point, less things to worry about.
spi_nor_try_unlock_all() calls
	spi_nor_unlock(&nor->mtd, 0, nor->params->size);
I can't see for now if we will ever need some specific mtd_info
parameter. I would say that we won't, we're just unlocking the full
flash, every info we would need we can obtain from NOR. The discussion
would be different if it were about mtd partitions, but it isn't, we're
dealing with the entire flash.

Would you accept the place where I put spi_nor_set_mtd_info() if I add
a comment before calling it? Something like:
/* No mtd_info fields are used up to this point. */
spi_nor_set_mtd_info();

Cheers,
ta


More information about the linux-mtd mailing list