Message ID | 20240804112032.3628645-2-u.kleine-koenig@baylibre.com (mailing list archive) |
---|---|
State | Accepted |
Commit | c4afe3eb04a5fc095a9e3b1b25691f9ed31a52d3 |
Headers | show |
Series | powerpc/476: Drop explicit initialization of struct i2c_device_id::driver_data to 0 | expand |
Context | Check | Description |
---|---|---|
snowpatch_ozlabs/github-powerpc_selftests | success | Successfully ran 8 jobs. |
snowpatch_ozlabs/github-powerpc_ppctests | success | Successfully ran 8 jobs. |
snowpatch_ozlabs/github-powerpc_sparse | success | Successfully ran 4 jobs. |
snowpatch_ozlabs/github-powerpc_clang | success | Successfully ran 5 jobs. |
snowpatch_ozlabs/github-powerpc_kernel_qemu | success | Successfully ran 21 jobs. |
Le 04/08/2024 à 13:20, Uwe Kleine-König a écrit : > This driver doesn't use the driver_data member of struct i2c_device_id, > so don't explicitly initialize this member. Well, even if the member was used, a 0 init is useless because as soon as you initialise one field of the struct, the compiler initialise everything else with 0. > > This prepares putting driver_data in an anonymous union which requires > either no initialization or named designators. But it's also a nice > cleanup on its own. > > Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com> Reviewed-by: Christophe Leroy <christophe leroy@csgroup.eu> > --- > arch/powerpc/platforms/44x/ppc476.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/arch/powerpc/platforms/44x/ppc476.c b/arch/powerpc/platforms/44x/ppc476.c > index 164cbcd4588e..e7b7bdaad341 100644 > --- a/arch/powerpc/platforms/44x/ppc476.c > +++ b/arch/powerpc/platforms/44x/ppc476.c > @@ -95,7 +95,7 @@ static int avr_probe(struct i2c_client *client) > } > > static const struct i2c_device_id avr_id[] = { > - { "akebono-avr", 0 }, > + { "akebono-avr" }, > { } > }; > > > base-commit: f524a5e4dfb75b277c9a5ad819ca5f035f490f14
Hello, On Wed, Aug 07, 2024 at 07:50:26AM +0200, Christophe Leroy wrote: > Le 04/08/2024 à 13:20, Uwe Kleine-König a écrit : > > This driver doesn't use the driver_data member of struct i2c_device_id, > > so don't explicitly initialize this member. > > Well, even if the member was used, a 0 init is useless because as soon as > you initialise one field of the struct, the compiler initialise everything > else with 0. Yeah, there are different shades of "useless". I'd say that if the driver_data member is used, e.g. like: static const struct i2c_device_id avr_id[] = { { .name = "akebono-avr", .driver_data = 0, }, { .name = "akebono-arduino", .driver_data = 1, }, { } }; the assignment to driver_data in the first entry is useless as it doesn't make a difference for the compiler, but still has a benefit for the human reader of the code. So I would keep that one. > Reviewed-by: Christophe Leroy <christophe leroy@csgroup.eu> Thanks Uwe
On Sun, 04 Aug 2024 13:20:31 +0200, Uwe Kleine-König wrote: > This driver doesn't use the driver_data member of struct i2c_device_id, > so don't explicitly initialize this member. > > This prepares putting driver_data in an anonymous union which requires > either no initialization or named designators. But it's also a nice > cleanup on its own. > > [...] Applied to powerpc/next. [1/1] powerpc/476: Drop explicit initialization of struct i2c_device_id::driver_data to 0 https://git.kernel.org/powerpc/c/c4afe3eb04a5fc095a9e3b1b25691f9ed31a52d3 cheers
diff --git a/arch/powerpc/platforms/44x/ppc476.c b/arch/powerpc/platforms/44x/ppc476.c index 164cbcd4588e..e7b7bdaad341 100644 --- a/arch/powerpc/platforms/44x/ppc476.c +++ b/arch/powerpc/platforms/44x/ppc476.c @@ -95,7 +95,7 @@ static int avr_probe(struct i2c_client *client) } static const struct i2c_device_id avr_id[] = { - { "akebono-avr", 0 }, + { "akebono-avr" }, { } };
This driver doesn't use the driver_data member of struct i2c_device_id, so don't explicitly initialize this member. This prepares putting driver_data in an anonymous union which requires either no initialization or named designators. But it's also a nice cleanup on its own. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com> --- arch/powerpc/platforms/44x/ppc476.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) base-commit: f524a5e4dfb75b277c9a5ad819ca5f035f490f14