All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] i2c: stub: move module_init/exit annotations to the proper place
@ 2017-05-16 11:21 Wolfram Sang
  2017-05-16 11:21 ` [PATCH 2/2] i2c: stub: use pr_fmt Wolfram Sang
  2017-05-18  7:58 ` [PATCH 1/2] i2c: stub: move module_init/exit annotations to the proper place Jean Delvare
  0 siblings, 2 replies; 6+ messages in thread
From: Wolfram Sang @ 2017-05-16 11:21 UTC (permalink / raw)
  To: linux-i2c; +Cc: Jean Delvare, Guenter Roeck, linux-renesas-soc, Wolfram Sang

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---
 drivers/i2c/i2c-stub.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/i2c/i2c-stub.c b/drivers/i2c/i2c-stub.c
index 06af583d510150..0aa4d646f8fb26 100644
--- a/drivers/i2c/i2c-stub.c
+++ b/drivers/i2c/i2c-stub.c
@@ -406,16 +406,15 @@ static int __init i2c_stub_init(void)
 	i2c_stub_free();
 	return ret;
 }
+module_init(i2c_stub_init);
 
 static void __exit i2c_stub_exit(void)
 {
 	i2c_del_adapter(&stub_adapter);
 	i2c_stub_free();
 }
+module_exit(i2c_stub_exit);
 
 MODULE_AUTHOR("Mark M. Hoffman <mhoffman@lightlink.com>");
 MODULE_DESCRIPTION("I2C stub driver");
 MODULE_LICENSE("GPL");
-
-module_init(i2c_stub_init);
-module_exit(i2c_stub_exit);
-- 
2.11.0

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

* [PATCH 2/2] i2c: stub: use pr_fmt
  2017-05-16 11:21 [PATCH 1/2] i2c: stub: move module_init/exit annotations to the proper place Wolfram Sang
@ 2017-05-16 11:21 ` Wolfram Sang
  2017-05-18  8:39   ` Jean Delvare
  2017-06-02 20:49   ` Wolfram Sang
  2017-05-18  7:58 ` [PATCH 1/2] i2c: stub: move module_init/exit annotations to the proper place Jean Delvare
  1 sibling, 2 replies; 6+ messages in thread
From: Wolfram Sang @ 2017-05-16 11:21 UTC (permalink / raw)
  To: linux-i2c; +Cc: Jean Delvare, Guenter Roeck, linux-renesas-soc, Wolfram Sang

Instead of hard coding "i2c-stub:", let's use the pr_fmt mechanism to
achieve the same more easily. This makes it easier to stay consistent
when adding new messages. Also, remove an unneeded OOM message while we
are here.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---
 drivers/i2c/i2c-stub.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/i2c/i2c-stub.c b/drivers/i2c/i2c-stub.c
index 0aa4d646f8fb26..5627b1df391c7e 100644
--- a/drivers/i2c/i2c-stub.c
+++ b/drivers/i2c/i2c-stub.c
@@ -15,7 +15,8 @@
     GNU General Public License for more details.
 */
 
-#define DEBUG 1
+#define DEBUG
+#define pr_fmt(fmt) "i2c-stub: " fmt
 
 #include <linux/errno.h>
 #include <linux/i2c.h>
@@ -342,7 +343,7 @@ static int __init i2c_stub_allocate_banks(int i)
 	if (!chip->bank_words)
 		return -ENOMEM;
 
