Hello Wolfram, On Tue, Jun 25, 2024 at 11:47:29AM +0200, Wolfram Sang wrote: > > This prepares putting driver_data in an anonymous union which requires > > either no initialization or named designators. > > Any preview/RFC of what you are aiming for with this one? There is an inconsistency in the different *_device_id structures. Some have a kernel_ulong_t for driver private data, others have a void*. Depending on how it's used in the drivers, one or the other is better. To get the best from both the idea is to do diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h index 4338b1b4ac44..594c5ace303a 100644 --- a/include/linux/mod_devicetable.h +++ b/include/linux/mod_devicetable.h @@ -477,7 +477,10 @@ struct rpmsg_device_id { struct i2c_device_id { char name[I2C_NAME_SIZE]; - kernel_ulong_t driver_data; /* Data private to the driver */ + union { + kernel_ulong_t driver_data; /* Data private to the driver */ + const void *data; + }; }; /* pci_epf */ which then allows to drop quite a few casts, e.g. diff --git a/drivers/clk/clk-cdce925.c b/drivers/clk/clk-cdce925.c index 2354d12ddad8..6ba5dce0c951 100644 --- a/drivers/clk/clk-cdce925.c +++ b/drivers/clk/clk-cdce925.c @@ -818,10 +818,10 @@ static const struct clk_cdce925_chip_info clk_cdce949_info = { }; static const struct i2c_device_id cdce925_id[] = { - { .name = "cdce913", .driver_data = (kernel_ulong_t)&clk_cdce913_info, }, - { .name = "cdce925", .driver_data = (kernel_ulong_t)&clk_cdce925_info, }, - { .name = "cdce937", .driver_data = (kernel_ulong_t)&clk_cdce937_info, }, - { .name = "cdce949", .driver_data = (kernel_ulong_t)&clk_cdce949_info, }, + { .name = "cdce913", .data = &clk_cdce913_info, }, + { .name = "cdce925", .data = &clk_cdce925_info, }, + { .name = "cdce937", .data = &clk_cdce937_info, }, + { .name = "cdce949", .data = &clk_cdce949_info, }, { } }; MODULE_DEVICE_TABLE(i2c, cdce925_id); diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c index 49fdcb3eb8f6..d19ffe79681b 100644 --- a/drivers/i2c/i2c-core-base.c +++ b/drivers/i2c/i2c-core-base.c @@ -129,7 +129,7 @@ const void *i2c_get_match_data(const struct i2c_client *client) if (!match) return NULL; - data = (const void *)match->driver_data; + data = match->data; } return data; The only downside is that all initializers have to use either ".data =" or ".driver_data =". IMHO that is OK, as named initializers are more robust and explicit. Best regards Uwe
Attachment:
signature.asc
Description: PGP signature