netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] iwlwifi: convert hex_dump_to_buffer() to %*ph
@ 2015-07-16 12:42 Andy Shevchenko
  2015-07-16 12:42 ` [PATCH 2/2] iwlegacy: " Andy Shevchenko
  2015-08-04 10:47 ` [PATCH 1/2] iwlwifi: " Andy Shevchenko
  0 siblings, 2 replies; 6+ messages in thread
From: Andy Shevchenko @ 2015-07-16 12:42 UTC (permalink / raw)
  To: netdev-u79uwXL29TY76Z2rM5mHXA,
	linux-wireless-u79uwXL29TY76Z2rM5mHXA, Johannes Berg, Kalle Valo,
	Stanislaw Gruszka
  Cc: Andy Shevchenko

There is no need to use hex_dump_to_buffer() in the cases like this:

	hexdump_to_buffer(buf, len, 16, 1, outbuf, outlen, false);	/* len <= 16 */
	sprintf("%s\n", outbuf);

since it maybe easily converted to simple:

	sprintf("%*ph\n", len, buf);

Note: it seems in one case the output is groupped by 2 bytes and looks like a
typo. Thus, patch changes that to plain byte stream.

Signed-off-by: Andy Shevchenko <andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
---
 drivers/net/wireless/iwlwifi/dvm/debugfs.c | 8 ++------
 drivers/net/wireless/iwlwifi/mvm/debugfs.c | 7 +------
 2 files changed, 3 insertions(+), 12 deletions(-)

