diff mbox

[v1,1/1] rtl8xxxu: tuse %*ph to dump buffers

Message ID 1464274339-103386-1-git-send-email-andriy.shevchenko@linux.intel.com (mailing list archive)
State Not Applicable
Delegated to: Kalle Valo
Headers show

Commit Message

Andy Shevchenko May 26, 2016, 2:52 p.m. UTC
Use %*ph specifier to dump small buffers in hex format instead of doing this
byte-by-byte.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192c.c | 9 ++-------
 drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192e.c | 9 ++-------
 drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723b.c | 9 ++-------
 3 files changed, 6 insertions(+), 21 deletions(-)

Comments

Joe Perches May 26, 2016, 4:02 p.m. UTC | #1
On Thu, 2016-05-26 at 17:52 +0300, Andy Shevchenko wrote:
> Use %*ph specifier to dump small buffers in hex format instead of doing this
> byte-by-byte.
[]
> diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192c.c b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192c.c
[]
> @@ -413,13 +413,8 @@ static int rtl8192cu_parse_efuse(struct rtl8xxxu_priv *priv)
>  		dev_info(&priv->udev->dev,
>  			 "%s: dumping efuse (0x%02zx bytes):\n",
>  			 __func__, sizeof(struct rtl8192cu_efuse));
> -		for (i = 0; i < sizeof(struct rtl8192cu_efuse); i += 8) {
> -			dev_info(&priv->udev->dev, "%02x: "
> -				 "%02x %02x %02x %02x %02x %02x %02x %02x\n", i,
> -				 raw[i], raw[i + 1], raw[i + 2],
> -				 raw[i + 3], raw[i + 4], raw[i + 5],
> -				 raw[i + 6], raw[i + 7]);
> -		}
> +		for (i = 0; i < sizeof(struct rtl8192cu_efuse); i += 8)
> +			dev_info(&priv->udev->dev, "%02x: %8ph\n", i, &raw[i]);

print_hex_dump_bytes?

or maybe add a dev_print_hex_dump variant?

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Andy Shevchenko May 26, 2016, 4:57 p.m. UTC | #2
On Thu, 2016-05-26 at 09:02 -0700, Joe Perches wrote:
> On Thu, 2016-05-26 at 17:52 +0300, Andy Shevchenko wrote:
> > Use %*ph specifier to dump small buffers in hex format instead of
> > doing this
> > byte-by-byte.
> []
> > diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192c.c
> > b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192c.c
> []
> > @@ -413,13 +413,8 @@ static int rtl8192cu_parse_efuse(struct
> > rtl8xxxu_priv *priv)
> >  		dev_info(&priv->udev->dev,
> >  			 "%s: dumping efuse (0x%02zx bytes):\n",
> >  			 __func__, sizeof(struct rtl8192cu_efuse));
> > -		for (i = 0; i < sizeof(struct rtl8192cu_efuse); i
> > += 8) {
> > -			dev_info(&priv->udev->dev, "%02x: "
> > -				 "%02x %02x %02x %02x %02x %02x
> > %02x %02x\n", i,
> > -				 raw[i], raw[i + 1], raw[i + 2],
> > -				 raw[i + 3], raw[i + 4], raw[i +
> > 5],
> > -				 raw[i + 6], raw[i + 7]);
> > -		}
> > +		for (i = 0; i < sizeof(struct rtl8192cu_efuse); i
> > += 8)
> > +			dev_info(&priv->udev->dev, "%02x: %8ph\n",
> > i, &raw[i]);
> 
> print_hex_dump_bytes?

I know, perhaps I had to mention that it is not too beneficial here. 

> or maybe add a dev_print_hex_dump variant?

