[PATCH 5/5] mtd: spi: Use IS_ENABLED to prevent ifdef
Stefan Roese
stefan.roese at gmail.com
Fri May 15 06:27:56 CEST 2020
Hi Daniel,
On 14.05.20 18:31, Daniel Schwierzeck wrote:
>
>
> Am 14.05.20 um 14:11 schrieb Jagan Teki:
>> Use IS_ENABLED to prevent ifdef in sf_probe.c
>>
>> Cc: Simon Glass <sjg at chromium.org>
>> Cc: Vignesh R <vigneshr at ti.com>
>> Cc: Daniel Schwierzeck <daniel.schwierzeck at gmail.com>
>> Signed-off-by: Jagan Teki <jagan at amarulasolutions.com>
>> ---
>> drivers/mtd/spi/sf_internal.h | 10 ++++++++++
>> drivers/mtd/spi/sf_probe.c | 17 ++++++++---------
>> 2 files changed, 18 insertions(+), 9 deletions(-)
>>
>> diff --git a/drivers/mtd/spi/sf_internal.h b/drivers/mtd/spi/sf_internal.h
>> index 940b2e4c9e..544ed74a5f 100644
>> --- a/drivers/mtd/spi/sf_internal.h
>> +++ b/drivers/mtd/spi/sf_internal.h
>> @@ -81,5 +81,15 @@ int spi_flash_cmd_get_sw_write_prot(struct spi_flash *flash);
>> #if CONFIG_IS_ENABLED(SPI_FLASH_MTD)
>> int spi_flash_mtd_register(struct spi_flash *flash);
>> void spi_flash_mtd_unregister(void);
>> +#else
>> +static inline int spi_flash_mtd_register(struct spi_flash *flash)
>> +{
>> + return 0;
>> +}
>> +
>> +static inline void spi_flash_mtd_unregister(void)
>> +{
>> +}
>> #endif
>> +
>> #endif /* _SF_INTERNAL_H_ */
>> diff --git a/drivers/mtd/spi/sf_probe.c b/drivers/mtd/spi/sf_probe.c
>> index 89e384901c..1e8744896c 100644
>> --- a/drivers/mtd/spi/sf_probe.c
>> +++ b/drivers/mtd/spi/sf_probe.c
>> @@ -44,9 +44,8 @@ static int spi_flash_probe_slave(struct spi_flash *flash)
>> if (ret)
>> goto err_read_id;
>>
>> -#if CONFIG_IS_ENABLED(SPI_FLASH_MTD)
>> - ret = spi_flash_mtd_register(flash);
>> -#endif
>> + if (IS_ENABLED(CONFIG_SPI_FLASH_MTD))
>> + ret = spi_flash_mtd_register(flash);
>
> you have to use CONFIG_IS_ENABLED() instead of IS_ENABLED()
Just curious: I thought that those two are equivalent:
IS_ENABLED(CONFIG_FOO) and
CONFIG_IS_ENABLED(FOO)
Is this not the case? From a functional point of view? I personally
prefer IS_ENABLED(CONFIG_FOO), as the Kconfig symbol is completely
visible this way.
Thanks,
Stefan
> to also
> consider the existing CONFIG_SPL_SPI_FLASH_MTD option
>
> $ git grep -n SPI_FLASH_MTD -- drivers/mtd/spi/
> drivers/mtd/spi/Kconfig:187:config SPI_FLASH_MTD
> drivers/mtd/spi/Kconfig:199:config SPL_SPI_FLASH_MTD
>
>
>>
>> err_read_id:
>> spi_release_bus(spi);
>> @@ -83,9 +82,9 @@ struct spi_flash *spi_flash_probe(unsigned int busnum, unsigned int cs,
>>
>> void spi_flash_free(struct spi_flash *flash)
>> {
>> -#if CONFIG_IS_ENABLED(SPI_FLASH_MTD)
>> - spi_flash_mtd_unregister();
>> -#endif
>> + if (IS_ENABLED(CONFIG_SPI_FLASH_MTD))
>> + spi_flash_mtd_unregister();
>> +
>> spi_free_slave(flash->spi);
>> free(flash);
>> }
>> @@ -150,9 +149,9 @@ int spi_flash_std_probe(struct udevice *dev)
>>
>> static int spi_flash_std_remove(struct udevice *dev)
>> {
>> -#if CONFIG_IS_ENABLED(SPI_FLASH_MTD)
>> - spi_flash_mtd_unregister();
>> -#endif
>> + if (IS_ENABLED(CONFIG_SPI_FLASH_MTD))
>> + spi_flash_mtd_unregister();
>> +
>> return 0;
>> }
>>
>>
>
More information about the U-Boot
mailing list