[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <581a4a0b-8e0e-b7a2-f873-77ed74b54e96@amazon.com>
Date: Tue, 13 Sep 2022 16:06:20 +0300
From: "Farber, Eliav" <farbere@...zon.com>
To: Andy Shevchenko <andriy.shevchenko@...el.com>
CC: <jdelvare@...e.com>, <linux@...ck-us.net>, <robh+dt@...nel.org>,
<p.zabel@...gutronix.de>, <rtanwar@...linear.com>,
<linux-hwmon@...r.kernel.org>, <devicetree@...r.kernel.org>,
<linux-kernel@...r.kernel.org>, <hhhawa@...zon.com>,
<jonnyc@...zon.com>, "Farber, Eliav" <farbere@...zon.com>
Subject: Re: [PATCH v5 20/21] hwmon: (mr75203) add debugfs to read and write
temperature coefficients
On 9/8/2022 9:11 PM, Andy Shevchenko wrote:
> On Thu, Sep 08, 2022 at 03:24:48PM +0000, Eliav Farber wrote:
>> This change adds debugfs to read and write temperature sensor
>> coefficients
>> - g, h, j and cal5.
>>
>> The coefficients can vary between product and product, so it can be very
>> useful to be able to modify them on the fly during the calibration
>> process.
>>
>> e.g.:
>>
>> cat /sys/kernel/debug/940f23d0000.pvt/ts_coeff_cal5
>> 4096
>>
>> echo 83000 > sys/kernel/debug/940f23d0000.pvt/ts_coeff_g
>
> ...
>
>> - Return j coefficient to use debugfs_create_file() instead of
>> debugfs_create_u32() because j is signed.
>
> You can use
>
> DEFINE_DEBUGFS_ATTRIBUTE(ts_coeff_j, ts_coeff_j_get, ts_coeff_j_set,
> "%lld\n");
>
> which still makes code compact.
I tried your suggestion to use DEFINE_DEBUGFS_ATTRIBUTE but I can't set
j to be a negative value:
root@...ine:~# cat /sys/kernel/debug/940f23d0000.pvt/ts_coeff_j
0
root@...ine:~# echo 100 > /sys/kernel/debug/940f23d0000.pvt/ts_coeff_j
root@...ine:~# cat /sys/kernel/debug/940f23d0000.pvt/ts_coeff_j
100
root@...ine:~# echo -100 > /sys/kernel/debug/940f23d0000.pvt/ts_coeff_j
sh: write error: Invalid argument
This is the code I added:
static int ts_coeff_j_set(void *data, u64 val)
{
struct pvt_device *pvt = data;
pvt->ts_coeff.j = val;
return 0;
}
static int ts_coeff_j_get(void *data, u64 *val)
{
struct pvt_device *pvt = data;
*val = pvt->ts_coeff.j;
return 0;
}
DEFINE_DEBUGFS_ATTRIBUTE(ts_coeff_j_fops, ts_coeff_j_get,
ts_coeff_j_set, "%lld\n");
static void devm_pvt_ts_dbgfs_remove(void *data)
{
struct pvt_device *pvt = (struct pvt_device *)data;
debugfs_remove_recursive(pvt->dbgfs_dir);
pvt->dbgfs_dir = NULL;
}
static int pvt_ts_dbgfs_create(struct pvt_device *pvt, struct device *dev)
{
...
debugfs_create_file("ts_coeff_j", 0644, pvt->dbgfs_dir, pvt,
&ts_coeff_j_fops);
...
I'm using kernel 5.10.112.
Can you please see if I'm did anything wrong?
--
Thanks, Eliav
Powered by blists - more mailing lists