Message ID | 20230628153453.122213-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 k13csp9026072vqr; Wed, 28 Jun 2023 08:50:52 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5YGqHlU0P0hEEPfs3Vl3j/ZsW2yXLcy2wz5k3ozqXoHaWhvXYEFb+YApLOP4IGipURaW87 X-Received: by 2002:a17:907:7ba0:b0:992:74e0:6f76 with SMTP id ne32-20020a1709077ba000b0099274e06f76mr2110582ejc.4.1687967451889; Wed, 28 Jun 2023 08:50:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687967451; cv=none; d=google.com; s=arc-20160816; b=V7njJR2dWFFMUIrgJmFRLCk0nQQUKPPMIxAvL71wU8f5DiYNoLTiyFtZVtVOGcqBSC Uy9G5rA0EEwI7nxeKbcLk6+Yg/bs1A4GhcwVUfwqfATRLO136v1UgQ7nxbHwoLiHzUZW 8nNZi2VqSpxLbBYxlTGklrY/cBhPmjMeLRL66JxHlN+sqgUJuo6I9pHAQBBYFsOawvSt 8+7n+Uu/9vqP3tuy7IzoVxAK6bztG+IQ4feKMcgt6dvuGY++jUh6oHte+Bcjq4K89Vpu XEObiSfDfSPuAENHZix67v3vP3aRy1/NdYmIwb8aRuVYgnAv1i18eVjQLXo5uMh+Wzjc rGjw== 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=yjSSLk7IIZbwKBc+RFq027CdKB7HA5IOuDChCv+hIhs=; fh=4+peFJK9TXCte9iQ3M/4CYngH0AZNqSI8cjipV0/9Vw=; b=ynXZjv4Qns+I5iKvMVgCJpy0c1d9KipkPSfpXm0oVW2DXXmLB/UcaOQ0AwCm7Nnlt+ Ac+MZgolRrMxe9gpc0RpR0rTqngwcApFjCt/wYiHqASQBoABwSx6879QTTHg6akeiv2p oeVVjsRwpx9+ybuL9tKM2WfWb2txwXsQuW2j2G+nTkK5F6GWrs6CapL9RrJdIicl6t9I +UCESkAeZQc2r1HmktKVVhV0HwrOGGhqO6tsi/Z1jtHJrFDmAgE021f9z0Kedrma0QCq 6C7aGnGfjxJX+llsUG9en1cb6l6qKsRf5yvDu2bd+vqRN6RKMtyQslCfkUuXjgjbSulF kWlg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=ljPs2feU; 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 a2-20020a1709064a4200b009929ca27a5asi302973ejv.86.2023.06.28.08.50.27; Wed, 28 Jun 2023 08:50:51 -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=ljPs2feU; 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 S232481AbjF1Pg3 (ORCPT <rfc822;adanhawthorn@gmail.com> + 99 others); Wed, 28 Jun 2023 11:36:29 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:21242 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232536AbjF1PfX (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 28 Jun 2023 11:35:23 -0400 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 35SFYlxS011856; Wed, 28 Jun 2023 15:35:09 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=yjSSLk7IIZbwKBc+RFq027CdKB7HA5IOuDChCv+hIhs=; b=ljPs2feU/vhJXsPNgbGmNkrTbcMofD14IP5jzUjlI+AtUgj9zMbRiC9o861S13hAPdX/ BONL6mKUSXbCe584x1JKlGAxdaw0nyIZ4De6IPePQqAwvs9Zb31dGOYIv4tsfcsM5q0H jaKaI/y1n9x1s6r87Jp1qU9mJKJ4LfDcaz8pkyJVFXtWiiwdf0FrZJv7JcB9k/Uxf61O tyC1niAs8E+cKBZ23Z7T9D1BCFTuO0HpLLnb9rO0MpZ1VWOpXiuRo3W0wUEbI6he8eK5 skVMK5KFfEfbe6Np98dx34RaVvGLnenkLhCc3PraTt61AZ8CWvJbEP5LxC6focRE8K5f NA== Received: from ppma02wdc.us.ibm.com (aa.5b.37a9.ip4.static.sl-reverse.com [169.55.91.170]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3rgqhhg5e0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 28 Jun 2023 15:35:03 +0000 Received: from pps.filterd (ppma02wdc.us.ibm.com [127.0.0.1]) by ppma02wdc.us.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 35SEHLcH023981; Wed, 28 Jun 2023 15:34:57 GMT Received: from smtprelay02.wdc07v.mail.ibm.com ([9.208.129.120]) by ppma02wdc.us.ibm.com (PPS) with ESMTPS id 3rdr466ke4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 28 Jun 2023 15:34:56 +0000 Received: from smtpav03.wdc07v.mail.ibm.com (smtpav03.wdc07v.mail.ibm.com [10.39.53.230]) by smtprelay02.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 35SFYtG31442434 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 28 Jun 2023 15:34:55 GMT Received: from smtpav03.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3DE275805C; Wed, 28 Jun 2023 15:34:55 +0000 (GMT) Received: from smtpav03.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C137A5805D; Wed, 28 Jun 2023 15:34:54 +0000 (GMT) Received: from slate16.aus.stglabs.ibm.com (unknown [9.61.85.197]) by smtpav03.wdc07v.mail.ibm.com (Postfix) with ESMTP; Wed, 28 Jun 2023 15:34:54 +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 v2] hwmon: (pmbus/acbel-fsg032) Add firmware version debugfs attribute Date: Wed, 28 Jun 2023 10:34:53 -0500 Message-Id: <20230628153453.122213-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-GUID: Xs-fYOUbxI1zmkiDR1VJpmPzRWpxJViA X-Proofpoint-ORIG-GUID: Xs-fYOUbxI1zmkiDR1VJpmPzRWpxJViA 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-28_10,2023-06-27_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 lowpriorityscore=0 bulkscore=0 priorityscore=1501 impostorscore=0 malwarescore=0 clxscore=1015 mlxlogscore=999 adultscore=0 mlxscore=0 spamscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2305260000 definitions=main-2306280139 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?1769962158889024266?= |
Series |
[v2] hwmon: (pmbus/acbel-fsg032) Add firmware version debugfs attribute
|
|
Commit Message
Eddie James
June 28, 2023, 3:34 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>
---
Changes since v1:
- Remove locking since there's only one page
- Switch to %*ph in snprintf instead of loop of %02x
drivers/hwmon/pmbus/acbel-fsg032.c | 39 ++++++++++++++++++++++++++++++
1 file changed, 39 insertions(+)
Comments
On 6/28/23 08:34, 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> For my reference: Reviewed-by: Guenter Roeck <linux@roeck-us.net> I'll apply after the commit window closes. Thanks, Guenter > --- > Changes since v1: > - Remove locking since there's only one page > - Switch to %*ph in snprintf instead of loop of %02x > > drivers/hwmon/pmbus/acbel-fsg032.c | 39 ++++++++++++++++++++++++++++++ > 1 file changed, 39 insertions(+) > > diff --git a/drivers/hwmon/pmbus/acbel-fsg032.c b/drivers/hwmon/pmbus/acbel-fsg032.c > index 0a0ef4ce3493..6413f5ae605f 100644 > --- a/drivers/hwmon/pmbus/acbel-fsg032.c > +++ b/drivers/hwmon/pmbus/acbel-fsg032.c > @@ -3,14 +3,52 @@ > * Copyright 2023 IBM Corp. > */ > > +#include <linux/debugfs.h> > #include <linux/device.h> > #include <linux/fs.h> > #include <linux/i2c.h> > +#include <linux/minmax.h> > #include <linux/module.h> > #include <linux/pmbus.h> > #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 = i2c_smbus_read_block_data(client, ACBEL_MFR_FW_REVISION, data); > + if (rc < 0) > + return rc; > + > + rc = snprintf(out, sizeof(out), "%*phN\n", min(rc, 3), data); > + 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 +97,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: [auto build test WARNING on groeck-staging/hwmon-next] [also build test WARNING on linus/master v6.4 next-20230628] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in 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-233840 base: https://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging.git hwmon-next patch link: https://lore.kernel.org/r/20230628153453.122213-1-eajames%40linux.ibm.com patch subject: [PATCH v2] hwmon: (pmbus/acbel-fsg032) Add firmware version debugfs attribute config: i386-randconfig-i012-20230628 (https://download.01.org/0day-ci/archive/20230629/202306290818.2IuC4QCQ-lkp@intel.com/config) compiler: gcc-12 (Debian 12.2.0-14) 12.2.0 reproduce: (https://download.01.org/0day-ci/archive/20230629/202306290818.2IuC4QCQ-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> | Closes: https://lore.kernel.org/oe-kbuild-all/202306290818.2IuC4QCQ-lkp@intel.com/ All warnings (new ones prefixed by >>): drivers/hwmon/pmbus/acbel-fsg032.c: In function 'acbel_fsg032_debugfs_read': >> drivers/hwmon/pmbus/acbel-fsg032.c:25:13: warning: unused variable 'i' [-Wunused-variable] 25 | int i; | ^ vim +/i +25 drivers/hwmon/pmbus/acbel-fsg032.c 17 18 static ssize_t acbel_fsg032_debugfs_read(struct file *file, char __user *buf, size_t count, 19 loff_t *ppos) 20 { 21 struct i2c_client *client = file->private_data; 22 char data[I2C_SMBUS_BLOCK_MAX + 2] = { 0 }; 23 char out[8]; 24 int rc; > 25 int i; 26 27 rc = i2c_smbus_read_block_data(client, ACBEL_MFR_FW_REVISION, data); 28 if (rc < 0) 29 return rc; 30 31 rc = snprintf(out, sizeof(out), "%*phN\n", min(rc, 3), data); 32 return simple_read_from_buffer(buf, count, ppos, out, rc); 33 } 34
Hi Eddie, kernel test robot noticed the following build warnings: [auto build test WARNING on groeck-staging/hwmon-next] [also build test WARNING on linus/master v6.4 next-20230628] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in 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-233840 base: https://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging.git hwmon-next patch link: https://lore.kernel.org/r/20230628153453.122213-1-eajames%40linux.ibm.com patch subject: [PATCH v2] hwmon: (pmbus/acbel-fsg032) Add firmware version debugfs attribute config: x86_64-randconfig-x016-20230628 (https://download.01.org/0day-ci/archive/20230629/202306291012.dDHxs13l-lkp@intel.com/config) compiler: clang version 15.0.7 (https://github.com/llvm/llvm-project.git 8dfdcc7b7bf66834a761bd8de445840ef68e4d1a) reproduce: (https://download.01.org/0day-ci/archive/20230629/202306291012.dDHxs13l-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> | Closes: https://lore.kernel.org/oe-kbuild-all/202306291012.dDHxs13l-lkp@intel.com/ All warnings (new ones prefixed by >>): >> drivers/hwmon/pmbus/acbel-fsg032.c:25:6: warning: unused variable 'i' [-Wunused-variable] int i; ^ 1 warning generated. vim +/i +25 drivers/hwmon/pmbus/acbel-fsg032.c 17 18 static ssize_t acbel_fsg032_debugfs_read(struct file *file, char __user *buf, size_t count, 19 loff_t *ppos) 20 { 21 struct i2c_client *client = file->private_data; 22 char data[I2C_SMBUS_BLOCK_MAX + 2] = { 0 }; 23 char out[8]; 24 int rc; > 25 int i; 26 27 rc = i2c_smbus_read_block_data(client, ACBEL_MFR_FW_REVISION, data); 28 if (rc < 0) 29 return rc; 30 31 rc = snprintf(out, sizeof(out), "%*phN\n", min(rc, 3), data); 32 return simple_read_from_buffer(buf, count, ppos, out, rc); 33 } 34
diff --git a/drivers/hwmon/pmbus/acbel-fsg032.c b/drivers/hwmon/pmbus/acbel-fsg032.c index 0a0ef4ce3493..6413f5ae605f 100644 --- a/drivers/hwmon/pmbus/acbel-fsg032.c +++ b/drivers/hwmon/pmbus/acbel-fsg032.c @@ -3,14 +3,52 @@ * Copyright 2023 IBM Corp. */ +#include <linux/debugfs.h> #include <linux/device.h> #include <linux/fs.h> #include <linux/i2c.h> +#include <linux/minmax.h> #include <linux/module.h> #include <linux/pmbus.h> #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 = i2c_smbus_read_block_data(client, ACBEL_MFR_FW_REVISION, data); + if (rc < 0) + return rc; + + rc = snprintf(out, sizeof(out), "%*phN\n", min(rc, 3), data); + 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 +97,7 @@ static int acbel_fsg032_probe(struct i2c_client *client) if (rc) return rc; + acbel_fsg032_init_debugfs(client); return 0; }