i2c: i801: Simplify initialization of i2c_board_info in i801_probe_optional_slaves
PATCH 1/1 i2c: i801: Simplify initialization of i2c_board_info in i801_probe_optional_slaves
Why shall we bother to open-code something that the compiler can do for us.
--- drivers/i2c/busses/i2c-i801.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/i2c/busses/i2c-i801.c +4 -4
@@ -1291,11 +1291,11 @@ static void i801_probe_optional_slaves(struct i801_priv *priv)return ;if (apanel_addr) { -struct i2c_board_info info; +struct i2c_board_info info = { + .addr = apanel_addr, + .type ="fujitsu_apanel" + }; -memset (&info,0 ,sizeof (struct i2c_board_info )); - info.addr = apanel_addr; -strlcpy (info.type,"fujitsu_apanel" ,I2C_NAME_SIZE );i2c_new_client_device (&priv->adapter, &info); }
Signature · 1 line
2.31.1
Quoted 1 line · Heiner Kallweit
Why shall we bother to open-code something that the compiler can do for us.
I don't know, maybe it wasn't supported by older versions of gcc?
Surprisingly, this makes the binary a tad larger. I wonder why.
Quoted 10 lines
Signed-off-by Heiner Kallweit <[email protected]>--- drivers/i2c/busses/i2c-i801.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)drivers/i2c/busses/i2c-i801.c +0
-0
drivers/i2c/busses/i2c-i801.c static void i801_probe_optional_slaves(struct i801_priv *priv) · line 1294
Quoted 5 lines
drivers/i2c/busses/i2c-i801.c +1
-1@@ -1291,11 +1291,11 @@ static void i801_probe_optional_slaves(struct i801_priv *priv)return ;if (apanel_addr) { -struct i2c_board_info info; +struct i2c_board_info info = {
Could be declared const now?
drivers/i2c/busses/i2c-i801.c static void i801_probe_optional_slaves(struct i801_priv *priv) · line 1296
Quoted 2 lines
drivers/i2c/busses/i2c-i801.c +2
-0+ .addr = apanel_addr, + .type ="fujitsu_apanel"
We traditionally add a trailing comma on every line, so that adding a line in the future will result in a smaller, more readable patch.
drivers/i2c/busses/i2c-i801.c static void i801_probe_optional_slaves(struct i801_priv *priv) · line 1301
Quoted 8 lines
drivers/i2c/busses/i2c-i801.c +1
-3+ }; -memset (&info,0 ,sizeof (struct i2c_board_info )); - info.addr = apanel_addr; -strlcpy (info.type,"fujitsu_apanel" ,I2C_NAME_SIZE );i2c_new_client_device (&priv->adapter, &info); }
Other than these minor details, no objection from me.
Signature · 2 lines
Jean Delvare SUSE L3 Support
Wolfram Sang
AppliedQuoted 3 lines · Heiner Kallweit
Why shall we bother to open-code something that the compiler can do for us.
Signed-off-by Heiner Kallweit <[email protected]>
Applied to for-next, thanks!
drivers/i2c/busses/i2c-i801.c static void i801_probe_optional_slaves(struct i801_priv *priv) · line 1296
Quoted 1 line
drivers/i2c/busses/i2c-i801.c +1
-0+ .type = "fujitsu_apanel"
I added the "," here.