[PATCH] hwmon: (ina3221) Fix read timeout issue

2019-10-21 Thread Nicolin Chen
mes of the wait time in order to fix this issue. Fixes: 5c090abf945b ("hwmon: (ina3221) Add averaging mode support") Signed-off-by: Nicolin Chen --- drivers/hwmon/ina3221.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hwmon/ina3221.c b/drivers/hwmo

Re: ABI for these two registers?

2019-10-07 Thread Nicolin Chen
On Wed, Oct 02, 2019 at 10:03:11PM -0700, Guenter Roeck wrote: > On 10/1/19 3:17 PM, Nicolin Chen wrote: > > Hello Guenter, > > > > It's been nearly three weeks. Would it be possible for you to > > provide some advice on my latest questions? I'd like to write > >

Re: ABI for these two registers?

2019-10-01 Thread Nicolin Chen
Hello Guenter, It's been nearly three weeks. Would it be possible for you to provide some advice on my latest questions? I'd like to write code and submit changes once ABI is confirmed... Thank you! On Thu, Sep 12, 2019 at 05:12:38PM -0700, Nicolin Chen wrote: > > > > > &g

Re: ABI for these two registers?

2019-09-12 Thread Nicolin Chen
On Thu, Sep 12, 2019 at 03:45:29PM -0700, Nicolin Chen wrote: > On Thu, Sep 12, 2019 at 03:09:47PM -0700, Guenter Roeck wrote: > > On Thu, Sep 12, 2019 at 02:09:58PM -0700, Nicolin Chen wrote: > > > Hello Guenter, > > > > > > On Thu, Sep 12, 2019 at 1

Re: ABI for these two registers?

2019-09-12 Thread Nicolin Chen
On Thu, Sep 12, 2019 at 03:09:47PM -0700, Guenter Roeck wrote: > On Thu, Sep 12, 2019 at 02:09:58PM -0700, Nicolin Chen wrote: > > Hello Guenter, > > > > On Thu, Sep 12, 2019 at 11:32:18AM -0700, Guenter Roeck wrote: > > > On Wed, Sep 11, 2019 at 05:28:

Re: ABI for these two registers?

2019-09-12 Thread Nicolin Chen
Hello Guenter, On Thu, Sep 12, 2019 at 11:32:18AM -0700, Guenter Roeck wrote: > On Wed, Sep 11, 2019 at 05:28:14PM -0700, Nicolin Chen wrote: > > Hello Guenter, > > > > Datasheet: http://www.ti.com/lit/ds/symlink/ina3221.pdf > > (At page 32, chapter 8.6.2.14 and 8.

ABI for these two registers?

2019-09-11 Thread Nicolin Chen
Hello Guenter, Datasheet: http://www.ti.com/lit/ds/symlink/ina3221.pdf (At page 32, chapter 8.6.2.14 and 8.6.2.15) I have two registers that I need to expose to user space: Shunt-Voltage-Sum and Shunt-Voltage-Limit registers Right now in[123]_input of INA3221 are for voltage channels

[PATCH v2 2/2] hwmon: (ina3221) Add voltage conversion time settings

2019-04-17 Thread Nicolin Chen
the conversion time into two equal values. Signed-off-by: Nicolin Chen --- Changelog v1->v2: * Merged two adjacent calls of regmap_update_bits(). * Replaced CONFIG register read-back with tmp variable Documentation/hwmon/ina3221 | 9 ++ drivers/hwmon/ina3221.c |

[PATCH v2 0/2] hwmon: (ina3221) Two changes for INA3221

2019-04-17 Thread Nicolin Chen
Adding two changes for INA3221 HWMON driver. Changlog v1->v2: * Added PATCH-1 * Rebased PATCH-2 (see detail of changelog in it) Nicolin Chen (2): hwmon: (ina3221) Do not read-back to cache reg_config hwmon: (ina3221) Add voltage conversion time settings Documentation/hwmon/ina3221 |

Re: [PATCH] hwmon: (ina3221) Add voltage conversion time settings

2019-04-17 Thread Nicolin Chen
On Wed, Apr 17, 2019 at 01:12:34PM -0700, Guenter Roeck wrote: > On Wed, Apr 17, 2019 at 12:48:18PM -0700, Nicolin Chen wrote: > > On Wed, Apr 17, 2019 at 11:39:49AM -0700, Nicolin Chen wrote: > > > > > > Thinking about it ... does it even make sense to cache reg_con

Re: [PATCH] hwmon: (ina3221) Add voltage conversion time settings

2019-04-17 Thread Nicolin Chen
On Wed, Apr 17, 2019 at 11:39:49AM -0700, Nicolin Chen wrote: > > Thinking about it ... does it even make sense to cache reg_config twice, > > or would it be better to just update the local copy and use regmap_write() > > to send it to the chip ? > > I remember the reason

Re: [PATCH] hwmon: (ina3221) Add voltage conversion time settings

2019-04-17 Thread Nicolin Chen
On Wed, Apr 17, 2019 at 07:04:09AM -0700, Guenter Roeck wrote: > > > I am not quite sure if this update_interval is the best way to > > > implement the conversion time settings but I can't find another > > > common approach. This implementation certainly has drawbacks: > > >   1) It can't

[PATCH] hwmon: (ina3221) Add voltage conversion time settings

