All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1 1/1] hwmon: (occ) Replace open-coded variant of %*phN specifier
@ 2022-07-26 14:31 Andy Shevchenko
  2022-07-26 15:05 ` Guenter Roeck
  0 siblings, 1 reply; 3+ messages in thread
From: Andy Shevchenko @ 2022-07-26 14:31 UTC (permalink / raw)
  To: Guenter Roeck, Eddie James, linux-hwmon, linux-kernel
  Cc: Jean Delvare, Andy Shevchenko

printf()-like functions in the kernel have extensions, such as
%*phN to dump small pieces of memory as hex bytes.

Replace custom approach with the direct use of %*phN.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/hwmon/occ/common.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/hwmon/occ/common.c b/drivers/hwmon/occ/common.c
index 157b73a3da29..45407b12db4b 100644
--- a/drivers/hwmon/occ/common.c
+++ b/drivers/hwmon/occ/common.c
@@ -729,18 +729,14 @@ static ssize_t occ_show_extended(struct device *dev,
 			rc = sysfs_emit(buf, "%u",
 					get_unaligned_be32(&extn->sensor_id));
 		} else {
-			rc = sysfs_emit(buf, "%02x%02x%02x%02x\n",
-					extn->name[0], extn->name[1],
-					extn->name[2], extn->name[3]);
+			rc = sysfs_emit(buf, "%4phN\n", extn->name);
 		}
 		break;
 	case 1:
 		rc = sysfs_emit(buf, "%02x\n", extn->flags);
 		break;
 	case 2:
-		rc = sysfs_emit(buf, "%02x%02x%02x%02x%02x%02x\n",
-				extn->data[0], extn->data[1], extn->data[2],
-				extn->data[3], extn->data[4], extn->data[5]);
+		rc = sysfs_emit(buf, "%6phN\n", extn->data);
 		break;
 	default:
 		return -EINVAL;
-- 
2.35.1


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

* Re: [PATCH v1 1/1] hwmon: (occ) Replace open-coded variant of %*phN specifier
  2022-07-26 14:31 [PATCH v1 1/1] hwmon: (occ) Replace open-coded variant of %*phN specifier Andy Shevchenko
@ 2022-07-26 15:05 ` Guenter Roeck
  2022-08-02 19:51   ` Eddie James
  0 siblings, 1 reply; 3+ messages in thread
From: Guenter Roeck @ 2022-07-26 15:05 UTC (permalink / raw)
  To: Andy Shevchenko, Eddie James, linux-hwmon, linux-kernel; +Cc: Jean Delvare

On 7/26/22 07:31, Andy Shevchenko wrote:
> printf()-like functions in the kernel have extensions, such as
> %*phN to dump small pieces of memory as hex bytes.
> 
> Replace custom approach with the direct use of %*phN.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

Applied.

Thanks,
Guenter

> ---
>   drivers/hwmon/occ/common.c | 8 ++------
>   1 file changed, 2 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/hwmon/occ/common.c b/drivers/hwmon/occ/common.c
> index 157b73a3da29..45407b12db4b 100644
> --- a/drivers/hwmon/occ/common.c
> +++ b/drivers/hwmon/occ/common.c
> @@ -729,18 +729,14 @@ static ssize_t occ_show_extended(struct device *dev,
>   			rc = sysfs_emit(buf, "%u",
>   					get_unaligned_be32(&extn->sensor_id));
>   		} else {
> -			rc = sysfs_emit(buf, "%02x%02x%02x%02x\n",
> -					extn->name[0], extn->name[1],
> -					extn->name[2], extn->name[3]);
> +			rc = sysfs_emit(buf, "%4phN\n", extn->name);
>   		}
>   		break;
>   	case 1:
>   		rc = sysfs_emit(buf, "%02x\n", extn->flags);
>   		break;
>   	case 2:
> -		rc = sysfs_emit(buf, "%02x%02x%02x%02x%02x%02x\n",
> -				extn->data[0], extn->data[1], extn->data[2],
> -				extn->data[3], extn->data[4], extn->data[5]);
> +		rc = sysfs_emit(buf, "%6phN\n", extn->data);
>   		break;
>   	default:
>   		return -EINVAL;


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

* Re: [PATCH v1 1/1] hwmon: (occ) Replace open-coded variant of %*phN specifier
  2022-07-26 15:05 ` Guenter Roeck
@ 2022-08-02 19:51   ` Eddie James
  0 siblings, 0 replies; 3+ messages in thread
From: Eddie James @ 2022-08-02 19:51 UTC (permalink / raw)
  To: Guenter Roeck, Andy Shevchenko, linux-hwmon, linux-kernel; +Cc: Jean Delvare


On 7/26/22 10:05, Guenter Roeck wrote:
> On 7/26/22 07:31, Andy Shevchenko wrote:
>> printf()-like functions in the kernel have extensions, such as
>> %*phN to dump small pieces of memory as hex bytes.
>>
>> Replace custom approach with the direct use of %*phN.
>>
>> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>


Email was acting up so I missed this at the time. Thanks Andy!


>
> Applied.
>
> Thanks,
> Guenter
>
>> ---
>>   drivers/hwmon/occ/common.c | 8 ++------
>>   1 file changed, 2 insertions(+), 6 deletions(-)
>>
>> diff --git a/drivers/hwmon/occ/common.c b/drivers/hwmon/occ/common.c
>> index 157b73a3da29..45407b12db4b 100644
>> --- a/drivers/hwmon/occ/common.c
>> +++ b/drivers/hwmon/occ/common.c
>> @@ -729,18 +729,14 @@ static ssize_t occ_show_extended(struct device 
>> *dev,
>>               rc = sysfs_emit(buf, "%u",
>> get_unaligned_be32(&extn->sensor_id));
>>           } else {
>> -            rc = sysfs_emit(buf, "%02x%02x%02x%02x\n",
>> -                    extn->name[0], extn->name[1],
>> -                    extn->name[2], extn->name[3]);
>> +            rc = sysfs_emit(buf, "%4phN\n", extn->name);
>>           }
>>           break;
>>       case 1:
>>           rc = sysfs_emit(buf, "%02x\n", extn->flags);
>>           break;
>>       case 2:
>> -        rc = sysfs_emit(buf, "%02x%02x%02x%02x%02x%02x\n",
>> -                extn->data[0], extn->data[1], extn->data[2],
>> -                extn->data[3], extn->data[4], extn->data[5]);
>> +        rc = sysfs_emit(buf, "%6phN\n", extn->data);
>>           break;
>>       default:
>>           return -EINVAL;
>

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

end of thread, other threads:[~2022-08-02 19:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-26 14:31 [PATCH v1 1/1] hwmon: (occ) Replace open-coded variant of %*phN specifier Andy Shevchenko
2022-07-26 15:05 ` Guenter Roeck
2022-08-02 19:51   ` Eddie James

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.