diff --git a/drivers/net/wireless/iwlwifi/dvm/debugfs.c b/drivers/net/wireless/iwlwifi/dvm/debugfs.c
index 0ffb6ff..b15e44f 100644
--- a/drivers/net/wireless/iwlwifi/dvm/debugfs.c
+++ b/drivers/net/wireless/iwlwifi/dvm/debugfs.c
@@ -310,12 +310,8 @@ static ssize_t iwl_dbgfs_nvm_read(struct file *file,
 	pos += scnprintf(buf + pos, buf_size - pos,
 			 "NVM version: 0x%x\n", nvm_ver);
 	for (ofs = 0 ; ofs < eeprom_len ; ofs += 16) {
-		pos += scnprintf(buf + pos, buf_size - pos, "0x%.4x ", ofs);
-		hex_dump_to_buffer(ptr + ofs, 16 , 16, 2, buf + pos,
-				   buf_size - pos, 0);
-		pos += strlen(buf + pos);
-		if (buf_size - pos > 0)
-			buf[pos++] = '\n';
+		pos += scnprintf(buf + pos, buf_size - pos, "0x%.4x %16ph\n",
+				 ofs, ptr + ofs);
 	}
 
 	ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
diff --git a/drivers/net/wireless/iwlwifi/mvm/debugfs.c b/drivers/net/wireless/iwlwifi/mvm/debugfs.c
index ffb4b5c..98abd31 100644
--- a/drivers/net/wireless/iwlwifi/mvm/debugfs.c
+++ b/drivers/net/wireless/iwlwifi/mvm/debugfs.c
@@ -1200,12 +1200,7 @@ static ssize_t iwl_dbgfs_d3_sram_read(struct file *file, char __user *user_buf,
 	if (ptr) {
 		for (ofs = 0; ofs < len; ofs += 16) {
 			pos += scnprintf(buf + pos, bufsz - pos,
-					 "0x%.4x ", ofs);
-			hex_dump_to_buffer(ptr + ofs, 16, 16, 1, buf + pos,
-					   bufsz - pos, false);
-			pos += strlen(buf + pos);
-			if (bufsz - pos > 0)
-				buf[pos++] = '\n';
+					 "0x%.4x %16ph\n", ofs, ptr + ofs);
 		}
 	} else {
 		pos += scnprintf(buf + pos, bufsz - pos,
-- 
2.1.4

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

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

* [PATCH 2/2] iwlegacy: convert hex_dump_to_buffer() to %*ph
  2015-07-16 12:42 [PATCH 1/2] iwlwifi: convert hex_dump_to_buffer() to %*ph Andy Shevchenko
@ 2015-07-16 12:42 ` Andy Shevchenko
  2015-07-21 15:08   ` [2/2] " Kalle Valo
  2015-08-04 10:47 ` [PATCH 1/2] iwlwifi: " Andy Shevchenko
  1 sibling, 1 reply; 6+ messages in thread
From: Andy Shevchenko @ 2015-07-16 12:42 UTC (permalink / raw)
  To: netdev, linux-wireless, Johannes Berg, Kalle Valo,
	Stanislaw Gruszka
  Cc: Andy Shevchenko

There is no need to use hex_dump_to_buffer() in the cases like this:

	hexdump_to_buffer(buf, len, 16, 1, outbuf, outlen, false);	/* len <= 16 */
	sprintf("%s\n", outbuf);

since it maybe easily converted to simple:

	sprintf("%*ph\n", len, buf);

Note: it seems in the case the output is groupped by 2 bytes and looks like a
typo. Thus, patch changes that to plain byte stream.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/net/wireless/iwlegacy/3945-mac.c | 2 +-
 drivers/net/wireless/iwlegacy/debug.c    | 8 ++------
 2 files changed, 3 insertions(+), 7 deletions(-)

diff --git a/drivers/net/wireless/iwlegacy/3945-mac.c b/drivers/net/wireless/iwlegacy/3945-mac.c
index 7f4cb69..af1b3e6 100644
--- a/drivers/net/wireless/iwlegacy/3945-mac.c
+++ b/drivers/net/wireless/iwlegacy/3945-mac.c
@@ -3259,7 +3259,7 @@ il3945_show_measurement(struct device *d, struct device_attribute *attr,
 
 	while (size && PAGE_SIZE - len) {
 		hex_dump_to_buffer(data + ofs, size, 16, 1, buf + len,
-				   PAGE_SIZE - len, 1);
+				   PAGE_SIZE - len, true);
 		len = strlen(buf);
 		if (PAGE_SIZE - len)
 			buf[len++] = '\n';
diff --git a/drivers/net/wireless/iwlegacy/debug.c b/drivers/net/wireless/iwlegacy/debug.c
index 3440101..908b9f4 100644
--- a/drivers/net/wireless/iwlegacy/debug.c
+++ b/drivers/net/wireless/iwlegacy/debug.c
@@ -515,12 +515,8 @@ il_dbgfs_nvm_read(struct file *file, char __user *user_buf, size_t count,
 	    scnprintf(buf + pos, buf_size - pos, "EEPROM " "version: 0x%x\n",
 		      eeprom_ver);
 	for (ofs = 0; ofs < eeprom_len; ofs += 16) {
-		pos += scnprintf(buf + pos, buf_size - pos, "0x%.4x ", ofs);
-		hex_dump_to_buffer(ptr + ofs, 16, 16, 2, buf + pos,
-				   buf_size - pos, 0);
-		pos += strlen(buf + pos);
-		if (buf_size - pos > 0)
-			buf[pos++] = '\n';
+		pos += scnprintf(buf + pos, buf_size - pos, "0x%.4x %16ph\n",
+				 ofs, ptr + ofs);
 	}
 
 	ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
-- 
2.1.4

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

* Re: [2/2] iwlegacy: convert hex_dump_to_buffer() to %*ph
  2015-07-16 12:42 ` [PATCH 2/2] iwlegacy: " Andy Shevchenko
@ 2015-07-21 15:08   ` Kalle Valo
  0 siblings, 0 replies; 6+ messages in thread
From: Kalle Valo @ 2015-07-21 15:08 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: netdev, linux-wireless, Johannes Berg, Stanislaw Gruszka,
	Andy Shevchenko


> There is no need to use hex_dump_to_buffer() in the cases like this:
> 
> 	hexdump_to_buffer(buf, len, 16, 1, outbuf, outlen, false);	/* len <= 16 */
> 	sprintf("%s\n", outbuf);
> 
> since it maybe easily converted to simple:
> 
> 	sprintf("%*ph\n", len, buf);
> 
> Note: it seems in the case the output is groupped by 2 bytes and looks like a
> typo. Thus, patch changes that to plain byte stream.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

Thanks, applied to wireless-drivers-next.git.

Kalle Valo

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

* Re: [PATCH 1/2] iwlwifi: convert hex_dump_to_buffer() to %*ph
  2015-07-16 12:42 [PATCH 1/2] iwlwifi: convert hex_dump_to_buffer() to %*ph Andy Shevchenko
  2015-07-16 12:42 ` [PATCH 2/2] iwlegacy: " Andy Shevchenko
@ 2015-08-04 10:47 ` Andy Shevchenko
       [not found]   ` <1438685233.29746.156.camel-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
  1 sibling, 1 reply; 6+ messages in thread
From: Andy Shevchenko @ 2015-08-04 10:47 UTC (permalink / raw)
  To: netdev, linux-wireless, Johannes Berg, Kalle Valo,
	Stanislaw Gruszka

On Thu, 2015-07-16 at 15:42 +0300, Andy Shevchenko wrote:
> There is no need to use hex_dump_to_buffer() in the cases like this:
> 
> 	hexdump_to_buffer(buf, len, 16, 1, outbuf, outlen, false);	> /* len <= 16 
> */
> 	sprintf("%s\n", outbuf);
> 
> since it maybe easily converted to simple:
> 
> 	sprintf("%*ph\n", len, buf);
> 
> Note: it seems in one case the output is groupped by 2 bytes and 
> looks like a
> typo. Thus, patch changes that to plain byte stream.


Any comments on this, anyone?

The idea is to minimize usage of hexdump_to_buffer(), i.e. not using it
when it's an obvious overkill.

> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>  drivers/net/wireless/iwlwifi/dvm/debugfs.c | 8 ++------
>  drivers/net/wireless/iwlwifi/mvm/debugfs.c | 7 +------
>  2 files changed, 3 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/net/wireless/iwlwifi/dvm/debugfs.c 
> b/drivers/net/wireless/iwlwifi/dvm/debugfs.c
> index 0ffb6ff..b15e44f 100644
> --- a/drivers/net/wireless/iwlwifi/dvm/debugfs.c
> +++ b/drivers/net/wireless/iwlwifi/dvm/debugfs.c
> @@ -310,12 +310,8 @@ static ssize_t iwl_dbgfs_nvm_read(struct file 
> *file,
>  	pos += scnprintf(buf + pos, buf_size - pos,
>  			 "NVM version: 0x%x\n", nvm_ver);
>  	for (ofs = 0 ; ofs < eeprom_len ; ofs += 16) {
> -		pos += scnprintf(buf + pos, buf_size - pos, "0x%.4x 
> ", ofs);
> -		hex_dump_to_buffer(ptr + ofs, 16 , 16, 2, buf + pos,
> -				   buf_size - pos, 0);
> -		pos += strlen(buf + pos);
> -		if (buf_size - pos > 0)
> -			buf[pos++] = '\n';
> +		pos += scnprintf(buf + pos, buf_size - pos, "0x%.4x 
> %16ph\n",
> +				 ofs, ptr + ofs);
>  	}
>  
>  	ret = simple_read_from_buffer(user_buf, count, ppos, buf, 
> pos);
> diff --git a/drivers/net/wireless/iwlwifi/mvm/debugfs.c 
> b/drivers/net/wireless/iwlwifi/mvm/debugfs.c
> index ffb4b5c..98abd31 100644
> --- a/drivers/net/wireless/iwlwifi/mvm/debugfs.c
> +++ b/drivers/net/wireless/iwlwifi/mvm/debugfs.c
> @@ -1200,12 +1200,7 @@ static ssize_t iwl_dbgfs_d3_sram_read(struct 
> file *file, char __user *user_buf,
>  	if (ptr) {
>  		for (ofs = 0; ofs < len; ofs += 16) {
>  			pos += scnprintf(buf + pos, bufsz - pos,
> -					 "0x%.4x ", ofs);
> -			hex_dump_to_buffer(ptr + ofs, 16, 16, 1, buf 
> + pos,
> -					   bufsz - pos, false);
> -			pos += strlen(buf + pos);
> -			if (bufsz - pos > 0)
> -				buf[pos++] = '\n';
> +					 "0x%.4x %16ph\n", ofs, ptr 
> + ofs);
>  		}
>  	} else {
>  		pos += scnprintf(buf + pos, bufsz - pos,

-- 
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Intel Finland Oy

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

* Re: [PATCH 1/2] iwlwifi: convert hex_dump_to_buffer() to %*ph
       [not found]   ` <1438685233.29746.156.camel-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
@ 2015-08-04 11:48     ` Emmanuel Grumbach
  2015-08-04 11:52       ` Emmanuel Grumbach
  0 siblings, 1 reply; 6+ messages in thread
From: Emmanuel Grumbach @ 2015-08-04 11:48 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-wireless,
	Johannes Berg, Kalle Valo, Stanislaw Gruszka

On Tue, Aug 4, 2015 at 1:47 PM, Andy Shevchenko
<andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA@public.gmane.org> wrote:
> On Thu, 2015-07-16 at 15:42 +0300, Andy Shevchenko wrote:
>> There is no need to use hex_dump_to_buffer() in the cases like this:
>>
>>       hexdump_to_buffer(buf, len, 16, 1, outbuf, outlen, false);      > /* len <= 16
>> */
>>       sprintf("%s\n", outbuf);
>>
>> since it maybe easily converted to simple:
>>
>>       sprintf("%*ph\n", len, buf);
>>
>> Note: it seems in one case the output is groupped by 2 bytes and
>> looks like a
>> typo. Thus, patch changes that to plain byte stream.
>
>
> Any comments on this, anyone?
>
> The idea is to minimize usage of hexdump_to_buffer(), i.e. not using it
> when it's an obvious overkill.
>

Sorry for the delay, since the buffer is small (less than 16 bytes, it
should be fine).
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH 1/2] iwlwifi: convert hex_dump_to_buffer() to %*ph
  2015-08-04 11:48     ` Emmanuel Grumbach
@ 2015-08-04 11:52       ` Emmanuel Grumbach
  0 siblings, 0 replies; 6+ messages in thread
From: Emmanuel Grumbach @ 2015-08-04 11:52 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: netdev@vger.kernel.org, linux-wireless, Johannes Berg, Kalle Valo,
	Stanislaw Gruszka

On Tue, Aug 4, 2015 at 2:48 PM, Emmanuel Grumbach <egrumbach@gmail.com> wrote:
> On Tue, Aug 4, 2015 at 1:47 PM, Andy Shevchenko
> <andriy.shevchenko@linux.intel.com> wrote:
>> On Thu, 2015-07-16 at 15:42 +0300, Andy Shevchenko wrote:
>>> There is no need to use hex_dump_to_buffer() in the cases like this:
>>>
>>>       hexdump_to_buffer(buf, len, 16, 1, outbuf, outlen, false);      > /* len <= 16
>>> */
>>>       sprintf("%s\n", outbuf);
>>>
>>> since it maybe easily converted to simple:
>>>
>>>       sprintf("%*ph\n", len, buf);
>>>
>>> Note: it seems in one case the output is groupped by 2 bytes and
>>> looks like a
>>> typo. Thus, patch changes that to plain byte stream.
>>
>>
>> Any comments on this, anyone?
>>
>> The idea is to minimize usage of hexdump_to_buffer(), i.e. not using it
>> when it's an obvious overkill.
>>
>
> Sorry for the delay, since the buffer is small (less than 16 bytes, it
> should be fine).

I applied it on our internal tree. Thank you.

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

end of thread, other threads:[~2015-08-04 11:52 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-07-16 12:42 [PATCH 1/2] iwlwifi: convert hex_dump_to_buffer() to %*ph Andy Shevchenko
2015-07-16 12:42 ` [PATCH 2/2] iwlegacy: " Andy Shevchenko
2015-07-21 15:08   ` [2/2] " Kalle Valo
2015-08-04 10:47 ` [PATCH 1/2] iwlwifi: " Andy Shevchenko
     [not found]   ` <1438685233.29746.156.camel-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2015-08-04 11:48     ` Emmanuel Grumbach
2015-08-04 11:52       ` Emmanuel Grumbach

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