linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] HID: core: Add hid printk_once macros
@ 2019-07-22 16:36 stillcompiling
  2019-07-22 16:36 ` [PATCH 2/2] HID: core: only warn once of oversize hid report stillcompiling
  2019-07-22 17:11 ` [PATCH 1/2] HID: core: Add hid printk_once macros Joe Perches
  0 siblings, 2 replies; 13+ messages in thread
From: stillcompiling @ 2019-07-22 16:36 UTC (permalink / raw)
  To: Jiri Kosina, Benjamin Tissoires, open list:HID CORE LAYER, open list
  Cc: Joshua Clayton

From: Joshua Clayton <stillcompiling@gmail.com>

Make available printk_once variants to hid_warn() etc

Signed-off-by: Joshua Clayton <stillcompiling@gmail.com>
---
 include/linux/hid.h | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/include/linux/hid.h b/include/linux/hid.h
index d770ab1a0479..5b239712c902 100644
--- a/include/linux/hid.h
+++ b/include/linux/hid.h
@@ -1179,4 +1179,23 @@ do {									\
 #define hid_dbg(hid, fmt, arg...)			\
 	dev_dbg(&(hid)->dev, fmt, ##arg)
 
+#define hid_level_once(level, hid, fmt, arg...)		\
+	dev_level_once(level, &(hid)->dev, fmt, ##arg)
+#define hid_emerg_once(hid, fmt, arg...)		\
+	dev_emerg_once(&(hid)->dev, fmt, ##arg)
+#define hid_crit_once(hid, fmt, arg...)			\
+	dev_crit_once(&(hid)->dev, fmt, ##arg)
+#define hid_alert_once(hid, fmt, arg...)		\
+	dev_alert_once(&(hid)->dev, fmt, ##arg)
+#define hid_err_once(hid, fmt, arg...)			\
+	dev_err_once(&(hid)->dev, fmt, ##arg)
+#define hid_notice_once(hid, fmt, arg...)		\
+	dev_notice_once(&(hid)->dev, fmt, ##arg)
+#define hid_warn_once(hid, fmt, arg...)			\
+	dev_warn_once(&(hid)->dev, fmt, ##arg)
+#define hid_info_once(hid, fmt, arg...)			\
+	dev_info_once(&(hid)->dev, fmt, ##arg)
+#define hid_dbg_once(hid, fmt, arg...)			\
+	dev_dbg_once(&(hid)->dev, fmt, ##arg)
+
 #endif
-- 
2.21.0


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

* [PATCH 2/2] HID: core: only warn once of oversize hid report
  2019-07-22 16:36 [PATCH 1/2] HID: core: Add hid printk_once macros stillcompiling
@ 2019-07-22 16:36 ` stillcompiling
  2019-07-22 17:23   ` Joe Perches
                     ` (2 more replies)
  2019-07-22 17:11 ` [PATCH 1/2] HID: core: Add hid printk_once macros Joe Perches
  1 sibling, 3 replies; 13+ messages in thread
From: stillcompiling @ 2019-07-22 16:36 UTC (permalink / raw)
  To: Jiri Kosina, Benjamin Tissoires, open list:HID CORE LAYER, open list
  Cc: Joshua Clayton

From: Joshua Clayton <stillcompiling@gmail.com>

On HP spectre x360 convertible the message:
hid-sensor-hub 001F:8087:0AC2.0002: hid_field_extract() called with n (192) > 32! (kworker/1:2)
is continually printed many times per second, crowding out all other kernel logs
Protect dmesg by printing the warning only one time.

Signed-off-by: Joshua Clayton <stillcompiling@gmail.com>
---
 drivers/hid/hid-core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index 210b81a56e1a..7afd0422b280 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -1311,7 +1311,7 @@ u32 hid_field_extract(const struct hid_device *hid, u8 *report,
 			unsigned offset, unsigned n)
 {
 	if (n > 32) {
-		hid_warn(hid, "hid_field_extract() called with n (%d) > 32! (%s)\n",
+		hid_warn_once(hid, "hid_field_extract() called with n (%d) > 32! (%s)\n",
 			 n, current->comm);
 		n = 32;
 	}
-- 
2.21.0


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

* Re: [PATCH 1/2] HID: core: Add hid printk_once macros
  2019-07-22 16:36 [PATCH 1/2] HID: core: Add hid printk_once macros stillcompiling
  2019-07-22 16:36 ` [PATCH 2/2] HID: core: only warn once of oversize hid report stillcompiling
@ 2019-07-22 17:11 ` Joe Perches
  1 sibling, 0 replies; 13+ messages in thread
From: Joe Perches @ 2019-07-22 17:11 UTC (permalink / raw)
  To: stillcompiling, Jiri Kosina, Benjamin Tissoires,
	open list:HID CORE LAYER, open list

On Mon, 2019-07-22 at 10:36 -0600, stillcompiling@gmail.com wrote:
> From: Joshua Clayton <stillcompiling@gmail.com>
> 
> Make available printk_once variants to hid_warn() etc
> 
> Signed-off-by: Joshua Clayton <stillcompiling@gmail.com>

This seems OK, but I suggest a slightly different style:

> diff --git a/include/linux/hid.h b/include/linux/hid.h
[]
> @@ -1179,4 +1179,23 @@ do {									\
>  #define hid_dbg(hid, fmt, arg...)			\
>  	dev_dbg(&(hid)->dev, fmt, ##arg)
>  
> +#define hid_level_once(level, hid, fmt, arg...)		\
> +	dev_level_once(level, &(hid)->dev, fmt, ##arg)

This one is probably not useful in actual code.

> +#define hid_emerg_once(hid, fmt, arg...)		\
> +	dev_emerg_once(&(hid)->dev, fmt, ##arg)

Even though I introduced those macros originally,
it's now a more common style to use:

#define hid_emerg_once(hid, fmt, ...)				\
	dev_emerg_once(&(hid)->dev, fmt, ##__VA_ARGS__)

etc...

And trivially:

hid_printk, hid_emerg, hid_crit, and hid_alert aren't
used at all and could all be removed.

I'm not sure there is a use case for any of them.

Perhaps:
---
 include/linux/hid.h | 39 +++++++++++++++++++++------------------
 1 file changed, 21 insertions(+), 18 deletions(-)

diff --git a/include/linux/hid.h b/include/linux/hid.h
index d770ab1a0479..5d2c4b63954f 100644
--- a/include/linux/hid.h
+++ b/include/linux/hid.h
@@ -1160,23 +1160,26 @@ do {									\
 		printk(KERN_DEBUG "%s: " format, __FILE__, ##arg);	\
 } while (0)
 
-#define hid_printk(level, hid, fmt, arg...)		\
-	dev_printk(level, &(hid)->dev, fmt, ##arg)
-#define hid_emerg(hid, fmt, arg...)			\
-	dev_emerg(&(hid)->dev, fmt, ##arg)
-#define hid_crit(hid, fmt, arg...)			\
-	dev_crit(&(hid)->dev, fmt, ##arg)
-#define hid_alert(hid, fmt, arg...)			\
-	dev_alert(&(hid)->dev, fmt, ##arg)
-#define hid_err(hid, fmt, arg...)			\
-	dev_err(&(hid)->dev, fmt, ##arg)
-#define hid_notice(hid, fmt, arg...)			\
-	dev_notice(&(hid)->dev, fmt, ##arg)
-#define hid_warn(hid, fmt, arg...)			\
-	dev_warn(&(hid)->dev, fmt, ##arg)
-#define hid_info(hid, fmt, arg...)			\
-	dev_info(&(hid)->dev, fmt, ##arg)
-#define hid_dbg(hid, fmt, arg...)			\
-	dev_dbg(&(hid)->dev, fmt, ##arg)
+#define hid_err(hid, fmt, ...)						\
+	dev_err(&(hid)->dev, fmt, ##__VA_ARGS__)
+#define hid_notice(hid, fmt, ...)					\
+	dev_notice(&(hid)->dev, fmt, ##__VA_ARGS__)
+#define hid_warn(hid, fmt, ...)						\
+	dev_warn(&(hid)->dev, fmt, ##__VA_ARGS__)
+#define hid_info(hid, fmt, ...)						\
+	dev_info(&(hid)->dev, fmt, ##__VA_ARGS__)
+#define hid_dbg(hid, fmt, ...)						\
+	dev_dbg(&(hid)->dev, fmt, ##__VA_ARGS__)
+
+#define hid_err_once(hid, fmt, ...)					\
+	dev_err_once(&(hid)->dev, fmt, ##__VA_ARGS__)
+#define hid_notice_once(hid, fmt, ...)					\
+	dev_notice_once(&(hid)->dev, fmt, ##__VA_ARGS__)
+#define hid_warn_once(hid, fmt, ...)					\
+	dev_warn_once(&(hid)->dev, fmt, ##__VA_ARGS__)
+#define hid_info_once(hid, fmt, ...)					\
+	dev_info_once(&(hid)->dev, fmt, ##__VA_ARGS__)
+#define hid_dbg_once(hid, fmt, ...)					\
+	dev_dbg_once(&(hid)->dev, fmt, ##__VA_ARGS__)
 
 #endif



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

* Re: [PATCH 2/2] HID: core: only warn once of oversize hid report
  2019-07-22 16:36 ` [PATCH 2/2] HID: core: only warn once of oversize hid report stillcompiling
@ 2019-07-22 17:23   ` Joe Perches
  2019-07-22 18:16     ` Joshua Clayton
  2019-07-22 21:26   ` [PATCH v2 1/3] HID: core: reformat and reduce hid_printk macros stillcompiling
  2019-07-22 21:48   ` [PATCH v3 1/3] HID: core: reformat and reduce hid_printk macros stillcompiling
  2 siblings, 1 reply; 13+ messages in thread
From: Joe Perches @ 2019-07-22 17:23 UTC (permalink / raw)
  To: stillcompiling, Jiri Kosina, Benjamin Tissoires,
	open list:HID CORE LAYER, open list

On Mon, 2019-07-22 at 10:36 -0600, stillcompiling@gmail.com wrote:
> On HP spectre x360 convertible the message:
> hid-sensor-hub 001F:8087:0AC2.0002: hid_field_extract() called with n (192) > 32! (kworker/1:2)
> is continually printed many times per second, crowding out all other kernel logs
> Protect dmesg by printing the warning only one time.
[]
> diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
[]
> @@ -1311,7 +1311,7 @@ u32 hid_field_extract(const struct hid_device *hid, u8 *report,
>  			unsigned offset, unsigned n)
>  {
>  	if (n > 32) {
> -		hid_warn(hid, "hid_field_extract() called with n (%d) > 32! (%s)\n",
> +		hid_warn_once(hid, "hid_field_extract() called with n (%d) > 32! (%s)\n",
>  			 n, current->comm);
>  		n = 32;
>  	}

Is this papering over an actual defect somewhere else?
Trivially, this could use "%s: ...", __func__, ...



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

* Re: [PATCH 2/2] HID: core: only warn once of oversize hid report
  2019-07-22 17:23   ` Joe Perches
@ 2019-07-22 18:16     ` Joshua Clayton
  0 siblings, 0 replies; 13+ messages in thread
From: Joshua Clayton @ 2019-07-22 18:16 UTC (permalink / raw)
  To: Joe Perches
  Cc: Jiri Kosina, Benjamin Tissoires, open list:HID CORE LAYER, open list

On Mon, Jul 22, 2019 at 11:23 AM Joe Perches <joe@perches.com> wrote:
>
> On Mon, 2019-07-22 at 10:36 -0600, stillcompiling@gmail.com wrote:
> > On HP spectre x360 convertible the message:
> > hid-sensor-hub 001F:8087:0AC2.0002: hid_field_extract() called with n (192) > 32! (kworker/1:2)
> > is continually printed many times per second, crowding out all other kernel logs
> > Protect dmesg by printing the warning only one time.
> []
> > diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
> []
> > @@ -1311,7 +1311,7 @@ u32 hid_field_extract(const struct hid_device *hid, u8 *report,
> >                       unsigned offset, unsigned n)
> >  {
> >       if (n > 32) {
> > -             hid_warn(hid, "hid_field_extract() called with n (%d) > 32! (%s)\n",
> > +             hid_warn_once(hid, "hid_field_extract() called with n (%d) > 32! (%s)\n",
> >                        n, current->comm);
> >               n = 32;
> >       }
>
> Is this papering over an actual defect somewhere else?

Sort of.
It doesn't correct the underlying issue, but I think this should go in
even along with the real fix.
The dmesg spamming has become a more serious problem for me than the
underlying issue.
Someone had a patch rejected that completely suppressed the message.

From my limited understanding, the hid spec allows an unlimited size
for an hid report , but the kernel only allocated 32 bits, which was
more than anything used at that time. The 32 bit version is doing some
bit shifting and possibly endian correction with the 32 bit field, so
I was not comfortable just extending it to 192 or 256 bits without a
little more understanding.

> Trivially, this could use "%s: ...", __func__, ...
True. I can make that change.
>

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

* [PATCH v2 1/3] HID: core: reformat and reduce hid_printk macros
  2019-07-22 16:36 ` [PATCH 2/2] HID: core: only warn once of oversize hid report stillcompiling
  2019-07-22 17:23   ` Joe Perches
@ 2019-07-22 21:26   ` stillcompiling
  2019-07-22 21:26     ` [PATCH v2 2/3] HID: core: Add printk_once variants to hid_warn() etc stillcompiling
  2019-07-22 21:26     ` [PATCH v2 3/3] HID: core: only warn once of oversize hid report stillcompiling
  2019-07-22 21:48   ` [PATCH v3 1/3] HID: core: reformat and reduce hid_printk macros stillcompiling
  2 siblings, 2 replies; 13+ messages in thread
From: stillcompiling @ 2019-07-22 21:26 UTC (permalink / raw)
  To: Joe Perches, Jiri Kosina, Benjamin Tissoires,
	open list:HID CORE LAYER, open list
  Cc: Joshua Clayton

From: Joshua Clayton <stillcompiling@gmail.com>

Reformat hid_printk macros to use standard __VA_ARGS__ syntax
Remove hid_printk(), hid_emerg(), hid_crit(), and hid_alert().
Per Joe Perches these unused and likely never to be used.

Signed-off-by: Joshua Clayton <stillcompiling@gmail.com>
---
 include/linux/hid.h | 32 ++++++++++++--------------------
 1 file changed, 12 insertions(+), 20 deletions(-)

diff --git a/include/linux/hid.h b/include/linux/hid.h
index d770ab1a0479..b5e73331100e 100644
--- a/include/linux/hid.h
+++ b/include/linux/hid.h
@@ -1154,29 +1154,21 @@ int hid_pidff_init(struct hid_device *hid);
 #define hid_pidff_init NULL
 #endif
 
-#define dbg_hid(format, arg...)						\
+#define dbg_hid(fmt, ...)						\
 do {									\
 	if (hid_debug)							\
-		printk(KERN_DEBUG "%s: " format, __FILE__, ##arg);	\
+		printk(KERN_DEBUG "%s: " fmt, __FILE__, ##__VA_ARGS__)	\
 } while (0)
 
-#define hid_printk(level, hid, fmt, arg...)		\
-	dev_printk(level, &(hid)->dev, fmt, ##arg)
-#define hid_emerg(hid, fmt, arg...)			\
-	dev_emerg(&(hid)->dev, fmt, ##arg)
-#define hid_crit(hid, fmt, arg...)			\
-	dev_crit(&(hid)->dev, fmt, ##arg)
-#define hid_alert(hid, fmt, arg...)			\
-	dev_alert(&(hid)->dev, fmt, ##arg)
-#define hid_err(hid, fmt, arg...)			\
-	dev_err(&(hid)->dev, fmt, ##arg)
-#define hid_notice(hid, fmt, arg...)			\
-	dev_notice(&(hid)->dev, fmt, ##arg)
-#define hid_warn(hid, fmt, arg...)			\
-	dev_warn(&(hid)->dev, fmt, ##arg)
-#define hid_info(hid, fmt, arg...)			\
-	dev_info(&(hid)->dev, fmt, ##arg)
-#define hid_dbg(hid, fmt, arg...)			\
-	dev_dbg(&(hid)->dev, fmt, ##arg)
+#define hid_err(hid, fmt, ...)				\
+	dev_err(&(hid)->dev, fmt, ##__VA_ARGS__)
+#define hid_notice(hid, fmt, ...)			\
+	dev_notice(&(hid)->dev, fmt, ##__VA_ARGS__)
+#define hid_warn(hid, fmt, ...)				\
+	dev_warn(&(hid)->dev, fmt, ##__VA_ARGS__)
+#define hid_info(hid, fmt, ...)				\
+	dev_info(&(hid)->dev, fmt, ##__VA_ARGS__)
+#define hid_dbg(hid, fmt, ...)				\
+	dev_dbg(&(hid)->dev, fmt, ##__VA_ARGS__)
 
 #endif
-- 
2.21.0


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

* [PATCH v2 2/3] HID: core: Add printk_once variants to hid_warn() etc
  2019-07-22 21:26   ` [PATCH v2 1/3] HID: core: reformat and reduce hid_printk macros stillcompiling
@ 2019-07-22 21:26     ` stillcompiling
  2019-07-22 21:26     ` [PATCH v2 3/3] HID: core: only warn once of oversize hid report stillcompiling
  1 sibling, 0 replies; 13+ messages in thread
From: stillcompiling @ 2019-07-22 21:26 UTC (permalink / raw)
  To: Joe Perches, Jiri Kosina, Benjamin Tissoires,
	open list:HID CORE LAYER, open list
  Cc: Joshua Clayton

From: Joshua Clayton <stillcompiling@gmail.com>

hid_warn_once() is needed, add the others as part of the block

Signed-off-by: Joshua Clayton <stillcompiling@gmail.com>
---
 include/linux/hid.h | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/include/linux/hid.h b/include/linux/hid.h
index b5e73331100e..306dde3760a4 100644
--- a/include/linux/hid.h
+++ b/include/linux/hid.h
@@ -1171,4 +1171,15 @@ do {									\
 #define hid_dbg(hid, fmt, ...)				\
 	dev_dbg(&(hid)->dev, fmt, ##__VA_ARGS__)
 
+#define hid_err_once(hid, fmt, ...)			\
+	dev_err_once(&(hid)->dev, fmt, ##__VA_ARGS__)
+#define hid_notice_once(hid, fmt, ...)			\
+	dev_notice_once(&(hid)->dev, fmt, ##__VA_ARGS__)
+#define hid_warn_once(hid, fmt, ...)			\
+	dev_warn_once(&(hid)->dev, fmt, ##__VA_ARGS__)
+#define hid_info_once(hid, fmt, ...)			\
+	dev_info_once(&(hid)->dev, fmt, ##__VA_ARGS__)
+#define hid_dbg_once(hid, fmt, ...)			\
+	dev_dbg_once(&(hid)->dev, fmt, ##__VA_ARGS__)
+
 #endif
-- 
2.21.0


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

* [PATCH v2 3/3] HID: core: only warn once of oversize hid report
  2019-07-22 21:26   ` [PATCH v2 1/3] HID: core: reformat and reduce hid_printk macros stillcompiling
  2019-07-22 21:26     ` [PATCH v2 2/3] HID: core: Add printk_once variants to hid_warn() etc stillcompiling
@ 2019-07-22 21:26     ` stillcompiling
  2019-07-22 21:30       ` Joe Perches
  1 sibling, 1 reply; 13+ messages in thread
From: stillcompiling @ 2019-07-22 21:26 UTC (permalink / raw)
  To: Joe Perches, Jiri Kosina, Benjamin Tissoires,
	open list:HID CORE LAYER, open list
  Cc: Joshua Clayton

From: Joshua Clayton <stillcompiling@gmail.com>

On HP spectre x360 convertible the message:
hid-sensor-hub 001F:8087:0AC2.0002: hid_field_extract() called with n (192) > 32! (kworker/1:2)
is continually printed many times per second, crowding out all else
Protect dmesg by printing the warning only one time.

Signed-off-by: Joshua Clayton <stillcompiling@gmail.com>
---
 drivers/hid/hid-core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index 210b81a56e1a..0cb53dddf341 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -1311,8 +1311,8 @@ u32 hid_field_extract(const struct hid_device *hid, u8 *report,
 			unsigned offset, unsigned n)
 {
 	if (n > 32) {
-		hid_warn(hid, "hid_field_extract() called with n (%d) > 32! (%s)\n",
-			 n, current->comm);
+		hid_warn_once(hid, "%s() called with n (%d) > 32! (%s)\n",
+			      __func__ ,n , current->comm);
 		n = 32;
 	}
 
-- 
2.21.0


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

* Re: [PATCH v2 3/3] HID: core: only warn once of oversize hid report
  2019-07-22 21:26     ` [PATCH v2 3/3] HID: core: only warn once of oversize hid report stillcompiling
@ 2019-07-22 21:30       ` Joe Perches
  2019-07-22 21:43         ` Joshua Clayton
  0 siblings, 1 reply; 13+ messages in thread
From: Joe Perches @ 2019-07-22 21:30 UTC (permalink / raw)
  To: stillcompiling, Jiri Kosina, Benjamin Tissoires,
	open list:HID CORE LAYER, open list

On Mon, 2019-07-22 at 15:26 -0600, stillcompiling@gmail.com wrote:
> From: Joshua Clayton <stillcompiling@gmail.com>

Thanks Joshua

> On HP spectre x360 convertible the message:
> hid-sensor-hub 001F:8087:0AC2.0002: hid_field_extract() called with n (192) > 32! (kworker/1:2)
> is continually printed many times per second, crowding out all else
> Protect dmesg by printing the warning only one time.
[]
> diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
[]
> @@ -1311,8 +1311,8 @@ u32 hid_field_extract(const struct hid_device *hid, u8 *report,
>  			unsigned offset, unsigned n)
>  {
>  	if (n > 32) {
> -		hid_warn(hid, "hid_field_extract() called with n (%d) > 32! (%s)\n",
> -			 n, current->comm);
> +		hid_warn_once(hid, "%s() called with n (%d) > 32! (%s)\n",
> +			      __func__ ,n , current->comm);

All the other bits are fine, but this line is oddly written
with unusual spacing around 'n'.

Normally it'd be something like:

		hid_warn_once(hid, "%s: called with n (%d) > 32! (%s)\n",
			      __func__, n, current->comm);



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

* Re: [PATCH v2 3/3] HID: core: only warn once of oversize hid report
  2019-07-22 21:30       ` Joe Perches
@ 2019-07-22 21:43         ` Joshua Clayton
  0 siblings, 0 replies; 13+ messages in thread
From: Joshua Clayton @ 2019-07-22 21:43 UTC (permalink / raw)
  To: Joe Perches
  Cc: Jiri Kosina, Benjamin Tissoires, open list:HID CORE LAYER, open list

On Mon, Jul 22, 2019 at 3:30 PM Joe Perches <joe@perches.com> wrote:
>
> On Mon, 2019-07-22 at 15:26 -0600, stillcompiling@gmail.com wrote:
> > From: Joshua Clayton <stillcompiling@gmail.com>
>
> Thanks Joshua
>
> > On HP spectre x360 convertible the message:
> > hid-sensor-hub 001F:8087:0AC2.0002: hid_field_extract() called with n (192) > 32! (kworker/1:2)
> > is continually printed many times per second, crowding out all else
> > Protect dmesg by printing the warning only one time.
> []
> > diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
> []
> > @@ -1311,8 +1311,8 @@ u32 hid_field_extract(const struct hid_device *hid, u8 *report,
> >                       unsigned offset, unsigned n)
> >  {
> >       if (n > 32) {
> > -             hid_warn(hid, "hid_field_extract() called with n (%d) > 32! (%s)\n",
> > -                      n, current->comm);
> > +             hid_warn_once(hid, "%s() called with n (%d) > 32! (%s)\n",
> > +                           __func__ ,n , current->comm);
>
> All the other bits are fine, but this line is oddly written
> with unusual spacing around 'n'.
>
> Normally it'd be something like:
>
>                 hid_warn_once(hid, "%s: called with n (%d) > 32! (%s)\n",
>                               __func__, n, current->comm);
Gah!
Not only that but I missed a semicolon in patch 1. Will fix, (compile)
and send v3 pdq.
Sorry about the extra noise.
>
>

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

* [PATCH v3 1/3] HID: core: reformat and reduce hid_printk macros
  2019-07-22 16:36 ` [PATCH 2/2] HID: core: only warn once of oversize hid report stillcompiling
  2019-07-22 17:23   ` Joe Perches
  2019-07-22 21:26   ` [PATCH v2 1/3] HID: core: reformat and reduce hid_printk macros stillcompiling
@ 2019-07-22 21:48   ` stillcompiling
  2019-07-22 21:48     ` [PATCH v3 2/3] HID: core: Add printk_once variants to hid_warn() etc stillcompiling
  2019-07-22 21:48     ` [PATCH v3 3/3] HID: core: only warn once of oversize hid report stillcompiling
  2 siblings, 2 replies; 13+ messages in thread
From: stillcompiling @ 2019-07-22 21:48 UTC (permalink / raw)
  To: Joe Perches, Jiri Kosina, Benjamin Tissoires,
	open list:HID CORE LAYER, open list
  Cc: Joshua Clayton

From: Joshua Clayton <stillcompiling@gmail.com>

Reformat hid_printk macros to use standard __VA_ARGS__ syntax
Remove hid_printk(), hid_emerg(), hid_crit(), and hid_alert().
Per Joe Perches these unused and likely never to be used.

Signed-off-by: Joshua Clayton <stillcompiling@gmail.com>
---
 include/linux/hid.h | 32 ++++++++++++--------------------
 1 file changed, 12 insertions(+), 20 deletions(-)

diff --git a/include/linux/hid.h b/include/linux/hid.h
index d770ab1a0479..e6c7efdb0458 100644
--- a/include/linux/hid.h
+++ b/include/linux/hid.h
@@ -1154,29 +1154,21 @@ int hid_pidff_init(struct hid_device *hid);
 #define hid_pidff_init NULL
 #endif
 
-#define dbg_hid(format, arg...)						\
+#define dbg_hid(fmt, ...)						\
 do {									\
 	if (hid_debug)							\
-		printk(KERN_DEBUG "%s: " format, __FILE__, ##arg);	\
+		printk(KERN_DEBUG "%s: " fmt, __FILE__, ##__VA_ARGS__);	\
 } while (0)
 
-#define hid_printk(level, hid, fmt, arg...)		\
-	dev_printk(level, &(hid)->dev, fmt, ##arg)
-#define hid_emerg(hid, fmt, arg...)			\
-	dev_emerg(&(hid)->dev, fmt, ##arg)
-#define hid_crit(hid, fmt, arg...)			\
-	dev_crit(&(hid)->dev, fmt, ##arg)
-#define hid_alert(hid, fmt, arg...)			\
-	dev_alert(&(hid)->dev, fmt, ##arg)
-#define hid_err(hid, fmt, arg...)			\
-	dev_err(&(hid)->dev, fmt, ##arg)
-#define hid_notice(hid, fmt, arg...)			\
-	dev_notice(&(hid)->dev, fmt, ##arg)
-#define hid_warn(hid, fmt, arg...)			\
-	dev_warn(&(hid)->dev, fmt, ##arg)
-#define hid_info(hid, fmt, arg...)			\
-	dev_info(&(hid)->dev, fmt, ##arg)
-#define hid_dbg(hid, fmt, arg...)			\
-	dev_dbg(&(hid)->dev, fmt, ##arg)
+#define hid_err(hid, fmt, ...)				\
+	dev_err(&(hid)->dev, fmt, ##__VA_ARGS__)
+#define hid_notice(hid, fmt, ...)			\
+	dev_notice(&(hid)->dev, fmt, ##__VA_ARGS__)
+#define hid_warn(hid, fmt, ...)				\
+	dev_warn(&(hid)->dev, fmt, ##__VA_ARGS__)
+#define hid_info(hid, fmt, ...)				\
+	dev_info(&(hid)->dev, fmt, ##__VA_ARGS__)
+#define hid_dbg(hid, fmt, ...)				\
+	dev_dbg(&(hid)->dev, fmt, ##__VA_ARGS__)
 
 #endif
-- 
2.21.0


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

* [PATCH v3 2/3] HID: core: Add printk_once variants to hid_warn() etc
  2019-07-22 21:48   ` [PATCH v3 1/3] HID: core: reformat and reduce hid_printk macros stillcompiling
@ 2019-07-22 21:48     ` stillcompiling
  2019-07-22 21:48     ` [PATCH v3 3/3] HID: core: only warn once of oversize hid report stillcompiling
  1 sibling, 0 replies; 13+ messages in thread
From: stillcompiling @ 2019-07-22 21:48 UTC (permalink / raw)
  To: Joe Perches, Jiri Kosina, Benjamin Tissoires,
	open list:HID CORE LAYER, open list
  Cc: Joshua Clayton

From: Joshua Clayton <stillcompiling@gmail.com>

hid_warn_once() is needed, add the others as part of the block

Signed-off-by: Joshua Clayton <stillcompiling@gmail.com>
---
 include/linux/hid.h | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/include/linux/hid.h b/include/linux/hid.h
index e6c7efdb0458..cd41f209043f 100644
--- a/include/linux/hid.h
+++ b/include/linux/hid.h
@@ -1171,4 +1171,15 @@ do {									\
 #define hid_dbg(hid, fmt, ...)				\
 	dev_dbg(&(hid)->dev, fmt, ##__VA_ARGS__)
 
+#define hid_err_once(hid, fmt, ...)			\
+	dev_err_once(&(hid)->dev, fmt, ##__VA_ARGS__)
+#define hid_notice_once(hid, fmt, ...)			\
+	dev_notice_once(&(hid)->dev, fmt, ##__VA_ARGS__)
+#define hid_warn_once(hid, fmt, ...)			\
+	dev_warn_once(&(hid)->dev, fmt, ##__VA_ARGS__)
+#define hid_info_once(hid, fmt, ...)			\
+	dev_info_once(&(hid)->dev, fmt, ##__VA_ARGS__)
+#define hid_dbg_once(hid, fmt, ...)			\
+	dev_dbg_once(&(hid)->dev, fmt, ##__VA_ARGS__)
+
 #endif
-- 
2.21.0


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

* [PATCH v3 3/3] HID: core: only warn once of oversize hid report
  2019-07-22 21:48   ` [PATCH v3 1/3] HID: core: reformat and reduce hid_printk macros stillcompiling
  2019-07-22 21:48     ` [PATCH v3 2/3] HID: core: Add printk_once variants to hid_warn() etc stillcompiling
@ 2019-07-22 21:48     ` stillcompiling
  1 sibling, 0 replies; 13+ messages in thread
From: stillcompiling @ 2019-07-22 21:48 UTC (permalink / raw)
  To: Joe Perches, Jiri Kosina, Benjamin Tissoires,
	open list:HID CORE LAYER, open list
  Cc: Joshua Clayton

From: Joshua Clayton <stillcompiling@gmail.com>

On HP spectre x360 convertible the message:
hid-sensor-hub 001F:8087:0AC2.0002: hid_field_extract() called with n (192) > 32! (kworker/1:2)
is continually printed many times per second, crowding out all else
Protect dmesg by printing the warning only one time.

Signed-off-by: Joshua Clayton <stillcompiling@gmail.com>
---
 drivers/hid/hid-core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index 210b81a56e1a..3eaee2c37931 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -1311,8 +1311,8 @@ u32 hid_field_extract(const struct hid_device *hid, u8 *report,
 			unsigned offset, unsigned n)
 {
 	if (n > 32) {
-		hid_warn(hid, "hid_field_extract() called with n (%d) > 32! (%s)\n",
-			 n, current->comm);
+		hid_warn_once(hid, "%s() called with n (%d) > 32! (%s)\n",
+			      __func__, n, current->comm);
 		n = 32;
 	}
 
-- 
2.21.0


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

end of thread, other threads:[~2019-07-22 21:48 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-22 16:36 [PATCH 1/2] HID: core: Add hid printk_once macros stillcompiling
2019-07-22 16:36 ` [PATCH 2/2] HID: core: only warn once of oversize hid report stillcompiling
2019-07-22 17:23   ` Joe Perches
2019-07-22 18:16     ` Joshua Clayton
2019-07-22 21:26   ` [PATCH v2 1/3] HID: core: reformat and reduce hid_printk macros stillcompiling
2019-07-22 21:26     ` [PATCH v2 2/3] HID: core: Add printk_once variants to hid_warn() etc stillcompiling
2019-07-22 21:26     ` [PATCH v2 3/3] HID: core: only warn once of oversize hid report stillcompiling
2019-07-22 21:30       ` Joe Perches
2019-07-22 21:43         ` Joshua Clayton
2019-07-22 21:48   ` [PATCH v3 1/3] HID: core: reformat and reduce hid_printk macros stillcompiling
2019-07-22 21:48     ` [PATCH v3 2/3] HID: core: Add printk_once variants to hid_warn() etc stillcompiling
2019-07-22 21:48     ` [PATCH v3 3/3] HID: core: only warn once of oversize hid report stillcompiling
2019-07-22 17:11 ` [PATCH 1/2] HID: core: Add hid printk_once macros Joe Perches

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