[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Z-u0ylwQsRp0ZsoUL7G1kVcTsQy3yh6ozr4hWbv5ZsV16SIq_rQ6LlVHGWTpJwGubIyzYsmEyPoDkgVrvNgT8bQFTxldAk5oadd-2tuumsY=@wujek.eu>
Date: Wed, 20 Apr 2022 21:37:16 +0000
From: wujek dev <dev_public@...ek.eu>
To: Guenter Roeck <linux@...ck-us.net>
Cc: Jean Delvare <jdelvare@...e.com>, linux-hwmon@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH 2/2] hwmon: (pmbus) add MFR_* registers to debugfs
------- Original Message -------
On Wednesday, April 20th, 2022 at 18:06, Guenter Roeck <linux@...ck-us.net> wrote:
>
>
> On 4/20/22 08:51, wujek dev wrote:
>
> > ------- Original Message -------
> > On Wednesday, April 20th, 2022 at 16:15, Guenter Roeck linux@...ck-us.net wrote:
> >
> > > On 4/20/22 06:58, wujek dev wrote:
> > >
> > > > ------- Original Message -------
> > > > On Wednesday, April 20th, 2022 at 15:53, Guenter Roeck linux@...ck-us.net wrote:
> > > >
> > > > > On 4/20/22 05:22, Adam Wujek wrote:
> > > > >
> > > > > > Add registers to debugfs:
> > > > > > PMBUS_MFR_ID
> > > > > > PMBUS_MFR_MODEL
> > > > > > PMBUS_MFR_REVISION
> > > > > > PMBUS_MFR_LOCATION
> > > > > > PMBUS_MFR_DATE
> > > > > > PMBUS_MFR_SERIAL
> > > > > >
> > > > > > Signed-off-by: Adam Wujek dev_public@...ek.eu
> > > > >
> > > > > Where is patch 1/2, and why did you resend this patch ?
> > > >
> > > > There should be no "1/2" since this and the second patch are unrelated.
> > > > I resend it because I rebased it on master.
> > >
> > > Please provide change logs and version your patches in the future.
> > > ok, thank you for your patience.
> > >
> > > > Adam
> > > >
> > > > > Guenter
> > > > >
> > > > > > ---
> > > > > > drivers/hwmon/pmbus/pmbus_core.c | 84 ++++++++++++++++++++++++++++++++
> > > > > > 1 file changed, 84 insertions(+)
> > > > > >
> > > > > > diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c
> > > > > > index 0af7a3d74f47..1dc186780ccf 100644
> > > > > > --- a/drivers/hwmon/pmbus/pmbus_core.c
> > > > > > +++ b/drivers/hwmon/pmbus/pmbus_core.c
> > > > > > @@ -2625,6 +2625,30 @@ 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 ssize_t pmbus_debugfs_mfr_read(struct file *file, char __user *buf,
> > > > > > + size_t count, loff_t *ppos)
> > > > > > +{
> > > > > > + int rc;
> > > > > > + struct pmbus_debugfs_entry *entry = file->private_data;
> > > > > > + char data[I2C_SMBUS_BLOCK_MAX + 2] = { 0 };
> > > > > > +
> > > > > > + rc = i2c_smbus_read_block_data(entry->client, entry->reg, data);
> > > > > > + if (rc < 0)
> > > > > > + return rc;
> > > > > > +
> > > > > > + data[rc] = '\n';
> > > > > > + rc += 2;
> > >
> > > Why +2 ?
> >
> > Copied from another driver.
> > +1 due to '\n'
> > +1 due to NULL character (smbus block transfer does not include it in the length)
> > Explanation included in v3 patch.
>
>
> "copied from another driver" is not really a good argument.
> That other driver might just be buggy.
yes, you're right. There is a bug in that driver.
>
> What do you see in userspace when you read the data ? A string that ends with
> "\n\0" ? If so, does the "\0" at the end add any value ?
I confirm I see "\n\0". I will fix it right now. Thank you for pointing it out.
Adam
>
> Guenter
Powered by blists - more mailing lists