I don't know how much users we have to introduce a such. This is
actually a main reason I avoid to use print_hex_dump() above. Btw, the
above might be collapsed into one function instead of 3 times of copy-n-
paste.
Jes Sorensen May 26, 2016, 8:16 p.m. UTC | #3
Andy Shevchenko <andriy.shevchenko@linux.intel.com> writes:
> On Thu, 2016-05-26 at 09:02 -0700, Joe Perches wrote:
>> On Thu, 2016-05-26 at 17:52 +0300, Andy Shevchenko wrote:
>> > Use %*ph specifier to dump small buffers in hex format instead of
>> > doing this
>> > byte-by-byte.
>> []
>> > diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192c.c
>> > b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192c.c
>> []
>> > @@ -413,13 +413,8 @@ static int rtl8192cu_parse_efuse(struct
>> > rtl8xxxu_priv *priv)
>> >  		dev_info(&priv->udev->dev,
>> >  			 "%s: dumping efuse (0x%02zx bytes):\n",
>> >  			 __func__, sizeof(struct rtl8192cu_efuse));
>> > -		for (i = 0; i < sizeof(struct rtl8192cu_efuse); i
>> > += 8) {
>> > -			dev_info(&priv->udev->dev, "%02x: "
>> > -				 "%02x %02x %02x %02x %02x %02x
>> > %02x %02x\n", i,
>> > -				 raw[i], raw[i + 1], raw[i + 2],
>> > -				 raw[i + 3], raw[i + 4], raw[i +
>> > 5],
>> > -				 raw[i + 6], raw[i + 7]);
>> > -		}
>> > +		for (i = 0; i < sizeof(struct rtl8192cu_efuse); i
>> > += 8)
>> > +			dev_info(&priv->udev->dev, "%02x: %8ph\n",
>> > i, &raw[i]);
>> 
>> print_hex_dump_bytes?
>
> I know, perhaps I had to mention that it is not too beneficial here. 
>
>> or maybe add a dev_print_hex_dump variant?
>
> I don't know how much users we have to introduce a such. This is
> actually a main reason I avoid to use print_hex_dump() above. Btw, the
> above might be collapsed into one function instead of 3 times of copy-n-
> paste.

I think a dev_print_hex_dump() would be useful here. When I first read
your patch I was a bit hmmmm but then I realized why you had stuck with
the %8ph rather than print_hex_dump().

I'll apply it shortly.

Jes
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192c.c b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192c.c
index 2c86b55..eefb7ca 100644
--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192c.c
+++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192c.c
@@ -413,13 +413,8 @@  static int rtl8192cu_parse_efuse(struct rtl8xxxu_priv *priv)
 		dev_info(&priv->udev->dev,
 			 "%s: dumping efuse (0x%02zx bytes):\n",
 			 __func__, sizeof(struct rtl8192cu_efuse));
-		for (i = 0; i < sizeof(struct rtl8192cu_efuse); i += 8) {
-			dev_info(&priv->udev->dev, "%02x: "
-				 "%02x %02x %02x %02x %02x %02x %02x %02x\n", i,
-				 raw[i], raw[i + 1], raw[i + 2],
-				 raw[i + 3], raw[i + 4], raw[i + 5],
-				 raw[i + 6], raw[i + 7]);
-		}
+		for (i = 0; i < sizeof(struct rtl8192cu_efuse); i += 8)
+			dev_info(&priv->udev->dev, "%02x: %8ph\n", i, &raw[i]);
 	}
 	return 0;
 }
diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192e.c b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192e.c
index fe19ace..65c079a 100644
--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192e.c
+++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192e.c
@@ -622,13 +622,8 @@  static int rtl8192eu_parse_efuse(struct rtl8xxxu_priv *priv)
 		dev_info(&priv->udev->dev,
 			 "%s: dumping efuse (0x%02zx bytes):\n",
 			 __func__, sizeof(struct rtl8192eu_efuse));
-		for (i = 0; i < sizeof(struct rtl8192eu_efuse); i += 8) {
-			dev_info(&priv->udev->dev, "%02x: "
-				 "%02x %02x %02x %02x %02x %02x %02x %02x\n", i,
-				 raw[i], raw[i + 1], raw[i + 2],
-				 raw[i + 3], raw[i + 4], raw[i + 5],
-				 raw[i + 6], raw[i + 7]);
-		}
+		for (i = 0; i < sizeof(struct rtl8192eu_efuse); i += 8)
+			dev_info(&priv->udev->dev, "%02x: %8ph\n", i, &raw[i]);
 	}
 	return 0;
 }
diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723b.c b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723b.c
index 4186e7c..9d45afb 100644
--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723b.c
+++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723b.c
@@ -466,13 +466,8 @@  static int rtl8723bu_parse_efuse(struct rtl8xxxu_priv *priv)
 		dev_info(&priv->udev->dev,
 			 "%s: dumping efuse (0x%02zx bytes):\n",
 			 __func__, sizeof(struct rtl8723bu_efuse));
-		for (i = 0; i < sizeof(struct rtl8723bu_efuse); i += 8) {
-			dev_info(&priv->udev->dev, "%02x: "
-				 "%02x %02x %02x %02x %02x %02x %02x %02x\n", i,
-				 raw[i], raw[i + 1], raw[i + 2],
-				 raw[i + 3], raw[i + 4], raw[i + 5],
-				 raw[i + 6], raw[i + 7]);
-		}
+		for (i = 0; i < sizeof(struct rtl8723bu_efuse); i += 8)
+			dev_info(&priv->udev->dev, "%02x: %8ph\n", i, &raw[i]);
 	}
 
 	return 0;