[PATCH v2] powerpc/machdep: warn when machine_is() used too early

Nathan Lynch nathanl at linux.ibm.com
Tue Feb 14 07:20:53 AEDT 2023


Christophe Leroy <christophe.leroy at csgroup.eu> writes:
> Le 13/02/2023 à 20:23, Nathan Lynch via B4 Submission Endpoint a écrit :
>> From: Nathan Lynch <nathanl at linux.ibm.com>
>> 
>> machine_is() can't provide correct results before probe_machine() has
>> run. Warn when it's used too early in boot, placing the WARN_ON() in a
>> helper function so the reported file:line indicates exactly what went
>> wrong.
>> 
>> checkpatch complains about __attribute__((weak)) in the patch, so
>> change that to __weak, and align the line continuations as well.
>> 
>> Signed-off-by: Nathan Lynch <nathanl at linux.ibm.com>
>
> Reviewed-by: Christophe Leroy <christophe.leroy at csgroup.eu>

thanks!

>> @@ -220,11 +221,16 @@ extern struct machdep_calls *machine_id;
>>   	EXPORT_SYMBOL(mach_##name);				\
>>   	struct machdep_calls mach_##name __machine_desc =
>>   
>> -#define machine_is(name) \
>> -	({ \
>> -		extern struct machdep_calls mach_##name \
>> -			__attribute__((weak));		 \
>> -		machine_id == &mach_##name; \
>> +static inline bool __machine_is(const struct machdep_calls *md)
>> +{
>> +	WARN_ON(!machine_id); // complain if used before probe_machine()
>> +	return machine_id == md;
>> +}
>> +
>> +#define machine_is(name)                                        \
>
> Misaligned back-slash ?

An artifact of the patch format + tabs for indentation. It should be
aligned with the rest when looking at the file itself after the patch is
applied.

>
>> +	({                                                      \
>> +		extern struct machdep_calls mach_##name __weak; \
>> +		__machine_is(&mach_##name);                     \
>>   	})
>>   
>>   static inline void log_error(char *buf, unsigned int err_type, int fatal)


More information about the Linuxppc-dev mailing list