diff mbox series

i2c: i801: Simplify initialization of i2c_board_info in i801_probe_optional_slaves

Message ID c2c797f9-7c5c-9545-0cac-675a191c7e40@gmail.com
State Accepted
Commit 8d83973e7a85b2fab168894ea327dfd4e6ef596e
Headers show
Series i2c: i801: Simplify initialization of i2c_board_info in i801_probe_optional_slaves | expand

Commit Message

Heiner Kallweit May 25, 2021, 8:01 p.m. UTC
Why shall we bother to open-code something that the compiler can do for us.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
 drivers/i2c/busses/i2c-i801.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

Jean Delvare June 14, 2021, 4:07 p.m. UTC | #1
On Tue, 25 May 2021 22:01:31 +0200, Heiner Kallweit wrote:
> 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.

> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>

> ---

>  drivers/i2c/busses/i2c-i801.c | 8 ++++----

>  1 file changed, 4 insertions(+), 4 deletions(-)

> 

> diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c

> index 9588d5bcf..0c08cfec5 100644

> --- a/drivers/i2c/busses/i2c-i801.c

> +++ b/drivers/i2c/busses/i2c-i801.c

> @@ -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?

> +			.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.

> +		};

>  

> -		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.

Reviewed-by: Jean Delvare <jdelvare@suse.de>


-- 
Jean Delvare
SUSE L3 Support
Wolfram Sang June 20, 2021, 8:53 p.m. UTC | #2
On Tue, May 25, 2021 at 10:01:31PM +0200, Heiner Kallweit wrote:
> Why shall we bother to open-code something that the compiler can do for us.

> 

> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>


Applied to for-next, thanks!

> +			.type = "fujitsu_apanel"


I added the "," here.
diff mbox series

Patch

diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c
index 9588d5bcf..0c08cfec5 100644
--- a/drivers/i2c/busses/i2c-i801.c
+++ b/drivers/i2c/busses/i2c-i801.c
@@ -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);
 	}