lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <b3a5036e-83b2-a8be-cc9e-fafb161047ec@linux.ibm.com>
Date:   Wed, 28 Jun 2023 09:50:54 -0500
From:   Eddie James <eajames@...ux.ibm.com>
To:     Guenter Roeck <linux@...ck-us.net>, linux-hwmon@...r.kernel.org
Cc:     linux-kernel@...r.kernel.org, jdelvare@...e.com,
        lakshmiy@...ibm.com
Subject: Re: [PATCH] hwmon: (pmbus/acbel-fsg032) Add firmware version debugfs
 attribute


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@...ux.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;
>>   }
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