hwmon: (pmbus) Expose PEC debugfs attribute
PATCH 1/1 hwmon: (pmbus) Expose PEC debugfs attribute
Enable runtime debug control of whether the PEC byte is exchanged with the PMBus device.
Some manufacturers have asked for the PEC to be disabled as part of debugging driver communication issues with devices.
--- drivers/hwmon/pmbus/pmbus_core.c | 39 ++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+)
drivers/hwmon/pmbus/pmbus_core.c +39 -0
@@ -2346,6 +2346,42 @@ static int pmbus_debugfs_get_status(void *data, u64 *val)DEFINE_DEBUGFS_ATTRIBUTE (pmbus_debugfs_ops_status, pmbus_debugfs_get_status,NULL ,"0x%04llx\n" ); +static int pmbus_debugfs_get_pec (void *data,u64 *val) +{ +struct i2c_client *client = data; + + *val = !!(client->flags &I2C_CLIENT_PEC ); + +return 0 ; +} + +static int pmbus_debugfs_set_pec (void *data,u64 val) +{ +int rc; +struct i2c_client *client = data; + +if (!val) { + client->flags &= ~I2C_CLIENT_PEC ; +return 0 ; + } + +if (val !=1 ) +return -EINVAL ; + + rc =i2c_smbus_read_byte_data (client,PMBUS_CAPABILITY ); +if (rc <0 ) +return rc; + +if (!(rc &PB_CAPABILITY_ERROR_CHECK )) +return -ENOTSUPP ; + + client->flags |=I2C_CLIENT_PEC ; + +return 0 ; +} +DEFINE_DEBUGFS_ATTRIBUTE (pmbus_debugfs_ops_pec, pmbus_debugfs_get_pec, + pmbus_debugfs_set_pec,"0x%1llu\n" ); +static int pmbus_init_debugfs (struct i2c_client *client,struct pmbus_data *data) {
@@ -2374,6 +2410,9 @@ static int pmbus_init_debugfs(struct i2c_client *client,if (!entries)return -ENOMEM ; +debugfs_create_file ("pec" ,0664 , data->debugfs, client, + &pmbus_debugfs_ops_pec); +for (i =0 ; i < data->info->pages; ++i) {/* Check accessibility of status register if it's not page 0 */ if (!i ||pmbus_check_status_register (client, i)) {
Signature · 1 line
2.25.1
Guenter Roeck
maintainerQuoted 37 lines · Andrew Jeffery
Enable runtime debug control of whether the PEC byte is exchanged with the PMBus device.
Some manufacturers have asked for the PEC to be disabled as part of debugging driver communication issues with devices.
Signed-off-by Andrew Jeffery <[email protected]>--- drivers/hwmon/pmbus/pmbus_core.c | 39 ++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+)drivers/hwmon/pmbus/pmbus_core.c +18
-0@@ -2346,6 +2346,42 @@ static int pmbus_debugfs_get_status(void *data, u64 *val)DEFINE_DEBUGFS_ATTRIBUTE (pmbus_debugfs_ops_status, pmbus_debugfs_get_status,NULL ,"0x%04llx\n" ); +static int pmbus_debugfs_get_pec (void *data,u64 *val) +{ +struct i2c_client *client = data; + + *val = !!(client->flags &I2C_CLIENT_PEC ); + +return 0 ; +} + +static int pmbus_debugfs_set_pec (void *data,u64 val) +{ +int rc; +struct i2c_client *client = data; + +if (!val) { + client->flags &= ~I2C_CLIENT_PEC ; +return 0 ; + }
drivers/hwmon/pmbus/pmbus_core.c static int pmbus_debugfs_get_status(void *data, u64 *val) · line 2376
Quoted 10 lines
drivers/hwmon/pmbus/pmbus_core.c +10
-0+ +if (val !=1 ) +return -EINVAL ; + + rc =i2c_smbus_read_byte_data (client,PMBUS_CAPABILITY ); +if (rc <0 ) +return rc; + +if (!(rc &PB_CAPABILITY_ERROR_CHECK )) +return -ENOTSUPP ;
WARNING: ENOTSUPP is not a SUSV4 error code, prefer EOPNOTSUPP
drivers/hwmon/pmbus/pmbus_core.c static int pmbus_debugfs_get_status(void *data, u64 *val) · line 2383
Quoted 7 lines
drivers/hwmon/pmbus/pmbus_core.c +7
-0+ + client->flags |=I2C_CLIENT_PEC ; + +return 0 ; +} +DEFINE_DEBUGFS_ATTRIBUTE (pmbus_debugfs_ops_pec, pmbus_debugfs_get_pec, + pmbus_debugfs_set_pec,"0x%1llu\n" );
ERROR: Prefixing 0x with decimal output is defective
(since the displayed value is a boolean, it is also quite useless).
Quoted 15 lines
drivers/hwmon/pmbus/pmbus_core.c +4
-0+static int pmbus_init_debugfs (struct i2c_client *client,struct pmbus_data *data) {@@ -2374,6 +2410,9 @@ static int pmbus_init_debugfs(struct i2c_client *client,if (!entries)return -ENOMEM ; +debugfs_create_file ("pec" ,0664 , data->debugfs, client, + &pmbus_debugfs_ops_pec); +for (i =0 ; i < data->info->pages; ++i) {/* Check accessibility of status register if it's not page 0 */ if (!i ||pmbus_check_status_register (client, i)) {
Quoted 61 lines · Guenter Roeck
Quoted 37 lines · Andrew Jeffery
Enable runtime debug control of whether the PEC byte is exchanged with the PMBus device.
Some manufacturers have asked for the PEC to be disabled as part of debugging driver communication issues with devices.
Signed-off-by Andrew Jeffery <[email protected]>--- drivers/hwmon/pmbus/pmbus_core.c | 39 ++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+)drivers/hwmon/pmbus/pmbus_core.c +18
-0@@ -2346,6 +2346,42 @@ static int pmbus_debugfs_get_status(void *data, u64 *val)DEFINE_DEBUGFS_ATTRIBUTE (pmbus_debugfs_ops_status, pmbus_debugfs_get_status,NULL ,"0x%04llx\n" ); +static int pmbus_debugfs_get_pec (void *data,u64 *val) +{ +struct i2c_client *client = data; + + *val = !!(client->flags &I2C_CLIENT_PEC ); + +return 0 ; +} + +static int pmbus_debugfs_set_pec (void *data,u64 val) +{ +int rc; +struct i2c_client *client = data; + +if (!val) { + client->flags &= ~I2C_CLIENT_PEC ; +return 0 ; + }drivers/hwmon/pmbus/pmbus_core.c static int pmbus_debugfs_get_status(void *data, u64 *val) · line 2376
Quoted 10 lines
drivers/hwmon/pmbus/pmbus_core.c +10
-0+ +if (val !=1 ) +return -EINVAL ; + + rc =i2c_smbus_read_byte_data (client,PMBUS_CAPABILITY ); +if (rc <0 ) +return rc; + +if (!(rc &PB_CAPABILITY_ERROR_CHECK )) +return -ENOTSUPP ;WARNING: ENOTSUPP is not a SUSV4 error code, prefer EOPNOTSUPP
drivers/hwmon/pmbus/pmbus_core.c static int pmbus_debugfs_get_status(void *data, u64 *val) · line 2383
Quoted 7 lines
drivers/hwmon/pmbus/pmbus_core.c +7
-0+ + client->flags |=I2C_CLIENT_PEC ; + +return 0 ; +} +DEFINE_DEBUGFS_ATTRIBUTE (pmbus_debugfs_ops_pec, pmbus_debugfs_get_pec, + pmbus_debugfs_set_pec,"0x%1llu\n" );ERROR: Prefixing 0x with decimal output is defective
Quoted 1 line
(since the displayed value is a boolean, it is also quite useless).
Indeed. I overlooked running checkpatch, sorry for the noise.
I've sent v2 which checkpatch claims to be clean.
Andrew
Hi Andrew,
url: https://github.com/0day-ci/linux/commits/Andrew-Jeffery/hwmon-pmbus-Expose-PEC-debugfs-attribute/20200910-010642 base: https://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging.git hwmon-next config: x86_64-randconfig-m001-20200909 (attached as .config) compiler: gcc-9 (Debian 9.3.0-15) 9.3.0
If you fix the issue, kindly add following tag as appropriate
smatch warnings:drivers/hwmon/pmbus/pmbus_core.c:2415 pmbus_debugfs_ops_pec_open() warn: '0x' prefix is confusing together with '%1llu' specifier
# https://github.com/0day-ci/linux/commit/705b8b5588d4102256d0954086ed16c9bdf9804f
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Andrew-Jeffery/hwmon-pmbus-Expose-PEC-debugfs-attribute/20200910-010642 git checkout 705b8b5588d4102256d0954086ed16c9bdf9804f
vim +2415 drivers/hwmon/pmbus/pmbus_core.c
705b8b5588d410 Andrew Jeffery 2020-09-09 2391 static int pmbus_debugfs_set_pec(void *data, u64 val)
705b8b5588d410 Andrew Jeffery 2020-09-09 2392 {
705b8b5588d410 Andrew Jeffery 2020-09-09 2393 int rc;
705b8b5588d410 Andrew Jeffery 2020-09-09 2394 struct i2c_client *client = data;
705b8b5588d410 Andrew Jeffery 2020-09-09 2395
705b8b5588d410 Andrew Jeffery 2020-09-09 2396 if (!val) {
705b8b5588d410 Andrew Jeffery 2020-09-09 2397 client->flags &= ~I2C_CLIENT_PEC;
705b8b5588d410 Andrew Jeffery 2020-09-09 2398 return 0;
705b8b5588d410 Andrew Jeffery 2020-09-09 2399 }
705b8b5588d410 Andrew Jeffery 2020-09-09 2400
705b8b5588d410 Andrew Jeffery 2020-09-09 2401 if (val != 1)
705b8b5588d410 Andrew Jeffery 2020-09-09 2402 return -EINVAL;
705b8b5588d410 Andrew Jeffery 2020-09-09 2403
705b8b5588d410 Andrew Jeffery 2020-09-09 2404 rc = i2c_smbus_read_byte_data(client, PMBUS_CAPABILITY);
705b8b5588d410 Andrew Jeffery 2020-09-09 2405 if (rc < 0)
705b8b5588d410 Andrew Jeffery 2020-09-09 2406 return rc;
705b8b5588d410 Andrew Jeffery 2020-09-09 2407
705b8b5588d410 Andrew Jeffery 2020-09-09 2408 if (!(rc & PB_CAPABILITY_ERROR_CHECK))
705b8b5588d410 Andrew Jeffery 2020-09-09 2409 return -ENOTSUPP;
705b8b5588d410 Andrew Jeffery 2020-09-09 2410
705b8b5588d410 Andrew Jeffery 2020-09-09 2411 client->flags |= I2C_CLIENT_PEC;
705b8b5588d410 Andrew Jeffery 2020-09-09 2412
705b8b5588d410 Andrew Jeffery 2020-09-09 2413 return 0;
705b8b5588d410 Andrew Jeffery 2020-09-09 2414 }
705b8b5588d410 Andrew Jeffery 2020-09-09 @2415 DEFINE_DEBUGFS_ATTRIBUTE(pmbus_debugfs_ops_pec, pmbus_debugfs_get_pec,
705b8b5588d410 Andrew Jeffery 2020-09-09 2416 pmbus_debugfs_set_pec, "0x%1llu\n");
^^^^^^^Was the 1 intentional? Anyway, you probably want to remove the 0x so it doesn't look like hex.
705b8b5588d410 Andrew Jeffery 2020-09-09 2417
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
Guenter Roeck
maintainerQuoted 47 lines · Dan Carpenter
Hi Andrew,
url: https://github.com/0day-ci/linux/commits/Andrew-Jeffery/hwmon-pmbus-Expose-PEC-debugfs-attribute/20200910-010642 base: https://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging.git hwmon-next config: x86_64-randconfig-m001-20200909 (attached as .config) compiler: gcc-9 (Debian 9.3.0-15) 9.3.0If you fix the issue, kindly add following tag as appropriate
Reported-by kernel test robot <[email protected]>Reported-by Dan Carpenter <[email protected]>smatch warnings:
drivers/hwmon/pmbus/pmbus_core.c:2415pmbus_debugfs_ops_pec_open()warn: '0x' prefix is confusing together with '%1llu' specifier# https://github.com/0day-ci/linux/commit/705b8b5588d4102256d0954086ed16c9bdf9804f
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Andrew-Jeffery/hwmon-pmbus-Expose-PEC-debugfs-attribute/20200910-010642 git checkout705b8b5588d4102256d0954086ed16c9bdf9804f
vim +2415drivers/hwmon/pmbus/pmbus_core.c705b8b5588d410 Andrew Jeffery 2020-09-09 2391 static int pmbus_debugfs_set_pec(void *data, u64 val) 705b8b5588d410 Andrew Jeffery 2020-09-09 2392 { 705b8b5588d410 Andrew Jeffery 2020-09-09 2393 int rc; 705b8b5588d410 Andrew Jeffery 2020-09-09 2394 struct i2c_client *client = data; 705b8b5588d410 Andrew Jeffery 2020-09-09 2395 705b8b5588d410 Andrew Jeffery 2020-09-09 2396 if (!val) { 705b8b5588d410 Andrew Jeffery 2020-09-09 2397 client->flags &= ~I2C_CLIENT_PEC; 705b8b5588d410 Andrew Jeffery 2020-09-09 2398 return 0; 705b8b5588d410 Andrew Jeffery 2020-09-09 2399 } 705b8b5588d410 Andrew Jeffery 2020-09-09 2400 705b8b5588d410 Andrew Jeffery 2020-09-09 2401 if (val != 1) 705b8b5588d410 Andrew Jeffery 2020-09-09 2402 return -EINVAL; 705b8b5588d410 Andrew Jeffery 2020-09-09 2403 705b8b5588d410 Andrew Jeffery 2020-09-09 2404 rc = i2c_smbus_read_byte_data(client, PMBUS_CAPABILITY); 705b8b5588d410 Andrew Jeffery 2020-09-09 2405 if (rc < 0) 705b8b5588d410 Andrew Jeffery 2020-09-09 2406 return rc; 705b8b5588d410 Andrew Jeffery 2020-09-09 2407 705b8b5588d410 Andrew Jeffery 2020-09-09 2408 if (!(rc & PB_CAPABILITY_ERROR_CHECK)) 705b8b5588d410 Andrew Jeffery 2020-09-09 2409 return -ENOTSUPP; 705b8b5588d410 Andrew Jeffery 2020-09-09 2410 705b8b5588d410 Andrew Jeffery 2020-09-09 2411 client->flags |= I2C_CLIENT_PEC; 705b8b5588d410 Andrew Jeffery 2020-09-09 2412 705b8b5588d410 Andrew Jeffery 2020-09-09 2413 return 0; 705b8b5588d410 Andrew Jeffery 2020-09-09 2414 } 705b8b5588d410 Andrew Jeffery 2020-09-09 @2415 DEFINE_DEBUGFS_ATTRIBUTE(pmbus_debugfs_ops_pec, pmbus_debugfs_get_pec, 705b8b5588d410 Andrew Jeffery 2020-09-09 2416 pmbus_debugfs_set_pec, "0x%1llu\n"); ^^^^^^^
Quoted 3 lines
Was the 1 intentional? Anyway, you probably want to remove the 0x so it doesn't look like hex.
Nice catch; I didn't notice the 1. It is still there in v2, but it does seem quite useless.
Guenter
Quoted 6 lines
705b8b5588d410Andrew Jeffery 2020-09-09 2417---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
Quoted 52 lines · Guenter Roeck
Quoted 47 lines · Dan Carpenter
Hi Andrew,
url: https://github.com/0day-ci/linux/commits/Andrew-Jeffery/hwmon-pmbus-Expose-PEC-debugfs-attribute/20200910-010642 base: https://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging.git hwmon-next config: x86_64-randconfig-m001-20200909 (attached as .config) compiler: gcc-9 (Debian 9.3.0-15) 9.3.0If you fix the issue, kindly add following tag as appropriate
Reported-by kernel test robot <[email protected]>Reported-by Dan Carpenter <[email protected]>smatch warnings:
drivers/hwmon/pmbus/pmbus_core.c:2415pmbus_debugfs_ops_pec_open()warn: '0x' prefix is confusing together with '%1llu' specifier# https://github.com/0day-ci/linux/commit/705b8b5588d4102256d0954086ed16c9bdf9804f
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Andrew-Jeffery/hwmon-pmbus-Expose-PEC-debugfs-attribute/20200910-010642 git checkout705b8b5588d4102256d0954086ed16c9bdf9804f
vim +2415drivers/hwmon/pmbus/pmbus_core.c705b8b5588d410 Andrew Jeffery 2020-09-09 2391 static int pmbus_debugfs_set_pec(void *data, u64 val) 705b8b5588d410 Andrew Jeffery 2020-09-09 2392 { 705b8b5588d410 Andrew Jeffery 2020-09-09 2393 int rc; 705b8b5588d410 Andrew Jeffery 2020-09-09 2394 struct i2c_client *client = data; 705b8b5588d410 Andrew Jeffery 2020-09-09 2395 705b8b5588d410 Andrew Jeffery 2020-09-09 2396 if (!val) { 705b8b5588d410 Andrew Jeffery 2020-09-09 2397 client->flags &= ~I2C_CLIENT_PEC; 705b8b5588d410 Andrew Jeffery 2020-09-09 2398 return 0; 705b8b5588d410 Andrew Jeffery 2020-09-09 2399 } 705b8b5588d410 Andrew Jeffery 2020-09-09 2400 705b8b5588d410 Andrew Jeffery 2020-09-09 2401 if (val != 1) 705b8b5588d410 Andrew Jeffery 2020-09-09 2402 return -EINVAL; 705b8b5588d410 Andrew Jeffery 2020-09-09 2403 705b8b5588d410 Andrew Jeffery 2020-09-09 2404 rc = i2c_smbus_read_byte_data(client, PMBUS_CAPABILITY); 705b8b5588d410 Andrew Jeffery 2020-09-09 2405 if (rc < 0) 705b8b5588d410 Andrew Jeffery 2020-09-09 2406 return rc; 705b8b5588d410 Andrew Jeffery 2020-09-09 2407 705b8b5588d410 Andrew Jeffery 2020-09-09 2408 if (!(rc & PB_CAPABILITY_ERROR_CHECK)) 705b8b5588d410 Andrew Jeffery 2020-09-09 2409 return -ENOTSUPP; 705b8b5588d410 Andrew Jeffery 2020-09-09 2410 705b8b5588d410 Andrew Jeffery 2020-09-09 2411 client->flags |= I2C_CLIENT_PEC; 705b8b5588d410 Andrew Jeffery 2020-09-09 2412 705b8b5588d410 Andrew Jeffery 2020-09-09 2413 return 0; 705b8b5588d410 Andrew Jeffery 2020-09-09 2414 } 705b8b5588d410 Andrew Jeffery 2020-09-09 @2415 DEFINE_DEBUGFS_ATTRIBUTE(pmbus_debugfs_ops_pec, pmbus_debugfs_get_pec, 705b8b5588d410 Andrew Jeffery 2020-09-09 2416 pmbus_debugfs_set_pec, "0x%1llu\n"); ^^^^^^^Quoted 3 lines
Was the 1 intentional? Anyway, you probably want to remove the 0x so it doesn't look like hex.
Quoted 2 lines
Nice catch; I didn't notice the 1. It is still there in v2, but it does seem quite useless.
Do you want to just rebase it out, or would you like me to send a patch removing the stray 1 from v2?
Andrew
Guenter Roeck
maintainerQuoted 55 lines · Andrew Jeffery
Quoted 52 lines · Guenter Roeck
Quoted 50 lines · Dan Carpenter
Hi Andrew,
url: https://github.com/0day-ci/linux/commits/Andrew-Jeffery/hwmon-pmbus-Expose-PEC-debugfs-attribute/20200910-010642 base: https://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging.git hwmon-next config: x86_64-randconfig-m001-20200909 (attached as .config) compiler: gcc-9 (Debian 9.3.0-15) 9.3.0If you fix the issue, kindly add following tag as appropriate
Reported-by kernel test robot <[email protected]>Reported-by Dan Carpenter <[email protected]>smatch warnings:
drivers/hwmon/pmbus/pmbus_core.c:2415pmbus_debugfs_ops_pec_open()warn: '0x' prefix is confusing together with '%1llu' specifier# https://github.com/0day-ci/linux/commit/705b8b5588d4102256d0954086ed16c9bdf9804f
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Andrew-Jeffery/hwmon-pmbus-Expose-PEC-debugfs-attribute/20200910-010642 git checkout705b8b5588d4102256d0954086ed16c9bdf9804f
vim +2415drivers/hwmon/pmbus/pmbus_core.c705b8b5588d410 Andrew Jeffery 2020-09-09 2391 static int pmbus_debugfs_set_pec(void *data, u64 val) 705b8b5588d410 Andrew Jeffery 2020-09-09 2392 { 705b8b5588d410 Andrew Jeffery 2020-09-09 2393 int rc; 705b8b5588d410 Andrew Jeffery 2020-09-09 2394 struct i2c_client *client = data; 705b8b5588d410 Andrew Jeffery 2020-09-09 2395 705b8b5588d410 Andrew Jeffery 2020-09-09 2396 if (!val) { 705b8b5588d410 Andrew Jeffery 2020-09-09 2397 client->flags &= ~I2C_CLIENT_PEC; 705b8b5588d410 Andrew Jeffery 2020-09-09 2398 return 0; 705b8b5588d410 Andrew Jeffery 2020-09-09 2399 } 705b8b5588d410 Andrew Jeffery 2020-09-09 2400 705b8b5588d410 Andrew Jeffery 2020-09-09 2401 if (val != 1) 705b8b5588d410 Andrew Jeffery 2020-09-09 2402 return -EINVAL; 705b8b5588d410 Andrew Jeffery 2020-09-09 2403 705b8b5588d410 Andrew Jeffery 2020-09-09 2404 rc = i2c_smbus_read_byte_data(client, PMBUS_CAPABILITY); 705b8b5588d410 Andrew Jeffery 2020-09-09 2405 if (rc < 0) 705b8b5588d410 Andrew Jeffery 2020-09-09 2406 return rc; 705b8b5588d410 Andrew Jeffery 2020-09-09 2407 705b8b5588d410 Andrew Jeffery 2020-09-09 2408 if (!(rc & PB_CAPABILITY_ERROR_CHECK)) 705b8b5588d410 Andrew Jeffery 2020-09-09 2409 return -ENOTSUPP; 705b8b5588d410 Andrew Jeffery 2020-09-09 2410 705b8b5588d410 Andrew Jeffery 2020-09-09 2411 client->flags |= I2C_CLIENT_PEC; 705b8b5588d410 Andrew Jeffery 2020-09-09 2412 705b8b5588d410 Andrew Jeffery 2020-09-09 2413 return 0; 705b8b5588d410 Andrew Jeffery 2020-09-09 2414 } 705b8b5588d410 Andrew Jeffery 2020-09-09 @2415 DEFINE_DEBUGFS_ATTRIBUTE(pmbus_debugfs_ops_pec, pmbus_debugfs_get_pec, 705b8b5588d410 Andrew Jeffery 2020-09-09 2416 pmbus_debugfs_set_pec, "0x%1llu\n"); ^^^^^^^Was the 1 intentional? Anyway, you probably want to remove the 0x so it doesn't look like hex.
Quoted 6 lines
Quoted 2 lines
Nice catch; I didn't notice the 1. It is still there in v2, but it does seem quite useless.
Do you want to just rebase it out, or would you like me to send a patch removing the stray 1 from v2?
I'll rebase it.
Thanks,
Guenter