linux-i2c.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] i2c: i801: Simplify initialization of i2c_board_info in i801_probe_optional_slaves
@ 2021-05-25 20:01 Heiner Kallweit
  2021-06-14 16:07 ` Jean Delvare
  2021-06-20 20:53 ` Wolfram Sang
  0 siblings, 2 replies; 3+ messages in thread
From: Heiner Kallweit @ 2021-05-25 20:01 UTC (permalink / raw)
  To: Jean Delvare; +Cc: linux-i2c

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(-)

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);
 	}
 
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] i2c: i801: Simplify initialization of i2c_board_info in i801_probe_optional_slaves
  2021-05-25 20:01 [PATCH] i2c: i801: Simplify initialization of i2c_board_info in i801_probe_optional_slaves Heiner Kallweit
@ 2021-06-14 16:07 ` Jean Delvare
  2021-06-20 20:53 ` Wolfram Sang
  1 sibling, 0 replies; 3+ messages in thread
From: Jean Delvare @ 2021-06-14 16:07 UTC (permalink / raw)
  To: Heiner Kallweit; +Cc: linux-i2c

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] i2c: i801: Simplify initialization of i2c_board_info in i801_probe_optional_slaves
  2021-05-25 20:01 [PATCH] i2c: i801: Simplify initialization of i2c_board_info in i801_probe_optional_slaves Heiner Kallweit
  2021-06-14 16:07 ` Jean Delvare
@ 2021-06-20 20:53 ` Wolfram Sang
  1 sibling, 0 replies; 3+ messages in thread
From: Wolfram Sang @ 2021-06-20 20:53 UTC (permalink / raw)
  To: Heiner Kallweit; +Cc: Jean Delvare, linux-i2c

[-- Attachment #1: Type: text/plain, Size: 299 bytes --]

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.


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-06-20 20:53 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-25 20:01 [PATCH] i2c: i801: Simplify initialization of i2c_board_info in i801_probe_optional_slaves Heiner Kallweit
2021-06-14 16:07 ` Jean Delvare
2021-06-20 20:53 ` Wolfram Sang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).