From: "Farber, Eliav" <farbere@amazon.com>
To: Andy Shevchenko <andriy.shevchenko@intel.com>
Cc: <jdelvare@suse.com>, <linux@roeck-us.net>, <robh+dt@kernel.org>,
<p.zabel@pengutronix.de>, <rtanwar@maxlinear.com>,
<linux-hwmon@vger.kernel.org>, <devicetree@vger.kernel.org>,
<linux-kernel@vger.kernel.org>, <hhhawa@amazon.com>,
<jonnyc@amazon.com>, "Farber, Eliav" <farbere@amazon.com>
Subject: Re: [PATCH v5 20/21] hwmon: (mr75203) add debugfs to read and write temperature coefficients
Date: Tue, 13 Sep 2022 17:40:16 +0300 [thread overview]
Message-ID: <3b121ab4-dd64-68b3-ee89-8571b5d3651e@amazon.com> (raw)
In-Reply-To: <581a4a0b-8e0e-b7a2-f873-77ed74b54e96@amazon.com>
On 9/13/2022 4:06 PM, Farber, Eliav wrote:
> 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@alpine:~# cat /sys/kernel/debug/940f23d0000.pvt/ts_coeff_j
> 0
> root@alpine:~# echo 100 > /sys/kernel/debug/940f23d0000.pvt/ts_coeff_j
> root@alpine:~# cat /sys/kernel/debug/940f23d0000.pvt/ts_coeff_j
> 100
> root@alpine:~# 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?
It seems like debugfs_attr_write() calls simple_attr_write() and it uses
kstrtoull(), which is why it fails when setting a negative value.
This is the same also in v6.0-rc5.
debugfs_attr_read() on the other hand does show the correct value also
when j is negative.
--
Regards, Eliav
next prev parent reply other threads:[~2022-09-13 15:34 UTC|newest]
Thread overview: 55+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-08 15:24 [PATCH v5 00/21] Variety of fixes and new features for mr75203 driver Eliav Farber
2022-09-08 15:24 ` [PATCH v5 01/21] dt-bindings: hwmon: (mr75203) fix "intel,vm-map" property to be optional Eliav Farber
2022-09-08 18:59 ` Guenter Roeck
2022-09-08 15:24 ` [PATCH v5 02/21] hwmon: (mr75203) fix VM sensor allocation when "intel,vm-map" not defined Eliav Farber
2022-09-08 15:24 ` [PATCH v5 03/21] hwmon: (mr75203) update pvt->v_num and vm_num to the actual number of used sensors Eliav Farber
2022-09-08 15:24 ` [PATCH v5 04/21] hwmon: (mr75203) fix voltage equation for negative source input Eliav Farber
2022-09-08 15:24 ` [PATCH v5 05/21] hwmon: (mr75203) fix multi-channel voltage reading Eliav Farber
2022-09-08 15:24 ` [PATCH v5 06/21] hwmon: (mr75203) enable polling for all VM channels Eliav Farber
2022-09-08 15:24 ` [PATCH v5 07/21] dt-bindings: hwmon: (mr75203) add description for Moortec's PVT controller Eliav Farber
2022-09-09 2:16 ` Guenter Roeck
2022-09-08 15:24 ` [PATCH v5 08/21] dt-bindings: hwmon: (mr75203) change "resets" property to be optional Eliav Farber
2022-09-09 2:17 ` Guenter Roeck
2022-09-08 15:24 ` [PATCH v5 09/21] hwmon: (mr75203) skip reset-control deassert for SOCs that don't support it Eliav Farber
2022-09-09 2:18 ` Guenter Roeck
2022-09-08 15:24 ` [PATCH v5 10/21] dt-bindings: vendor-prefixes: add vendor prefix for Moortec Eliav Farber
2022-09-13 11:47 ` Rob Herring
2022-09-19 12:59 ` Guenter Roeck
2022-09-08 15:24 ` [PATCH v5 11/21] dt-bindings: hwmon: (mr75203) add "moortec,vm-active-channels" property Eliav Farber
2022-09-13 11:49 ` Rob Herring
2022-09-19 12:59 ` Guenter Roeck
2022-09-08 15:24 ` [PATCH v5 12/21] hwmon: (mr75203) add VM active channel support Eliav Farber
2022-09-19 13:00 ` Guenter Roeck
2022-09-08 15:24 ` [PATCH v5 13/21] dt-bindings: hwmon: (mr75203) add "moortec,vm-pre-scaler-x2" property Eliav Farber
2022-09-13 11:50 ` Rob Herring
2022-09-19 13:01 ` Guenter Roeck
2022-09-08 15:24 ` [PATCH v5 14/21] hwmon: (mr75203) add VM pre-scaler x2 support Eliav Farber
2022-09-19 13:10 ` Guenter Roeck
2022-09-08 15:24 ` [PATCH v5 15/21] hwmon: (mr75203) modify the temperature equation according to series 5 datasheet Eliav Farber
2022-09-19 13:11 ` Guenter Roeck
2022-09-08 15:24 ` [PATCH v5 16/21] dt-bindings: hwmon: (mr75203) add "moortec,ts-series" property Eliav Farber
2022-09-08 19:02 ` Guenter Roeck
2022-09-08 20:18 ` [PATCH v5 16/21] dt-bindings: hwmon: (mr75203) add "moortec, ts-series" property Farber, Eliav
2022-09-08 20:22 ` Guenter Roeck
2022-09-13 11:57 ` [PATCH v5 16/21] dt-bindings: hwmon: (mr75203) add "moortec,ts-series" property Rob Herring
2022-09-19 13:18 ` Guenter Roeck
2022-09-08 15:24 ` [PATCH v5 17/21] hwmon: (mr75203) add support for series 6 temperature equation Eliav Farber
2022-09-19 13:19 ` Guenter Roeck
2022-09-08 15:24 ` [PATCH v5 18/21] dt-bindings: hwmon: (mr75203) add coefficient properties for the thermal equation Eliav Farber
2022-09-13 11:58 ` Rob Herring
2022-09-19 13:20 ` Guenter Roeck
2022-09-08 15:24 ` [PATCH v5 19/21] hwmon: (mr75203) parse temperature coefficients from device-tree Eliav Farber
2022-09-19 13:21 ` Guenter Roeck
2022-09-08 15:24 ` [PATCH v5 20/21] hwmon: (mr75203) add debugfs to read and write temperature coefficients Eliav Farber
2022-09-08 18:11 ` Andy Shevchenko
2022-09-13 13:06 ` Farber, Eliav
2022-09-13 14:40 ` Farber, Eliav [this message]
2022-09-13 17:01 ` Andy Shevchenko
2022-09-14 4:26 ` Farber, Eliav
2022-09-14 9:32 ` Andy Shevchenko
2022-09-14 14:03 ` Andy Shevchenko
2022-09-14 14:08 ` Andy Shevchenko
2022-09-15 9:17 ` Farber, Eliav
2022-09-19 13:22 ` Guenter Roeck
2022-09-08 15:24 ` [PATCH v5 21/21] hwmon: (mr75203) fix coding style space errors Eliav Farber
2022-09-19 13:23 ` Guenter Roeck
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3b121ab4-dd64-68b3-ee89-8571b5d3651e@amazon.com \
--to=farbere@amazon.com \
--cc=andriy.shevchenko@intel.com \
--cc=devicetree@vger.kernel.org \
--cc=hhhawa@amazon.com \
--cc=jdelvare@suse.com \
--cc=jonnyc@amazon.com \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=p.zabel@pengutronix.de \
--cc=robh+dt@kernel.org \
--cc=rtanwar@maxlinear.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox