[PATCH v3 2/3] nand: omap2: Remove horrible ifdefs to fix module probe

Ezequiel Garcia ezequiel at vanguardiasur.com.ar
Thu Sep 18 00:48:06 PDT 2014


On 18 September 2014 07:03, Brian Norris <computersforpeace at gmail.com> wrote:
> On Thu, Sep 11, 2014 at 12:02:09PM -0300, Ezequiel Garcia wrote:
>> The current code abuses ifdefs to determine if the selected ECC scheme
>> is supported by the running kernel. As a result the code is hard to read,
>> and it also fails to load as a module.
>
> Yes, a real eyesore, with little benefit from the #ifdef's.
>
>> This commit removes all the ifdefs and instead introduces a function
>> omap2_nand_ecc_check() to check if the ECC is supported by using
>> IS_ENABLED(CONFIG_xxx).
>>
>> Since IS_ENABLED() is true when a config is =y or =m, this change fixes the
>> module so it can be loaded with no issues.
>>
>> Signed-off-by: Ezequiel Garcia <ezequiel at vanguardiasur.com.ar>
> [...]
>> diff --git a/include/linux/platform_data/elm.h b/include/linux/platform_data/elm.h
>> index 780d1e9..25d1bca 100644
>> --- a/include/linux/platform_data/elm.h
>> +++ b/include/linux/platform_data/elm.h
>> @@ -42,8 +42,22 @@ struct elm_errorvec {
>>       int error_loc[16];
>>  };
>>
>> +#if IS_ENABLED(CONFIG_MTD_NAND_OMAP_BCH)
>>  void elm_decode_bch_error_page(struct device *dev, u8 *ecc_calc,
>>               struct elm_errorvec *err_vec);
>>  int elm_config(struct device *dev, enum bch_ecc bch_type,
>>       int ecc_steps, int ecc_step_size, int ecc_syndrome_size);
>> +#else
>> +void elm_decode_bch_error_page(struct device *dev, u8 *ecc_calc,
>> +             struct elm_errorvec *err_vec)
>
> You should not be defining non-static functions in a header. Now these
> functions will be uselessly placed in every compilation unit that
> includes this header. You should probably make this function 'static
> inline'.
>

Darn, of course they must be static! Thanks for spotting this.
-- 
Ezequiel García, VanguardiaSur
www.vanguardiasur.com.ar



More information about the linux-mtd mailing list