2019-04-16 Thread Nicolin Chen
the conversion time into two equal values. Signed-off-by: Nicolin Chen --- Hi Guenter, I am not quite sure if this update_interval is the best way to implement the conversion time settings but I can't find another common approach. This implementation certainly has drawbacks: 1) It can't

[PATCH v2] hwmon: (ina3221) Add averaging mode support

2019-04-16 Thread Nicolin Chen
calculation by taking this samples value into account. Signed-off-by: Nicolin Chen --- Changelog v1->v2: * Implemented "samples" through hwmon_chip_info * Used find_closest() Documentation/hwmon/ina3221 | 3 ++ drivers/hwmon/ina3221.c | 67 - 2

Re: [PATCH] hwmon: Add support for samples attributes

2019-04-15 Thread Nicolin Chen
Thanks for adding this. On Mon, Apr 15, 2019 at 01:27:12PM -0700, Guenter Roeck wrote: > Add support for the new samples attributes to the hwmon core. > > Cc: Krzysztof Adamski > Cc: Nicolin Chen Acked-by: Nicolin Chen Will redo my change and test through API later.

Re: [PATCH 2/3] lm25066: export sysfs attribute for SAMPLES_FOR_AVG

2019-04-10 Thread Nicolin Chen
On Wed, Apr 10, 2019 at 05:55:19PM -0700, Guenter Roeck wrote: > > +static ssize_t samples_for_avg_show(struct device *dev, > > + struct device_attribute *attr, char *buf) > > +{ > > + struct i2c_client *client = to_i2c_client(dev->parent); > > + int ret; > > + >

Re: [PATCH] hwmon: (ina3221) Add averaging mode support

2019-03-12 Thread Nicolin Chen
On Tue, Mar 12, 2019 at 03:37:59PM -0700, Guenter Roeck wrote: > > +average Averaging mode. Supports the list of number of > > samples: > > + 1, 4, 16, 64, 128, 256, 512, 1024 > > This is the number of samples, so I think "samples" would be a better >

[PATCH] hwmon: (ina3221) Add averaging mode support

2019-03-12 Thread Nicolin Chen
into account. Signed-off-by: Nicolin Chen --- Documentation/hwmon/ina3221 | 2 ++ drivers/hwmon/ina3221.c | 61 - 2 files changed, 62 insertions(+), 1 deletion(-) diff --git a/Documentation/hwmon/ina3221 b/Documentation/hwmon/ina3221 index 4b82cbfb551c

Re: [RFC][PATCH] hwmon: (ina2xx) Improve current and power reading precision

2019-01-17 Thread Nicolin Chen
Hi Guenter, On Thu, Jan 17, 2019 at 03:13:23PM -0800, Guenter Roeck wrote: > I have one claim stating that your change won't make a difference, > and your claim that it would. That leaves me with no choice but to > spend a large amount of time with the datasheet, and possibly with > my

[PATCH v3 1/2] dt-bindings: hwmon: ina3221: Add ti,single-shot property

2019-01-17 Thread Nicolin Chen
ingle-shot operating mode. Signed-off-by: Nicolin Chen Reviewed-by: Rob Herring --- Changelog v2->v3: * Added "Reviewed-by" from Rob v1->v2: * N/A Documentation/devicetree/bindings/hwmon/ina3221.txt | 10 ++ 1 file changed, 10 insertions(+) diff --git a/Documentation/devicet

[PATCH v3 2/2] hwmon: (ina3221) Implement ti,single-shot DT property

2019-01-17 Thread Nicolin Chen
consuming mode to single-shot mode, which will measure input on demand and then shut down to save power. So this patch implements the DT property accordingly. Signed-off-by: Nicolin Chen --- Changelog v2->v3: * Dropped useless if condition by using the return value directly. v1->v2: * Re

[PATCH v3 0/2] hwmon (ina3221) Add single-shot mode support

2019-01-17 Thread Nicolin Chen
. Changelog v2->v3: * Added "Reviewed-by" from Rob to PATCH-1 * Cleaned-up PATCH-2 v1->v2: * Cleaned-up PATCH-2 Nicolin Chen (2): dt-bindings: hwmon: ina3221: Add ti,single-shot property hwmon: (ina3221) Implement ti,single-shot DT property .../devicetree/bindings/hwmon/ina3

Re: [PATCH v2 2/2] hwmon: (ina3221) Implement ti,single-shot DT property

2019-01-17 Thread Nicolin Chen
On Thu, Jan 17, 2019 at 02:58:42PM -0800, Guenter Roeck wrote: > "Right now" was supposed to mean that you should wait for Rob's > feedback before sending v3 with the feedback above applied. > Did you send that version ? I don't see it in patchwork, nor > in my inbox. Oh, sorry. Will resend it.

Re: [RFC][PATCH] hwmon: (ina2xx) Improve current and power reading precision

2019-01-17 Thread Nicolin Chen
On Fri, Jan 04, 2019 at 05:26:42PM -0800, Nicolin Chen wrote: > Hi Stefan, > > Sorry for a super late reply. I took a long vacation. > > On Wed, Nov 21, 2018 at 10:16:09PM +, Brüns, Stefan wrote: > > > > Another concern may be voltage drop over the shunt, but

Re: [PATCH v2 2/2] hwmon: (ina3221) Implement ti,single-shot DT property

2019-01-17 Thread Nicolin Chen
On Mon, Jan 07, 2019 at 11:35:55AM -0800, Guenter Roeck wrote: > > + if (of_property_read_bool(np, "ti,single-shot")) > > + ina->single_shot = true; > > + > ina->single_shot = of_property_read_bool(np, "ti,single-shot"); > > No need to resend right now; let's wait for feedback

[PATCH v2 0/2] hwmon (ina3221) Add single-shot mode support

2019-01-04 Thread Nicolin Chen
. Changelog v1->v2: * Cleaned-up PATCH-2 Nicolin Chen (2): dt-bindings: hwmon: ina3221: Add ti,single-shot property hwmon: (ina3221) Implement ti,single-shot DT property .../devicetree/bindings/hwmon/ina3221.txt | 10 ++ drivers/hwmon/ina3221.c |

[PATCH v2 1/2] dt-bindings: hwmon: ina3221: Add ti,single-shot property

2019-01-04 Thread Nicolin Chen
ingle-shot operating mode. Signed-off-by: Nicolin Chen --- Documentation/devicetree/bindings/hwmon/ina3221.txt | 10 ++ 1 file changed, 10 insertions(+) diff --git a/Documentation/devicetree/bindings/hwmon/ina3221.txt b/Documentation/devicetree/bindings/hwmon/ina3221.txt index a7b25caa2b8e..fa

[PATCH v2 2/2] hwmon: (ina3221) Implement ti,single-shot DT property

2019-01-04 Thread Nicolin Chen
consuming mode to single-shot mode, which will measure input on demand and then shut down to save power. So this patch implements the DT property accordingly. Signed-off-by: Nicolin Chen --- Changelog v1->v2: * Replaced the useless mode defines with a boolean variable. drivers/hwmon/ina322

Re: [PATCH 2/2] hwmon: (ina3221) Implement ti,single-shot DT property

2019-01-04 Thread Nicolin Chen
On Fri, Jan 04, 2019 at 06:37:55PM -0800, Guenter Roeck wrote: > > +enum ina3221_modes { > > + INA3221_MODE_SINGLE_SHOT, > > + INA3221_MODE_CONTINUOUS, > > + INA3221_NUM_MODES, > > Is NUM_MODES used anywhere ? Please drop unless there is a reason to keep it. Will clean it up in v2. Thanks

Re: [RFC][PATCH] hwmon: (ina2xx) Improve current and power reading precision

2019-01-04 Thread Nicolin Chen
Hi Stefan, Sorry for a super late reply. I took a long vacation. On Wed, Nov 21, 2018 at 10:16:09PM +, Brüns, Stefan wrote: > > > Another concern may be voltage drop over the shunt, but for this case you > > > have a nominal voltage of 1.8V, so 30uV are 0.001%. > > > > > > > When measuring

[PATCH 1/2] dt-bindings: hwmon: ina3221: Add ti,single-shot property

2019-01-04 Thread Nicolin Chen
ingle-shot operating mode. Signed-off-by: Nicolin Chen --- Documentation/devicetree/bindings/hwmon/ina3221.txt | 10 ++ 1 file changed, 10 insertions(+) diff --git a/Documentation/devicetree/bindings/hwmon/ina3221.txt b/Documentation/devicetree/bindings/hwmon/ina3221.txt index a7b25caa2b8e..fa

[PATCH 2/2] hwmon: (ina3221) Implement ti,single-shot DT property

2019-01-04 Thread Nicolin Chen
consuming mode to single-shot mode, which will measure input on demand and then shut down to save power. So this patch implements the DT property accordingly. Signed-off-by: Nicolin Chen --- drivers/hwmon/ina3221.c | 28 1 file changed, 28 insertions(+) diff --git

[PATCH 0/2] hwmon (ina3221) Add single-shot mode support

2019-01-04 Thread Nicolin Chen
By default, ina3221, as a hardware monitor, continuously measures the inputs and generates corresponding data. However, for battery powered devices, this mode might be power consuming. This series of patches add a feature of changing default operating mode to its single-shot mode via DT. Nicolin

Re: [RFC][PATCH] hwmon: (ina2xx) Improve current and power reading precision

2018-11-21 Thread Nicolin Chen
(Removing "m.pur...@samsung.com" since it's not reachable any more) Hi Stefan, Thank you for the comments. On Wed, Nov 21, 2018 at 04:13:01PM +, Brüns, Stefan wrote: > > === Problem === > > Both methods simplify software routine by fixing one factor, which > > sacrifices the precision of

[RFC][PATCH] hwmon: (ina2xx) Improve current and power reading precision

2018-11-20 Thread Nicolin Chen
= 62800 uW (expected 62965 uW) === Summary === - "shunt_resistor" attribute sets rshunt and "max_curr" boundaries - "max_curr" sysfs attribute decides current_lsb_uA and power_lsb_uW - ina2xx_init() still uses 4096|2048 as default calibration setting * All of them will calib

Re: [PATCH] hwmon (ina3221) Add single-shot mode support

2018-11-19 Thread Nicolin Chen
On Mon, Nov 19, 2018 at 09:45:59AM -0800, Guenter Roeck wrote: > > In short, other than exposing it via a generic ABI to the user > > space, how about defining some policy to maintaining it within > > the driver? > I think that would be a bad idea. It changes timing for everyone > curently using

[PATCH] Documentation: hwmon: Add descriptions for ina2xx sysfs entries

2018-11-19 Thread Nicolin Chen
There are a few sysfs entries being exposed to user space by the ina2xx hwmon driver while not getting explicitly documented. So this patch just adds a description section for them. Signed-off-by: Nicolin Chen --- Documentation/hwmon/ina2xx | 15 +++ 1 file changed, 15 insertions

Re: [PATCH] hwmon (ina3221) Add single-shot mode support

2018-11-16 Thread Nicolin Chen
Hello Guenter, On Wed, Nov 14, 2018 at 09:23:30AM -0800, Guenter Roeck wrote: > > An alternative way (without the sysfs node), after looking at > > other hwmon code, could be to have a timed polling thread and > > read data using an update_interval value from ABI. This might > > turn out to be

[PATCH] hwmon: (ina2xx) Fix current value calculation

2018-11-13 Thread Nicolin Chen
a casting to s16. Signed-off-by: Nicolin Chen --- drivers/hwmon/ina2xx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hwmon/ina2xx.c b/drivers/hwmon/ina2xx.c index c2252cf452f5..07ee19573b3f 100644 --- a/drivers/hwmon/ina2xx.c +++ b/drivers/hwmon/ina2xx.c @@ -274,7 +274,7

Re: [PATCH] hwmon (ina3221) Add single-shot mode support

2018-11-13 Thread Nicolin Chen
Hi Guenter, On Tue, Nov 13, 2018 at 09:21:02AM -0800, Guenter Roeck wrote: > > > > INA3221 supports both continuous and single-shot modes. When > > > > running in the continuous mode, it keeps measuring the inputs > > > > and converting them to the data register even if there are no > > > > users

Re: [PATCH] hwmon (ina3221) Add single-shot mode support

2018-11-12 Thread Nicolin Chen
Hi Guenter, On Mon, Nov 12, 2018 at 08:32:48PM -0800, Guenter Roeck wrote: > On Mon, Nov 12, 2018 at 08:23:53PM -0800, Nicolin Chen wrote: > > INA3221 supports both continuous and single-shot modes. When > > running in the continuous mode, it keeps measuring the inputs > >

Re: [PATCH] hwmon (ina3221) Add mutex lock to shunt nodes

2018-11-12 Thread Nicolin Chen
On Mon, Nov 12, 2018 at 08:31:22PM -0800, Guenter Roeck wrote: > On Mon, Nov 12, 2018 at 08:23:24PM -0800, Nicolin Chen wrote: > > The shunt resistor values are used to calculate shunt voltages > > and currents. As a part of sysfs nodes, it would be better to > > get protecte

[PATCH] hwmon (lm63) Do not overwrite data->kind

2018-11-12 Thread Nicolin Chen
According to the code right before the removed line, data->kind should be either from DT or from id pointer. So there shouldn't be an additional overwriting after the if-else statement. So this patch just removes the overwriting line. Signed-off-by: Nicolin Chen --- Guenter, I h

[PATCH] hwmon (ina3221) Add single-shot mode support

2018-11-12 Thread Nicolin Chen
g modes. Signed-off-by: Nicolin Chen --- Documentation/hwmon/ina3221 | 3 + drivers/hwmon/ina3221.c | 109 2 files changed, 112 insertions(+) diff --git a/Documentation/hwmon/ina3221 b/Documentation/hwmon/ina3221 index 4b82cbfb551c..b03f4ad901ee 100644 --- a

[PATCH] hwmon (ina3221) Add mutex lock to shunt nodes

2018-11-12 Thread Nicolin Chen
this patch adds the mutex lock to protect the shunt node. Signed-off-by: Nicolin Chen --- drivers/hwmon/ina3221.c | 17 +++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/drivers/hwmon/ina3221.c b/drivers/hwmon/ina3221.c index 86281afd2619..f7a09ab6c440 100644 --- a/drivers

[PATCH] hwmon (ina2xx) Fix NULL id pointer in probe()

2018-11-09 Thread Nicolin Chen
th hwmon->name. Fixes: bd0ddd4d0883 ("hwmon: (ina2xx) Add OF device ID table") Signed-off-by: Nicolin Chen --- drivers/hwmon/ina2xx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/hwmon/ina2xx.c b/drivers/hwmon/ina2xx.c index 71d3445ba869..c225

[PATCH v5 1/4] hwmon: (ina3221) Check channel status for alarms attribute read

2018-11-05 Thread Nicolin Chen
-off-by: Nicolin Chen --- Changelog v2->v5: * N/A v1->v2: * Returned 0 for alert flags instead of -ENODATA drivers/hwmon/ina3221.c | 6 ++ 1 file changed, 6 insertions(+) diff --git a/drivers/hwmon/ina3221.c b/drivers/hwmon/ina3221.c index d61688f04594..26cdf3342d80 100644 --- a/drivers

[PATCH v5 3/4] hwmon: (ina3221) Make sure data is ready before reading

2018-11-05 Thread Nicolin Chen
by adding a CVRF polling to make sure the data register is updated with the new data. Signed-off-by: Nicolin Chen --- Changelog v3->v5: * N/A v2->v3: * Dropped timeout dev_err messages as it's indicated in the errno v1->v2: * Moved CVRF polling to data read routine * Added calculation of

[PATCH v5 2/4] hwmon: (ina3221) Serialize sysfs ABI accesses

2018-11-05 Thread Nicolin Chen
by reading other fields like alert flags. So this patch adds a mutex lock to protect the write() and read() callbacks. The read_string() callback won't need the lock since it just returns the label without touching any hardware register. Signed-off-by: Nicolin Chen --- Changlog v1->v5: * N/A driv

[PATCH v5 4/4] hwmon: (ina3221) Add PM runtime support

2018-11-05 Thread Nicolin Chen
, as they're similar. It's also necessary to do so to match initial PM refcount with the number of enabled channels. Signed-off-by: Nicolin Chen --- Changelog v4->v5: * Dropped the code of passing pm pointer via _info API ** Moved all changes back to the status of v3 * Used i2c_client dev poin

[PATCH v5 0/4] hwmon: (ina3221) Implement PM runtime to save power

2018-11-05 Thread Nicolin Chen
r message and comments (PATCH-5) v1->v2: * Added device pointer check (PATCH-1) * Returned 0 for alert flags (PATCH-2) * Moved CVRF polling to data read routine (PATCH-4) * Bypassed i2c_client->dev in suspend/resume() (PATCH-5) Nicolin Chen (4): hwmon: (ina3221) Check channel status for alarms

Re: [PATCH v4 1/5] hwmon: (core) Add pm ops to hwmon class

2018-11-02 Thread Nicolin Chen
On Fri, Nov 02, 2018 at 10:54:35AM -0700, Guenter Roeck wrote: > > Actually, pm_runtime core also scans a class-level pm pointer: > > else if (dev->class && dev->class->pm) > > ops = dev->class->pm; > > > > This means that hwmon class in the hwmon core could actually >

[PATCH v4 5/5] hwmon: (ina3221) Add PM runtime support

2018-10-25 Thread Nicolin Chen
routine in the probe() by calling the resume() via pm_runtime_get_sync() instead, as they're similar. It's also necessary to do so to match initial PM refcount with the number of enabled channels. Signed-off-by: Nicolin Chen --- Changelog v3->v4: * Passed pm pointer via _with_info

[PATCH v4 3/5] hwmon: (ina3221) Serialize sysfs ABI accesses

2018-10-25 Thread Nicolin Chen
by reading other fields like alert flags. So this patch adds a mutex lock to protect the write() and read() callbacks. The read_string() callback won't need the lock since it just returns the label without touching any hardware register. Signed-off-by: Nicolin Chen --- Changlog v1->v4: * N/A driv

[PATCH v4 0/5] hwmon: (ina3221) Implement PM runtime to save power

2018-10-25 Thread Nicolin Chen
d routine (PATCH-4) * Bypassed i2c_client->dev in suspend/resume() (PATCH-5) Nicolin Chen (5): hwmon: (core) Add pm_runtime to hwmon class hwmon: (ina3221) Check channel status for alarms attribute read hwmon: (ina3221) Serialize sysfs ABI accesses hwmon: (ina3221) Make sure data is

[PATCH v4 1/5] hwmon: (core) Add pm ops to hwmon class

2018-10-25 Thread Nicolin Chen
ointers through _with_info API when registering devices. Signed-off-by: Nicolin Chen --- Changelog v3->v4: * Dropped the risky pointer copies * Added generic pm runtime callbacks to the hwmon class v2->v3: * N/A v1->v2: * Added device pointers drivers/hwmon/hwmon.c | 24

Re: [PATCH v3 1/5] hwmon: (core) Inherit power properties to hdev

2018-10-25 Thread Nicolin Chen
On Thu, Oct 25, 2018 at 06:55:31AM +, li...@roeck-us.net wrote: > > won't work then. I guess it'd be safer to ignore the problem of > > the power node, i.e. using parent dev pointer for pm runtime. > > > It might be worthwhile looking up how other virtal devices handle > this problem. Maybe

Re: [PATCH v3 1/5] hwmon: (core) Inherit power properties to hdev

2018-10-24 Thread Nicolin Chen
On Wed, Oct 24, 2018 at 06:01:16PM -0700, Nicolin Chen wrote: > On Thu, Oct 25, 2018 at 12:13:01AM +, li...@roeck-us.net wrote: > > > > + if (dev) { > > > + hdev->driver = dev->driver; > > > + hdev->power = dev->power; >

Re: [PATCH v3 1/5] hwmon: (core) Inherit power properties to hdev

2018-10-24 Thread Nicolin Chen
On Thu, Oct 25, 2018 at 12:13:01AM +, li...@roeck-us.net wrote: > > + if (dev) { > > + hdev->driver = dev->driver; > > + hdev->power = dev->power; > > + hdev->pm_domain = dev->pm_domain; > > + hdev->of_node = dev->of_node; > > + } > > We'l need to

[PATCH v3 4/5] hwmon: (ina3221) Make sure data is ready before reading

2018-10-24 Thread Nicolin Chen
by adding a CVRF polling to make sure the data register is updated with the new data. Signed-off-by: Nicolin Chen --- Changelog v2->v3: * Dropped timeout dev_err messages as it's indicated in the errno v1->v2: * Moved CVRF polling to data read routine * Added calculation of wait time

[PATCH v3 1/5] hwmon: (core) Inherit power properties to hdev

2018-10-24 Thread Nicolin Chen
pointers. Note that the dev->driver pointer is the place that contains a dev_pm_ops pointer defined in the parent device driver and the pm runtime core also checks this pointer: if (!cb && dev->driver && dev->driver->pm) Signed-off-by: Nicolin Chen --- Cha

[PATCH v3 5/5] hwmon: (ina3221) Add PM runtime support

2018-10-24 Thread Nicolin Chen
functions, which means there'd be two suspend() calls during the system suspend while the second one will fail. Signed-off-by: Nicolin Chen --- Changelog v2->v3: * Improved a dev_err message * Added comments at pm_runtime_put_noidle() callbacks * Added pm_runtime header file in an alphab

[PATCH v3 2/5] hwmon: (ina3221) Check channel status for alarms attribute read

2018-10-24 Thread Nicolin Chen
-off-by: Nicolin Chen --- Changelog v2->v3: * N/A v1->v2: * Returned 0 for alert flags instead of -ENODATA drivers/hwmon/ina3221.c | 6 ++ 1 file changed, 6 insertions(+) diff --git a/drivers/hwmon/ina3221.c b/drivers/hwmon/ina3221.c index d61688f04594..26cdf3342d80 100644 --- a/drivers

[PATCH v3 3/5] hwmon: (ina3221) Serialize sysfs ABI accesses

2018-10-24 Thread Nicolin Chen
by reading other fields like alert flags. So this patch adds a mutex lock to protect the write() and read() callbacks. The read_string() callback won't need the lock since it just returns the label without touching any hardware register. Signed-off-by: Nicolin Chen --- Changlog v1->v3: * N/A driv

Re: [PATCH v2 5/5] hwmon: (ina3221) Add PM runtime support

2018-10-24 Thread Nicolin Chen
On Wed, Oct 24, 2018 at 09:24:18AM +, li...@roeck-us.net wrote: > > +fail: > > + if (enable) { > > + dev_err(dev, "Reverting channel%d enabling: %d\n", > > + channel, ret); > > This message is confusing. Something like "Failed to enable channel %d: > error %d"

Re: [PATCH v2 4/5] hwmon: (ina3221) Make sure data is ready before reading

2018-10-24 Thread Nicolin Chen
On Wed, Oct 24, 2018 at 09:10:35AM +, li...@roeck-us.net wrote: > > @@ -150,6 +183,12 @@ static int ina3221_read_in(struct device *dev, u32 > > attr, int channel, long *val) > > if (!ina3221_is_enabled(ina, channel)) > > return -ENODATA; > > > > + ret

[PATCH v2 2/5] hwmon: (ina3221) Check channel status for alarms attribute read

2018-10-23 Thread Nicolin Chen
-off-by: Nicolin Chen --- Changelog v1->v2: * Returned 0 for alert flags instead of -ENODATA drivers/hwmon/ina3221.c | 6 ++ 1 file changed, 6 insertions(+) diff --git a/drivers/hwmon/ina3221.c b/drivers/hwmon/ina3221.c index d61688f04594..26cdf3342d80 100644 --- a/drivers/hwmon/ina322

[PATCH v2 3/5] hwmon: (ina3221) Serialize sysfs ABI accesses

2018-10-23 Thread Nicolin Chen
by reading other fields like alert flags. So this patch adds a mutex lock to protect the write() and read() callbacks. The read_string() callback won't need the lock since it just returns the label without touching any hardware register. Signed-off-by: Nicolin Chen --- drivers/hwmon/ina3221.c | 51

[PATCH v2 0/5] hwmon: (ina3221) Implement PM runtime to save power

2018-10-23 Thread Nicolin Chen
H-2) * Moved CVRF polling to data read routine (PATCH-4) * Bypassed i2c_client->dev in suspend/resume() (PATCH-5) Nicolin Chen (5): hwmon: (core) Inherit power properties to hdev hwmon: (ina3221) Check channel status for alarms attribute read hwmon: (ina3221) Serialize sysfs ABI accesses

[PATCH v2 1/5] hwmon: (core) Inherit power properties to hdev

2018-10-23 Thread Nicolin Chen
pointers. Note that the dev->driver pointer is the place that contains a dev_pm_ops pointer defined in the parent device driver and the pm runtime core also checks this pointer: if (!cb && dev->driver && dev->driver->pm) Signed-off-by: Nicolin Chen --- Chang

[PATCH v2 4/5] hwmon: (ina3221) Make sure data is ready before reading

2018-10-23 Thread Nicolin Chen
by adding a CVRF polling to make sure the data register is updated with the new data. Signed-off-by: Nicolin Chen --- * Moved CVRF polling to data read routine * Added calculation of wait time based on conversion time setting drivers/hwmon/ina3221.c | 46 + 1

[PATCH v2 5/5] hwmon: (ina3221) Add PM runtime support

2018-10-23 Thread Nicolin Chen
ich means there'd be two suspend() calls during the system suspend while the second one will fail. Signed-off-by: Nicolin Chen --- Changelog v1->v2: * Bypassed i2c_client->dev in suspend/resume() * Added a missing '\n' in one dev_err() drivers/hwmon/

Re: [PATCH 4/5] hwmon: (ina3221) Make sure data is ready after channel enabling

2018-10-17 Thread Nicolin Chen
On Wed, Oct 17, 2018 at 02:17:14PM -0700, Guenter Roeck wrote: > On Wed, Oct 17, 2018 at 01:53:48PM -0700, Nicolin Chen wrote: > > Hello Guenter, > > > > On Wed, Oct 17, 2018 at 09:55:43AM -0700, Guenter Roeck wrote: > > > > @@ -676,6 +701,13 @@ static int __m

Re: [PATCH 4/5] hwmon: (ina3221) Make sure data is ready after channel enabling

2018-10-17 Thread Nicolin Chen
Hello Guenter, On Wed, Oct 17, 2018 at 09:55:43AM -0700, Guenter Roeck wrote: > > @@ -676,6 +701,13 @@ static int __maybe_unused ina3221_resume(struct device > > *dev) > > if (ret) > > return ret; > > > > + /* Make sure data conversion is finished */ > > + ret =

Re: [PATCH 1/5] hwmon: (core) Inherit power properties to hdev

2018-10-17 Thread Nicolin Chen
On Wed, Oct 17, 2018 at 12:44:30PM -0700, Guenter Roeck wrote: > > + hdev->driver = dev->driver; > > + hdev->power = dev->power; > > + hdev->pm_domain = dev->pm_domain; > > dev can, unfortunately, be NULL > > > hdev->of_node = dev ? dev->of_node : NULL; > > ... as you can see here.

[PATCH 2/5] hwmon: (ina3221) Return -ENODATA for two alarms attributes

2018-10-16 Thread Nicolin Chen
-off-by: Nicolin Chen --- drivers/hwmon/ina3221.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/hwmon/ina3221.c b/drivers/hwmon/ina3221.c index d61688f04594..3e98b59108ee 100644 --- a/drivers/hwmon/ina3221.c +++ b/drivers/hwmon/ina3221.c @@ -200,6 +200,8 @@ static int

[PATCH 0/5] hwmon: (ina3221) Implement PM runtime to save power

2018-10-16 Thread Nicolin Chen
This series patches implement PM runtime feature in the ina3221 hwmon driver (PATCH-5). However, PATCH-[1:4] are required to make sure that the PM runtime feature would be functional and safe. Nicolin Chen (5): hwmon: (core) Inherit power properties to hdev hwmon: (ina3221) Return -ENODATA

[PATCH 1/5] hwmon: (core) Inherit power properties to hdev

2018-10-16 Thread Nicolin Chen
pointers. Note that the dev->driver pointer is the place that contains a dev_pm_ops pointer defined in the parent device driver and the pm runtime core also checks this pointer: if (!cb && dev->driver && dev->driver->pm) Signed-off-by: Nicolin Chen --- driv

[PATCH 4/5] hwmon: (ina3221) Make sure data is ready after channel enabling

2018-10-16 Thread Nicolin Chen
The data might need some time to get ready after channel enabling, although the data register is readable without CVRF being set. So this patch adds a CVRF polling to make sure that data register is updated with the new data. Signed-off-by: Nicolin Chen --- drivers/hwmon/ina3221.c | 32

[PATCH 3/5] hwmon: (ina3221) Serialize sysfs ABI accesses

2018-10-16 Thread Nicolin Chen
by reading other fields like alert flags. So this patch adds a mutex lock to protect the write() and read() callbacks. The read_string() callback won't need the lock since it just returns the label without touching any hardware register. Signed-off-by: Nicolin Chen --- drivers/hwmon/ina3221.c | 51

[PATCH 5/5] hwmon: (ina3221) Add PM runtime support

2018-10-16 Thread Nicolin Chen
necessary to do so to match initial refcount with the number of enabled channels. Signed-off-by: Nicolin Chen --- drivers/hwmon/ina3221.c | 104 +++- 1 file changed, 82 insertions(+), 22 deletions(-) diff --git a/drivers/hwmon/ina3221.c b/drivers/hwmon/ina3221.c

Re: [PATCH 2/2] hwmon: (ina3221) Add operating mode support

2018-10-11 Thread Nicolin Chen
On Thu, Oct 11, 2018 at 12:31:52PM -0700, Guenter Roeck wrote: > > One more question here, and this might sound a bit abuse of using > > the existing hwmon ABI: would it sound plausible to you that the > > driver powers down the chip when all three channels get disabled > > via in[123]_enable

Re: [PATCH 2/2] hwmon: (ina3221) Add operating mode support

2018-10-10 Thread Nicolin Chen
Hi Guenter, On Wed, Oct 10, 2018 at 04:43:00PM -0700, Guenter Roeck wrote: > > > The effort to do all this using CPU cycles would in most if not all cases > > > outweigh any perceived power savings. As such, I just don't see the > > > practical use case. > > > > It really depends on the use case

Re: [PATCH 2/2] hwmon: (ina3221) Add operating mode support

2018-10-10 Thread Nicolin Chen
> I am open to help explore adding support for runtime power management > to the hwmon subsystem, but that would be less than straightforward and > require an actual use case to warrant the effort. Is there any feasible solution from your point of view? Thanks Nicolin > > As s

[PATCH 2/2] hwmon: (ina3221) Add operating mode support

2018-10-09 Thread Nicolin Chen
The hwmon core now has a new optional mode interface. So this patch just implements this mode support so that user space can check and configure via sysfs node its operating modes: power-down, one-shot, and continuous modes. Signed-off-by: Nicolin Chen --- drivers/hwmon/ina3221.c | 64

[PATCH 1/2] hwmon: (core) Add hwmon_mode structure and mode sysfs node

2018-10-09 Thread Nicolin Chen
;mode" and "available_modes" for user to check and configure the operating mode. For hwmon device drivers that implemented the _with_info API, the change also adds an optional hwmon_mode structure in hwmon_chip_info structure so that those drivers can pass mode related information. Si

[PATCH 0/2] hwmon: Add operating mode support for core and ina3221

2018-10-09 Thread Nicolin Chen
Add operating mode support in the core and ina3221. Nicolin Chen (2): hwmon: (core) Add hwmon_mode structure and mode sysfs node hwmon: (ina3221) Add operating mode support Documentation/hwmon/sysfs-interface | 15 + drivers/hwmon/hwmon.c | 87

[PATCH v2] hwmon: (core) Add trace events to _attr_show/store functions

2018-10-09 Thread Nicolin Chen
-by: Nicolin Chen --- Changelog v1->v2: * Added a descriptive reason for this change in the commit message MAINTAINERS | 1 + drivers/hwmon/hwmon.c| 27 ++ include/trace/events/hwmon.h | 71 3 files changed, 92 inserti

Re: [PATCH] hwmon: (core) Add trace events to _attr_show/store functions

2018-10-09 Thread Nicolin Chen
On Tue, Oct 09, 2018 at 03:49:45PM -0400, Steven Rostedt wrote: > > > > Trace events are useful for people who collect data from the > > > > ftrace output. This patch adds initial trace events for the > > > > hwmon core. To call hwmon_attr_base() for aligned attr index > > > > numbers, this patch

Re: [PATCH] hwmon: (core) Add trace events to _attr_show/store functions

2018-10-09 Thread Nicolin Chen
On Tue, Oct 09, 2018 at 02:57:21PM -0400, Steven Rostedt wrote: > > Trace events are useful for people who collect data from the > > ftrace output. This patch adds initial trace events for the > > hwmon core. To call hwmon_attr_base() for aligned attr index > > numbers, this patch also moves the

[PATCH] hwmon: (core) Add trace events to _attr_show/store functions

2018-10-09 Thread Nicolin Chen
_with_info API to register a hwmon device. Signed-off-by: Nicolin Chen --- MAINTAINERS | 1 + drivers/hwmon/hwmon.c| 27 ++ include/trace/events/hwmon.h | 71 3 files changed, 92 insertions(+), 7 deletions(-) create mode

[PATCH v2] hwmon: (ina3221) Validate shunt resistor value from DT

2018-10-08 Thread Nicolin Chen
The input->shunt_resistor is int type while the value from DT is unsigned int. Meanwhile, a divide-by-zero error would happen if the value is 0. So this patch just simply validates the value. Signed-off-by: Nicolin Chen --- Changelog v1->v2: * Validate the value and error out drivers

[PATCH v2] hwmon: (ina3221) Use _info API to register hwmon device

2018-10-08 Thread Nicolin Chen
68261aaa drivers/hwmon/ina3221_before.o 4456 440 048961320 drivers/hwmon/ina3221.o Signed-off-by: Nicolin Chen --- Changelog v1->v2: * Added a binary size comparison in commit message * Dropped unnecessary checks * Dropped misleading ID conversion in the comme

[PATCH] hwmon: (ina3221) Clamp shunt resistor value from DT

2018-10-08 Thread Nicolin Chen
The input->shunt_resistor is int type while the value from DT is unsigned int. Meanwhile, a divide-by-zero error would happen if the value is 0. So this patch just simply clamps the value. Signed-off-by: Nicolin Chen --- drivers/hwmon/ina3221.c | 4 +++- 1 file changed, 3 insertions(+)

[PATCH 1/2] hwmon: (core) Add hwmon_in_enable attribute

2018-10-05 Thread Nicolin Chen
According to hwmon ABI, in%d_enable is a sysfs interface that allows user space to enable and disable the input sensor. So this patch just simply adds the attribute to the list. Signed-off-by: Nicolin Chen --- drivers/hwmon/hwmon.c | 1 + include/linux/hwmon.h | 2 ++ 2 files changed, 3

[PATCH 2/2] hwmon: (ina3221) Use _info API to register hwmon device

2018-10-05 Thread Nicolin Chen
The hwmon core has a newer API which abstracts most of common things in the core so as to simplify the hwmon device drivers. This patch implements this _info API to ina3221 hwmon driver. Signed-off-by: Nicolin Chen --- drivers/hwmon/ina3221.c | 528 +++- 1

[PATCH 0/2] hwmon: (ina3221) Apply _info API

2018-10-05 Thread Nicolin Chen
This series of patches applies _info API of hwmon core to the ina3221 hwmon driver. Nicolin Chen (2): hwmon: (core) Add hwmon_in_enable attribute hwmon: (ina3221) Use _info API to register hwmon device drivers/hwmon/hwmon.c | 1 + drivers/hwmon/ina3221.c | 528

Re: hwmon: trace event support?

2018-10-04 Thread Nicolin Chen
Hello, On Thu, Oct 04, 2018 at 09:48:02AM -0700, Guenter Roeck wrote: > > > I would not object to adding trace support into the hwmon subsystem. > > > However, it should be tied to the new API. I would resist patches > > > adding trace support to individual hwmon drivers unless the new API > > >

Re: hwmon: trace event support?

2018-10-03 Thread Nicolin Chen
Thanks for the quick response. On Wed, Oct 03, 2018 at 05:42:23PM -0700, Guenter Roeck wrote: > > Ftrace data. Similar to tz->poll_queue in thermal_core, hwmon core > > could also have a work queue polling the registered sensor inputs > > (by default disabled; enabled only if users configure

hwmon: trace event support?

2018-10-03 Thread Nicolin Chen
Hello Guenter, I am thinking about a possibility of adding a trace event support in hwmon subsystem. Ftrace is pretty useful and widely applied to different subsystems already while hwmon doesn't seem to have one yet. I know some power/perf folks who rely on the trace events to analyse

  1   2   >