Message ID | 20230627184027.16343-1-eajames@linux.ibm.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp8412286vqr; Tue, 27 Jun 2023 12:07:55 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7ekakKjaW4Qp2ln1tvStTKDfdeaATb7GQ0b1mcuEzeTQU1PriFjUCe5n7m67uG36GFgY44 X-Received: by 2002:a17:907:928d:b0:953:8249:1834 with SMTP id bw13-20020a170907928d00b0095382491834mr27895526ejc.16.1687892874846; Tue, 27 Jun 2023 12:07:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687892874; cv=none; d=google.com; s=arc-20160816; b=lAhxaJ25PN/5JkqJ0xXv5Ub7DRRC0Vtev01gxntHhxTw+CcKfPcJfDkWea/Pt+9i7w GTvfajT/t/csPxNW/1Db+iWiL2HYprhaYZgMMxJloGmqQhnrJXVK4WHrtph5GtHmgdr+ /zq7emrjnNlrs8s0lG+bsvwJIuU8f7GUNYBH3lOOxx7Wo2hvxW1Ap2DDTyeatcA8K6Bw +XyzTwiSjio/PoUNjyDTeCMCdBoTMzS7UuKqJUSYJZfoEkJH8fbnPEJx7U/PPnI3P7Ys F57qxsOY6Tf/NFGbYaUBUAF6f25iOFVtZiKFYrJq8sXOYoZKhdAqAk0Qf4KXYMPvrvc3 3hwA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=C3D/P4FPq9C11xGqw+J0fMya1etpgORpNTBZHmpQ5a0=; fh=4+peFJK9TXCte9iQ3M/4CYngH0AZNqSI8cjipV0/9Vw=; b=N7B/FCexqJOsmJzyjBewqb/kkVEB19k7D+Q7ze8vjEbAnJ4b5Bo7YDnLn7vziYgI9I PfFhdGr2xNPQuPm+lMemCeeaw+L/OJUwar/MoqT4ayW62yaICT+tJnOAW5v8KkLGkEbn 5MzVI7+giDB/F+rlGRcVufBZwTZakIsj1ZH8TPwppCStzU+ySceL0Y8dpNFzXmS1GCIw krEEhRQmNN3elXLuzWtNb/0G1aic15ziveFhvR7km/3kxnTRBI6Jgsu1MVhlLIfVb1mJ n5nfBH2UeUN0NlGq/cJ8vInIhayNRyUIS4tPPzP1rHD5EB1bBrL/CLIzu8dnDWBgMKNx 0ung== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=PGitqmLY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s23-20020a1709066c9700b0098896420108si4715361ejr.170.2023.06.27.12.07.29; Tue, 27 Jun 2023 12:07:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=PGitqmLY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231416AbjF0TFU (ORCPT <rfc822;nicolai.engesland@gmail.com> + 99 others); Tue, 27 Jun 2023 15:05:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42058 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231396AbjF0TFQ (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 27 Jun 2023 15:05:16 -0400 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CCD3D185; Tue, 27 Jun 2023 12:05:15 -0700 (PDT) Received: from pps.filterd (m0353729.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 35RIxaTa031473; Tue, 27 Jun 2023 19:05:02 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : mime-version : content-transfer-encoding; s=pp1; bh=C3D/P4FPq9C11xGqw+J0fMya1etpgORpNTBZHmpQ5a0=; b=PGitqmLY/HXn5BLhQYJs51QT78xDtZP6o3Dnyte/7G9Ugd5eciKJ+3/VoHZgNF1QqVGr Yn2kNib6u56WbS+hJCJGWn6szXh/GOp8uiQ1OXDTATHHmzybJDJ6ArOhNeeGllikOrPS E3LjynpYYCdNBBI8x1qEHBZt27l6AdezA5ouoQmdbsovq3QQrAN1WqjHdRChtIHTA6Y+ QpIkrd5lCLnul+TdcOpPyilQODVw1Ykh+4rr0cocdPY0Su7hYKDGZ9JBPNZjWWNFeytD 1mSxwzTTGTDoPHWZzDWCUqL/HPWLEvfAUJA9xg9Me8vPadg8qt/4eVvdydavl1CFMdTk wQ== Received: from ppma01wdc.us.ibm.com (fd.55.37a9.ip4.static.sl-reverse.com [169.55.85.253]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3rg5hag6et-7 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 27 Jun 2023 19:05:01 +0000 Received: from pps.filterd (ppma01wdc.us.ibm.com [127.0.0.1]) by ppma01wdc.us.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 35RHkVFN013240; Tue, 27 Jun 2023 18:40:32 GMT Received: from smtprelay02.wdc07v.mail.ibm.com ([9.208.129.120]) by ppma01wdc.us.ibm.com (PPS) with ESMTPS id 3rdr45j2e6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 27 Jun 2023 18:40:32 +0000 Received: from smtpav06.dal12v.mail.ibm.com (smtpav06.dal12v.mail.ibm.com [10.241.53.105]) by smtprelay02.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 35RIeUNe66257280 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 27 Jun 2023 18:40:31 GMT Received: from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9593658043; Tue, 27 Jun 2023 18:40:30 +0000 (GMT) Received: from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 639B258055; Tue, 27 Jun 2023 18:40:30 +0000 (GMT) Received: from slate16.aus.stglabs.ibm.com (unknown [9.61.104.152]) by smtpav06.dal12v.mail.ibm.com (Postfix) with ESMTP; Tue, 27 Jun 2023 18:40:30 +0000 (GMT) From: Eddie James <eajames@linux.ibm.com> To: linux-hwmon@vger.kernel.org Cc: linux-kernel@vger.kernel.org, linux@roeck-us.net, jdelvare@suse.com, lakshmiy@us.ibm.com, Eddie James <eajames@linux.ibm.com> Subject: [PATCH] hwmon: (pmbus/acbel-fsg032) Add firmware version debugfs attribute Date: Tue, 27 Jun 2023 13:40:27 -0500 Message-Id: <20230627184027.16343-1-eajames@linux.ibm.com> X-Mailer: git-send-email 2.39.3 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: yCImGPd8-ZGvACJ7YC59vgajXeidnTVp X-Proofpoint-GUID: yCImGPd8-ZGvACJ7YC59vgajXeidnTVp X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-06-27_13,2023-06-27_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 phishscore=0 clxscore=1011 lowpriorityscore=0 mlxlogscore=999 suspectscore=0 spamscore=0 impostorscore=0 malwarescore=0 mlxscore=0 adultscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2305260000 definitions=main-2306270173 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769883959477211123?= X-GMAIL-MSGID: =?utf-8?q?1769883959477211123?= |
Series |
hwmon: (pmbus/acbel-fsg032) Add firmware version debugfs attribute
|
|
Commit Message
Eddie James
June 27, 2023, 6:40 p.m. UTC
Like the IBM CFFPS driver, export the PSU's firmware version to a
debugfs attribute as reported in the manufacturer register.
Signed-off-by: Eddie James <eajames@linux.ibm.com>
---
drivers/hwmon/pmbus/acbel-fsg032.c | 48 ++++++++++++++++++++++++++++++
1 file changed, 48 insertions(+)
Comments
On 6/27/23 11:40, Eddie James wrote: > Like the IBM CFFPS driver, export the PSU's firmware version to a > debugfs attribute as reported in the manufacturer register. > > Signed-off-by: Eddie James <eajames@linux.ibm.com> > --- > drivers/hwmon/pmbus/acbel-fsg032.c | 48 ++++++++++++++++++++++++++++++ > 1 file changed, 48 insertions(+) > > diff --git a/drivers/hwmon/pmbus/acbel-fsg032.c b/drivers/hwmon/pmbus/acbel-fsg032.c > index 0a0ef4ce3493..4b97f108cfe3 100644 > --- a/drivers/hwmon/pmbus/acbel-fsg032.c > +++ b/drivers/hwmon/pmbus/acbel-fsg032.c > @@ -3,6 +3,7 @@ > * Copyright 2023 IBM Corp. > */ > > +#include <linux/debugfs.h> > #include <linux/device.h> > #include <linux/fs.h> > #include <linux/i2c.h> > @@ -11,6 +12,52 @@ > #include <linux/hwmon-sysfs.h> > #include "pmbus.h" > > +#define ACBEL_MFR_FW_REVISION 0xd9 > + > +static ssize_t acbel_fsg032_debugfs_read(struct file *file, char __user *buf, size_t count, > + loff_t *ppos) > +{ > + struct i2c_client *client = file->private_data; > + char data[I2C_SMBUS_BLOCK_MAX + 2] = { 0 }; > + char out[8]; > + int rc; > + int i; > + > + rc = pmbus_lock_interruptible(client); Is that needed here ? > + if (rc) > + return rc; > + > + rc = i2c_smbus_read_block_data(client, ACBEL_MFR_FW_REVISION, data); > + pmbus_unlock(client); > + if (rc < 0) > + return rc; > + > + for (i = 0; i < rc && i < 3; ++i) > + snprintf(&out[i * 2], 3, "%02X", data[i]); > + > + rc = i * 2; > + out[rc++] = '\n'; > + out[rc++] = 0; Any reason for not using one of the %*ph variants ? Thanks, Guenter > + return simple_read_from_buffer(buf, count, ppos, out, rc); > +} > + > +static const struct file_operations acbel_debugfs_ops = { > + .llseek = noop_llseek, > + .read = acbel_fsg032_debugfs_read, > + .write = NULL, > + .open = simple_open, > +}; > + > +static void acbel_fsg032_init_debugfs(struct i2c_client *client) > +{ > + struct dentry *debugfs = pmbus_get_debugfs_dir(client); > + > + if (!debugfs) > + return; > + > + debugfs_create_file("fw_version", 0444, debugfs, client, &acbel_debugfs_ops); > +} > + > static const struct i2c_device_id acbel_fsg032_id[] = { > { "acbel_fsg032" }, > {} > @@ -59,6 +106,7 @@ static int acbel_fsg032_probe(struct i2c_client *client) > if (rc) > return rc; > > + acbel_fsg032_init_debugfs(client); > return 0; > } >
On 6/27/23 17:19, Guenter Roeck wrote: > On 6/27/23 11:40, Eddie James wrote: >> Like the IBM CFFPS driver, export the PSU's firmware version to a >> debugfs attribute as reported in the manufacturer register. >> >> Signed-off-by: Eddie James <eajames@linux.ibm.com> >> --- >> drivers/hwmon/pmbus/acbel-fsg032.c | 48 ++++++++++++++++++++++++++++++ >> 1 file changed, 48 insertions(+) >> >> diff --git a/drivers/hwmon/pmbus/acbel-fsg032.c >> b/drivers/hwmon/pmbus/acbel-fsg032.c >> index 0a0ef4ce3493..4b97f108cfe3 100644 >> --- a/drivers/hwmon/pmbus/acbel-fsg032.c >> +++ b/drivers/hwmon/pmbus/acbel-fsg032.c >> @@ -3,6 +3,7 @@ >> * Copyright 2023 IBM Corp. >> */ >> +#include <linux/debugfs.h> >> #include <linux/device.h> >> #include <linux/fs.h> >> #include <linux/i2c.h> >> @@ -11,6 +12,52 @@ >> #include <linux/hwmon-sysfs.h> >> #include "pmbus.h" >> +#define ACBEL_MFR_FW_REVISION 0xd9 >> + >> +static ssize_t acbel_fsg032_debugfs_read(struct file *file, char >> __user *buf, size_t count, >> + loff_t *ppos) >> +{ >> + struct i2c_client *client = file->private_data; >> + char data[I2C_SMBUS_BLOCK_MAX + 2] = { 0 }; >> + char out[8]; >> + int rc; >> + int i; >> + >> + rc = pmbus_lock_interruptible(client); > > Is that needed here ? Good point, it's not. > >> + if (rc) >> + return rc; >> + >> + rc = i2c_smbus_read_block_data(client, ACBEL_MFR_FW_REVISION, >> data); >> + pmbus_unlock(client); >> + if (rc < 0) >> + return rc; >> + >> + for (i = 0; i < rc && i < 3; ++i) >> + snprintf(&out[i * 2], 3, "%02X", data[i]); >> + >> + rc = i * 2; >> + out[rc++] = '\n'; >> + out[rc++] = 0; > > Any reason for not using one of the %*ph variants ? Nope, that will work great, thanks. Eddie > > Thanks, > Guenter > >> + return simple_read_from_buffer(buf, count, ppos, out, rc); >> +} >> + >> +static const struct file_operations acbel_debugfs_ops = { >> + .llseek = noop_llseek, >> + .read = acbel_fsg032_debugfs_read, >> + .write = NULL, >> + .open = simple_open, >> +}; >> + >> +static void acbel_fsg032_init_debugfs(struct i2c_client *client) >> +{ >> + struct dentry *debugfs = pmbus_get_debugfs_dir(client); >> + >> + if (!debugfs) >> + return; >> + >> + debugfs_create_file("fw_version", 0444, debugfs, client, >> &acbel_debugfs_ops); >> +} >> + >> static const struct i2c_device_id acbel_fsg032_id[] = { >> { "acbel_fsg032" }, >> {} >> @@ -59,6 +106,7 @@ static int acbel_fsg032_probe(struct i2c_client >> *client) >> if (rc) >> return rc; >> + acbel_fsg032_init_debugfs(client); >> return 0; >> } >
Hi Eddie, kernel test robot noticed the following build warnings: https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/Eddie-James/hwmon-pmbus-acbel-fsg032-Add-firmware-version-debugfs-attribute/20230628-030615 base: https://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging.git hwmon-next patch link: https://lore.kernel.org/r/20230627184027.16343-1-eajames%40linux.ibm.com patch subject: [PATCH] hwmon: (pmbus/acbel-fsg032) Add firmware version debugfs attribute config: x86_64-randconfig-m001-20230627 (https://download.01.org/0day-ci/archive/20230628/202306281205.NFXmu7xb-lkp@intel.com/config) compiler: gcc-12 (Debian 12.2.0-14) 12.2.0 reproduce: (https://download.01.org/0day-ci/archive/20230628/202306281205.NFXmu7xb-lkp@intel.com/reproduce) If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot <lkp@intel.com> | Reported-by: Dan Carpenter <dan.carpenter@linaro.org> | Closes: https://lore.kernel.org/r/202306281205.NFXmu7xb-lkp@intel.com/ smatch warnings: drivers/hwmon/pmbus/acbel-fsg032.c:36 acbel_fsg032_debugfs_read() warn: argument 4 to %02X specifier has type 'char' vim +/char +36 drivers/hwmon/pmbus/acbel-fsg032.c d2c6444389b625 Eddie James 2023-06-27 17 static ssize_t acbel_fsg032_debugfs_read(struct file *file, char __user *buf, size_t count, d2c6444389b625 Eddie James 2023-06-27 18 loff_t *ppos) d2c6444389b625 Eddie James 2023-06-27 19 { d2c6444389b625 Eddie James 2023-06-27 20 struct i2c_client *client = file->private_data; d2c6444389b625 Eddie James 2023-06-27 21 char data[I2C_SMBUS_BLOCK_MAX + 2] = { 0 }; data should probably be a u8. d2c6444389b625 Eddie James 2023-06-27 22 char out[8]; d2c6444389b625 Eddie James 2023-06-27 23 int rc; d2c6444389b625 Eddie James 2023-06-27 24 int i; d2c6444389b625 Eddie James 2023-06-27 25 d2c6444389b625 Eddie James 2023-06-27 26 rc = pmbus_lock_interruptible(client); d2c6444389b625 Eddie James 2023-06-27 27 if (rc) d2c6444389b625 Eddie James 2023-06-27 28 return rc; d2c6444389b625 Eddie James 2023-06-27 29 d2c6444389b625 Eddie James 2023-06-27 30 rc = i2c_smbus_read_block_data(client, ACBEL_MFR_FW_REVISION, data); d2c6444389b625 Eddie James 2023-06-27 31 pmbus_unlock(client); d2c6444389b625 Eddie James 2023-06-27 32 if (rc < 0) d2c6444389b625 Eddie James 2023-06-27 33 return rc; d2c6444389b625 Eddie James 2023-06-27 34 d2c6444389b625 Eddie James 2023-06-27 35 for (i = 0; i < rc && i < 3; ++i) d2c6444389b625 Eddie James 2023-06-27 @36 snprintf(&out[i * 2], 3, "%02X", data[i]); If data[i] is negative this will print FFFFFFF1 etc. (This is an x86 config... Did we ever merge that patch to make char signed by default?) d2c6444389b625 Eddie James 2023-06-27 37 d2c6444389b625 Eddie James 2023-06-27 38 rc = i * 2; d2c6444389b625 Eddie James 2023-06-27 39 out[rc++] = '\n'; d2c6444389b625 Eddie James 2023-06-27 40 out[rc++] = 0; d2c6444389b625 Eddie James 2023-06-27 41 return simple_read_from_buffer(buf, count, ppos, out, rc); d2c6444389b625 Eddie James 2023-06-27 42 }
On 6/28/23 23:53, Dan Carpenter wrote: > Hi Eddie, > > kernel test robot noticed the following build warnings: > > https://git-scm.com/docs/git-format-patch#_base_tree_information] > > url: https://github.com/intel-lab-lkp/linux/commits/Eddie-James/hwmon-pmbus-acbel-fsg032-Add-firmware-version-debugfs-attribute/20230628-030615 > base: https://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging.git hwmon-next > patch link: https://lore.kernel.org/r/20230627184027.16343-1-eajames%40linux.ibm.com > patch subject: [PATCH] hwmon: (pmbus/acbel-fsg032) Add firmware version debugfs attribute > config: x86_64-randconfig-m001-20230627 (https://download.01.org/0day-ci/archive/20230628/202306281205.NFXmu7xb-lkp@intel.com/config) > compiler: gcc-12 (Debian 12.2.0-14) 12.2.0 > reproduce: (https://download.01.org/0day-ci/archive/20230628/202306281205.NFXmu7xb-lkp@intel.com/reproduce) > > If you fix the issue in a separate patch/commit (i.e. not just a new version of > the same patch/commit), kindly add following tags > | Reported-by: kernel test robot <lkp@intel.com> > | Reported-by: Dan Carpenter <dan.carpenter@linaro.org> > | Closes: https://lore.kernel.org/r/202306281205.NFXmu7xb-lkp@intel.com/ > > smatch warnings: > drivers/hwmon/pmbus/acbel-fsg032.c:36 acbel_fsg032_debugfs_read() warn: argument 4 to %02X specifier has type 'char' > > vim +/char +36 drivers/hwmon/pmbus/acbel-fsg032.c > > d2c6444389b625 Eddie James 2023-06-27 17 static ssize_t acbel_fsg032_debugfs_read(struct file *file, char __user *buf, size_t count, > d2c6444389b625 Eddie James 2023-06-27 18 loff_t *ppos) > d2c6444389b625 Eddie James 2023-06-27 19 { > d2c6444389b625 Eddie James 2023-06-27 20 struct i2c_client *client = file->private_data; > d2c6444389b625 Eddie James 2023-06-27 21 char data[I2C_SMBUS_BLOCK_MAX + 2] = { 0 }; > > data should probably be a u8. > > d2c6444389b625 Eddie James 2023-06-27 22 char out[8]; > d2c6444389b625 Eddie James 2023-06-27 23 int rc; > d2c6444389b625 Eddie James 2023-06-27 24 int i; > d2c6444389b625 Eddie James 2023-06-27 25 > d2c6444389b625 Eddie James 2023-06-27 26 rc = pmbus_lock_interruptible(client); > d2c6444389b625 Eddie James 2023-06-27 27 if (rc) > d2c6444389b625 Eddie James 2023-06-27 28 return rc; > d2c6444389b625 Eddie James 2023-06-27 29 > d2c6444389b625 Eddie James 2023-06-27 30 rc = i2c_smbus_read_block_data(client, ACBEL_MFR_FW_REVISION, data); > d2c6444389b625 Eddie James 2023-06-27 31 pmbus_unlock(client); > d2c6444389b625 Eddie James 2023-06-27 32 if (rc < 0) > d2c6444389b625 Eddie James 2023-06-27 33 return rc; > d2c6444389b625 Eddie James 2023-06-27 34 > d2c6444389b625 Eddie James 2023-06-27 35 for (i = 0; i < rc && i < 3; ++i) > d2c6444389b625 Eddie James 2023-06-27 @36 snprintf(&out[i * 2], 3, "%02X", data[i]); > > If data[i] is negative this will print FFFFFFF1 etc. (This is an x86 > config... Did we ever merge that patch to make char signed by default?) > That makes me wonder what "%*phN\n" in the updated patch does, as it only passes 'data' as pointer argument. Either case, no need to resend. I fixed this up when applying it by declaring data[] as u8. I also dropped the unused variable. Thanks, Guenter
On Thu, Jun 29, 2023 at 09:53:16AM +0300, Dan Carpenter wrote: > d2c6444389b625 Eddie James 2023-06-27 22 char out[8]; > d2c6444389b625 Eddie James 2023-06-27 23 int rc; > d2c6444389b625 Eddie James 2023-06-27 24 int i; > d2c6444389b625 Eddie James 2023-06-27 25 > d2c6444389b625 Eddie James 2023-06-27 26 rc = pmbus_lock_interruptible(client); > d2c6444389b625 Eddie James 2023-06-27 27 if (rc) > d2c6444389b625 Eddie James 2023-06-27 28 return rc; > d2c6444389b625 Eddie James 2023-06-27 29 > d2c6444389b625 Eddie James 2023-06-27 30 rc = i2c_smbus_read_block_data(client, ACBEL_MFR_FW_REVISION, data); > d2c6444389b625 Eddie James 2023-06-27 31 pmbus_unlock(client); > d2c6444389b625 Eddie James 2023-06-27 32 if (rc < 0) > d2c6444389b625 Eddie James 2023-06-27 33 return rc; > d2c6444389b625 Eddie James 2023-06-27 34 > d2c6444389b625 Eddie James 2023-06-27 35 for (i = 0; i < rc && i < 3; ++i) > d2c6444389b625 Eddie James 2023-06-27 @36 snprintf(&out[i * 2], 3, "%02X", data[i]); > > If data[i] is negative this will print FFFFFFF1 etc. (This is an x86 > config... Did we ever merge that patch to make char signed by default?) I meant unsigned not signed. But actually we debated both ways... Signed by default would annoy PowerPC devs since they try to really lean into the fact that char is unsigned on that arch. :P https://lwn.net/Articles/911914/ regards, dan carpenter
On 6/29/23 11:59, Dan Carpenter wrote: > On Thu, Jun 29, 2023 at 09:53:16AM +0300, Dan Carpenter wrote: >> d2c6444389b625 Eddie James 2023-06-27 22 char out[8]; >> d2c6444389b625 Eddie James 2023-06-27 23 int rc; >> d2c6444389b625 Eddie James 2023-06-27 24 int i; >> d2c6444389b625 Eddie James 2023-06-27 25 >> d2c6444389b625 Eddie James 2023-06-27 26 rc = pmbus_lock_interruptible(client); >> d2c6444389b625 Eddie James 2023-06-27 27 if (rc) >> d2c6444389b625 Eddie James 2023-06-27 28 return rc; >> d2c6444389b625 Eddie James 2023-06-27 29 >> d2c6444389b625 Eddie James 2023-06-27 30 rc = i2c_smbus_read_block_data(client, ACBEL_MFR_FW_REVISION, data); >> d2c6444389b625 Eddie James 2023-06-27 31 pmbus_unlock(client); >> d2c6444389b625 Eddie James 2023-06-27 32 if (rc < 0) >> d2c6444389b625 Eddie James 2023-06-27 33 return rc; >> d2c6444389b625 Eddie James 2023-06-27 34 >> d2c6444389b625 Eddie James 2023-06-27 35 for (i = 0; i < rc && i < 3; ++i) >> d2c6444389b625 Eddie James 2023-06-27 @36 snprintf(&out[i * 2], 3, "%02X", data[i]); >> >> If data[i] is negative this will print FFFFFFF1 etc. (This is an x86 >> config... Did we ever merge that patch to make char signed by default?) > > I meant unsigned not signed. But actually we debated both ways... > Signed by default would annoy PowerPC devs since they try to really > lean into the fact that char is unsigned on that arch. :P > > https://lwn.net/Articles/911914/ > As if anything would be easy nowadays ;-). Anyway, in this case, the array should be explicitly unsigned, so changing the type to u8 was the right thing to do. Also, the driver should be usable on non-Intel systems, which is another reason to make the type sign-specific (even more so in the context of the above discussion). Thanks, Guenter
On Thu, Jun 29, 2023 at 12:09:17PM -0700, Guenter Roeck wrote: > On 6/29/23 11:59, Dan Carpenter wrote: > > On Thu, Jun 29, 2023 at 09:53:16AM +0300, Dan Carpenter wrote: > > > d2c6444389b625 Eddie James 2023-06-27 22 char out[8]; > > > d2c6444389b625 Eddie James 2023-06-27 23 int rc; > > > d2c6444389b625 Eddie James 2023-06-27 24 int i; > > > d2c6444389b625 Eddie James 2023-06-27 25 > > > d2c6444389b625 Eddie James 2023-06-27 26 rc = pmbus_lock_interruptible(client); > > > d2c6444389b625 Eddie James 2023-06-27 27 if (rc) > > > d2c6444389b625 Eddie James 2023-06-27 28 return rc; > > > d2c6444389b625 Eddie James 2023-06-27 29 > > > d2c6444389b625 Eddie James 2023-06-27 30 rc = i2c_smbus_read_block_data(client, ACBEL_MFR_FW_REVISION, data); > > > d2c6444389b625 Eddie James 2023-06-27 31 pmbus_unlock(client); > > > d2c6444389b625 Eddie James 2023-06-27 32 if (rc < 0) > > > d2c6444389b625 Eddie James 2023-06-27 33 return rc; > > > d2c6444389b625 Eddie James 2023-06-27 34 > > > d2c6444389b625 Eddie James 2023-06-27 35 for (i = 0; i < rc && i < 3; ++i) > > > d2c6444389b625 Eddie James 2023-06-27 @36 snprintf(&out[i * 2], 3, "%02X", data[i]); > > > > > > If data[i] is negative this will print FFFFFFF1 etc. (This is an x86 > > > config... Did we ever merge that patch to make char signed by default?) > > > > I meant unsigned not signed. But actually we debated both ways... > > Signed by default would annoy PowerPC devs since they try to really > > lean into the fact that char is unsigned on that arch. :P > > > > https://lwn.net/Articles/911914/ > > > > As if anything would be easy nowadays ;-). Anyway, in this case, the array > should be explicitly unsigned, so changing the type to u8 was the right > thing to do. Also, the driver should be usable on non-Intel systems, > which is another reason to make the type sign-specific (even more so in > the context of the above discussion). Actually we did make char unsigned. I don't know if I'm super comfortable with code that assumes char is unsigned. It's makes backporting trickier. But this is definitely a false positive so I have silenced the warning in Smatch. regards, dan carpenter --- a/check_kernel_printf.c +++ b/check_kernel_printf.c @@ -827,7 +827,7 @@ hexbyte(const char *fmt, int fmt_len, struct expression *arg, int vaidx, struct sm_warning("could not determine type of argument %d", vaidx); return; } - if (type == &char_ctype || type == &schar_ctype) + if (type_signed(type) && (type == &char_ctype || type == &schar_ctype)) sm_warning("argument %d to %.*s specifier has type '%s'", vaidx, fmt_len, fmt, type_to_str(type)); }
diff --git a/drivers/hwmon/pmbus/acbel-fsg032.c b/drivers/hwmon/pmbus/acbel-fsg032.c index 0a0ef4ce3493..4b97f108cfe3 100644 --- a/drivers/hwmon/pmbus/acbel-fsg032.c +++ b/drivers/hwmon/pmbus/acbel-fsg032.c @@ -3,6 +3,7 @@ * Copyright 2023 IBM Corp. */ +#include <linux/debugfs.h> #include <linux/device.h> #include <linux/fs.h> #include <linux/i2c.h> @@ -11,6 +12,52 @@ #include <linux/hwmon-sysfs.h> #include "pmbus.h" +#define ACBEL_MFR_FW_REVISION 0xd9 + +static ssize_t acbel_fsg032_debugfs_read(struct file *file, char __user *buf, size_t count, + loff_t *ppos) +{ + struct i2c_client *client = file->private_data; + char data[I2C_SMBUS_BLOCK_MAX + 2] = { 0 }; + char out[8]; + int rc; + int i; + + rc = pmbus_lock_interruptible(client); + if (rc) + return rc; + + rc = i2c_smbus_read_block_data(client, ACBEL_MFR_FW_REVISION, data); + pmbus_unlock(client); + if (rc < 0) + return rc; + + for (i = 0; i < rc && i < 3; ++i) + snprintf(&out[i * 2], 3, "%02X", data[i]); + + rc = i * 2; + out[rc++] = '\n'; + out[rc++] = 0; + return simple_read_from_buffer(buf, count, ppos, out, rc); +} + +static const struct file_operations acbel_debugfs_ops = { + .llseek = noop_llseek, + .read = acbel_fsg032_debugfs_read, + .write = NULL, + .open = simple_open, +}; + +static void acbel_fsg032_init_debugfs(struct i2c_client *client) +{ + struct dentry *debugfs = pmbus_get_debugfs_dir(client); + + if (!debugfs) + return; + + debugfs_create_file("fw_version", 0444, debugfs, client, &acbel_debugfs_ops); +} + static const struct i2c_device_id acbel_fsg032_id[] = { { "acbel_fsg032" }, {} @@ -59,6 +106,7 @@ static int acbel_fsg032_probe(struct i2c_client *client) if (rc) return rc; + acbel_fsg032_init_debugfs(client); return 0; }