-	pr_debug("i2c-stub: Allocated %u banks of %u words each (registers 0x%02x to 0x%02x)\n",
+	pr_debug("Allocated %u banks of %u words each (registers 0x%02x to 0x%02x)\n",
 		 chip->bank_mask, chip->bank_size, chip->bank_start,
 		 chip->bank_end);
 
@@ -363,28 +364,27 @@ static int __init i2c_stub_init(void)
 	int i, ret;
 
 	if (!chip_addr[0]) {
-		pr_err("i2c-stub: Please specify a chip address\n");
+		pr_err("Please specify a chip address\n");
 		return -ENODEV;
 	}
 
 	for (i = 0; i < MAX_CHIPS && chip_addr[i]; i++) {
 		if (chip_addr[i] < 0x03 || chip_addr[i] > 0x77) {
-			pr_err("i2c-stub: Invalid chip address 0x%02x\n",
+			pr_err("Invalid chip address 0x%02x\n",
 			       chip_addr[i]);
 			return -EINVAL;
 		}
 
-		pr_info("i2c-stub: Virtual chip at 0x%02x\n", chip_addr[i]);
+		pr_info("Virtual chip at 0x%02x\n", chip_addr[i]);
 	}
 
 	/* Allocate memory for all chips at once */
 	stub_chips_nr = i;
 	stub_chips = kcalloc(stub_chips_nr, sizeof(struct stub_chip),
 			     GFP_KERNEL);
-	if (!stub_chips) {
-		pr_err("i2c-stub: Out of memory\n");
+	if (!stub_chips)
 		return -ENOMEM;
-	}
+
 	for (i = 0; i < stub_chips_nr; i++) {
 		INIT_LIST_HEAD(&stub_chips[i].smbus_blocks);
 
-- 
2.11.0

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

* Re: [PATCH 1/2] i2c: stub: move module_init/exit annotations to the proper place
  2017-05-16 11:21 [PATCH 1/2] i2c: stub: move module_init/exit annotations to the proper place Wolfram Sang
  2017-05-16 11:21 ` [PATCH 2/2] i2c: stub: use pr_fmt Wolfram Sang
@ 2017-05-18  7:58 ` Jean Delvare
  2017-05-18  8:14   ` Wolfram Sang
  1 sibling, 1 reply; 6+ messages in thread
From: Jean Delvare @ 2017-05-18  7:58 UTC (permalink / raw)
  To: Wolfram Sang; +Cc: linux-i2c, Guenter Roeck, linux-renesas-soc

Hi Wolfram,

On Tue, 16 May 2017 13:21:04 +0200, Wolfram Sang wrote:
> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
> ---
>  drivers/i2c/i2c-stub.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/i2c/i2c-stub.c b/drivers/i2c/i2c-stub.c
> index 06af583d510150..0aa4d646f8fb26 100644
> --- a/drivers/i2c/i2c-stub.c
> +++ b/drivers/i2c/i2c-stub.c
> @@ -406,16 +406,15 @@ static int __init i2c_stub_init(void)
>  	i2c_stub_free();
>  	return ret;
>  }
> +module_init(i2c_stub_init);
>  
>  static void __exit i2c_stub_exit(void)
>  {
>  	i2c_del_adapter(&stub_adapter);
>  	i2c_stub_free();
>  }
> +module_exit(i2c_stub_exit);
>  
>  MODULE_AUTHOR("Mark M. Hoffman <mhoffman@lightlink.com>");
>  MODULE_DESCRIPTION("I2C stub driver");
>  MODULE_LICENSE("GPL");
> -
> -module_init(i2c_stub_init);
> -module_exit(i2c_stub_exit);

I'm not sure on what you base your claim that this is the "proper
place". checkpatch doesn't complain about either, and if anything, the
original style (module_init/exit) at end of file seems a lot more
popular through the kernel tree.

-- 
Jean Delvare
SUSE L3 Support

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

* Re: [PATCH 1/2] i2c: stub: move module_init/exit annotations to the proper place
  2017-05-18  7:58 ` [PATCH 1/2] i2c: stub: move module_init/exit annotations to the proper place Jean Delvare
@ 2017-05-18  8:14   ` Wolfram Sang
  0 siblings, 0 replies; 6+ messages in thread
From: Wolfram Sang @ 2017-05-18  8:14 UTC (permalink / raw)
  To: Jean Delvare; +Cc: Wolfram Sang, linux-i2c, Guenter Roeck, linux-renesas-soc

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

Hi Jean,

> > -module_init(i2c_stub_init);
> > -module_exit(i2c_stub_exit);
> 
> I'm not sure on what you base your claim that this is the "proper
> place". checkpatch doesn't complain about either, and if anything, the
> original style (module_init/exit) at end of file seems a lot more
> popular through the kernel tree.

In my book, this is more "old-style" than "popular" ;) And while I am
quite sure my change is common these days (put annotations directly
behind the functions), I in deed cannot find any public reference for
that.

No strong feelings, I can drop it.

Thanks,

   Wolfram


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

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

* Re: [PATCH 2/2] i2c: stub: use pr_fmt
  2017-05-16 11:21 ` [PATCH 2/2] i2c: stub: use pr_fmt Wolfram Sang
@ 2017-05-18  8:39   ` Jean Delvare
  2017-06-02 20:49   ` Wolfram Sang
  1 sibling, 0 replies; 6+ messages in thread
From: Jean Delvare @ 2017-05-18  8:39 UTC (permalink / raw)
  To: Wolfram Sang; +Cc: linux-i2c, Guenter Roeck, linux-renesas-soc

On Tue, 16 May 2017 13:21:05 +0200, Wolfram Sang wrote:
> Instead of hard coding "i2c-stub:", let's use the pr_fmt mechanism to
> achieve the same more easily. This makes it easier to stay consistent
> when adding new messages. Also, remove an unneeded OOM message while we
> are here.
> 
> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
> ---
>  drivers/i2c/i2c-stub.c | 16 ++++++++--------
>  1 file changed, 8 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/i2c/i2c-stub.c b/drivers/i2c/i2c-stub.c
> index 0aa4d646f8fb26..5627b1df391c7e 100644
> --- a/drivers/i2c/i2c-stub.c
> +++ b/drivers/i2c/i2c-stub.c
> @@ -15,7 +15,8 @@
>      GNU General Public License for more details.
>  */
>  
> -#define DEBUG 1
> +#define DEBUG
> +#define pr_fmt(fmt) "i2c-stub: " fmt
>  
>  #include <linux/errno.h>
>  #include <linux/i2c.h>
> @@ -342,7 +343,7 @@ static int __init i2c_stub_allocate_banks(int i)
>  	if (!chip->bank_words)
>  		return -ENOMEM;
>  
> -	pr_debug("i2c-stub: Allocated %u banks of %u words each (registers 0x%02x to 0x%02x)\n",
> +	pr_debug("Allocated %u banks of %u words each (registers 0x%02x to 0x%02x)\n",
>  		 chip->bank_mask, chip->bank_size, chip->bank_start,
>  		 chip->bank_end);
>  
> @@ -363,28 +364,27 @@ static int __init i2c_stub_init(void)
>  	int i, ret;
>  
>  	if (!chip_addr[0]) {
> -		pr_err("i2c-stub: Please specify a chip address\n");
> +		pr_err("Please specify a chip address\n");
>  		return -ENODEV;
>  	}
>  
>  	for (i = 0; i < MAX_CHIPS && chip_addr[i]; i++) {
>  		if (chip_addr[i] < 0x03 || chip_addr[i] > 0x77) {
> -			pr_err("i2c-stub: Invalid chip address 0x%02x\n",
> +			pr_err("Invalid chip address 0x%02x\n",
>  			       chip_addr[i]);
>  			return -EINVAL;
>  		}
>  
> -		pr_info("i2c-stub: Virtual chip at 0x%02x\n", chip_addr[i]);
> +		pr_info("Virtual chip at 0x%02x\n", chip_addr[i]);
>  	}
>  
>  	/* Allocate memory for all chips at once */
>  	stub_chips_nr = i;
>  	stub_chips = kcalloc(stub_chips_nr, sizeof(struct stub_chip),
>  			     GFP_KERNEL);
> -	if (!stub_chips) {
> -		pr_err("i2c-stub: Out of memory\n");
> +	if (!stub_chips)
>  		return -ENOMEM;
> -	}
> +
>  	for (i = 0; i < stub_chips_nr; i++) {
>  		INIT_LIST_HEAD(&stub_chips[i].smbus_blocks);
>  

Looks good to me.

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

-- 
Jean Delvare
SUSE L3 Support

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

* Re: [PATCH 2/2] i2c: stub: use pr_fmt
  2017-05-16 11:21 ` [PATCH 2/2] i2c: stub: use pr_fmt Wolfram Sang
  2017-05-18  8:39   ` Jean Delvare
@ 2017-06-02 20:49   ` Wolfram Sang
  1 sibling, 0 replies; 6+ messages in thread
From: Wolfram Sang @ 2017-06-02 20:49 UTC (permalink / raw)
  To: Wolfram Sang; +Cc: linux-i2c, Jean Delvare, Guenter Roeck, linux-renesas-soc

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

On Tue, May 16, 2017 at 01:21:05PM +0200, Wolfram Sang wrote:
> Instead of hard coding "i2c-stub:", let's use the pr_fmt mechanism to
> achieve the same more easily. This makes it easier to stay consistent
> when adding new messages. Also, remove an unneeded OOM message while we
> are here.
> 
> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>

Applied to for-next, thanks!


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

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

end of thread, other threads:[~2017-06-02 20:49 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-16 11:21 [PATCH 1/2] i2c: stub: move module_init/exit annotations to the proper place Wolfram Sang
2017-05-16 11:21 ` [PATCH 2/2] i2c: stub: use pr_fmt Wolfram Sang
2017-05-18  8:39   ` Jean Delvare
2017-06-02 20:49   ` Wolfram Sang
2017-05-18  7:58 ` [PATCH 1/2] i2c: stub: move module_init/exit annotations to the proper place Jean Delvare
2017-05-18  8:14   ` Wolfram Sang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.