You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This approach works functionally, but it's not intuitive. The logic is split across multiple #if/#endif blocks, making it harder to read and maintain.
I propose replacing it with a clearer structure by splitting the entire function definition based on kernel version:
#ifLINUX_VERSION_CODE >= KERNEL_VERSION(6, 11, 0)
staticvoiddevicemodel_remove(structplatform_device*dev)
{
pr_info("devicemodel example removed\n");
/* Your device removal code */
}
#elsestaticintdevicemodel_remove(structplatform_device*dev)
{
pr_info("devicemodel example removed\n");
/* Your device removal code */return0;
}
#endif
This makes the logic easier to understand and reduces potential confusion for future readers.
If this looks good, I can send a patch for it.
The text was updated successfully, but these errors were encountered:
The current implementation of
devicemodel_remove()
uses conditional compilation to switch the return type betweenvoid
andint
, as shown below:This approach works functionally, but it's not intuitive. The logic is split across multiple
#if
/#endif
blocks, making it harder to read and maintain.I propose replacing it with a clearer structure by splitting the entire function definition based on kernel version:
This makes the logic easier to understand and reduces potential confusion for future readers.
If this looks good, I can send a patch for it.
The text was updated successfully, but these errors were encountered: