linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Guenter Roeck <linux@roeck-us.net>
To: Nicolin Chen <nicoleotsuka@gmail.com>
Cc: jdelvare@suse.com, robh+dt@kernel.org, mark.rutland@arm.com,
	corbet@lwn.net, afd@ti.com, linux-hwmon@vger.kernel.org,
	devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-doc@vger.kernel.org
Subject: Re: [PATCH v3 2/2] hwmon: ina3221: Read channel input source info from DT
Date: Sat, 22 Sep 2018 16:59:55 -0700	[thread overview]
Message-ID: <f8e017c4-10dd-2d0d-84df-b05d3ed03bbf@roeck-us.net> (raw)
In-Reply-To: <20180922184650.GB9092@Asurada>

On 09/22/2018 11:46 AM, Nicolin Chen wrote:
>>> This patch adds a new structure of input source specific
>>> information including input source label, shunt resistor
>>> value and its connection status. It exposes these labels
>>> via sysfs and also disables those channels where there's
>>> no input source being connected.
>>>
>>
>> I see you have decided to just display the disconnected channels.
>> This is misleading, and I can not accept it. Please either use the
>> is_visible callback to not display those channels at all, or have
> 
> I will add is_visible. I have almost finished it while waiting for
> the v3's review comments. Will test it and include in the v4.
> 
>> the _input attribute of disabled channels return -ENODATA (see
>> 'in[0-*]_enable' attribute in the ABI). If you implement the latter,
>> I would suggest to also implement the _enable attribute.
> 
> I will also add one separate patch for in[0-*]_enable after these
> two changes pass the review and get applied.
> 
>> As mentioned in patch 1, I can not accept an implicitly mandatory
>> label attribute. The property defining the label attribute will
>> have to be optional and well defined to ensure that it matches
>> the ABI.
> 
> I replied this in the PATCH-1. Let's discuss this topic there.
> 
>>> +	/* Disable channels if their inputs are disconnected */
>>> +	for (i = 0, mask = 0; i < INA3221_NUM_CHANNELS; i++) {
>>> +		if (ina->inputs[i].disconnected)
>>> +			mask |= INA3221_CONFIG_CHx_EN(i);
>>> +	}
>>
>> Consequently, you should also _enable_ channels which are not explicitly disabled.
> 
> The register has enabled all channels by default. So I felt it'd
> be neat to have disabling code only. My v1 actually had enabling
> part as well, but I can add it back if you think it'd be better.
> 
>> This can be tricky since you'll have to distinguish non-DT and DT configuration
>> and retain the original configuration if no channel configuration data is available
>> from devicetree.
> 
> I don't quite understand this comments. Would you please elaborate
> it?
> 
> For non-DT configurations, input->disconnected is always false by
> default unless someone adds config for it (through platform_data).
> If regmap_update_bits only does disabling like this version does,
> non-DT configurations will not get affected since mask = 0. Or if
> we change it to do both enabling and disabling, regmap_update_bits
> will still ignore since there's no register value changed, though
> it won't really hurt even if regmap writes correct configurations
> to the register.
> 
> For DT configurations (without channel input source defined), it's
> like the same as non-DT configurations. As we have platforms only
> enabled ina3221 via DT while they don't have this new DT binding,
> the driver has to be backward compatible, so my change only sets
> input->disconnected=true when a status="disabled" is present, i.e.
> those platforms are treated as all channels getting enabled until
> they update their DTs.
> 

I think your assumption may be that the chip is always in its reset state
when Linux is loaded. This is not necessarily the case; it may be
preconfigured by BIOS or ROMMON, or even by someone using i2cset before
loading the driver. If you add enable/disable functionality, you can
not make an assumption about the original state of the chip at probe time;
you have to read it from the chip itself.

Thanks,
Guenter

  reply	other threads:[~2018-09-23  0:00 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-21 22:32 [PATCH v3 0/2] Add an initial DT binding doc for ina3221 Nicolin Chen
2018-09-21 22:32 ` [PATCH v3 1/2] dt-bindings: hwmon: Add ina3221 documentation Nicolin Chen
2018-09-22 12:38   ` Guenter Roeck
2018-09-22 18:03     ` Nicolin Chen
2018-09-22 23:56       ` Guenter Roeck
2018-09-21 22:32 ` [PATCH v3 2/2] hwmon: ina3221: Read channel input source info from DT Nicolin Chen
2018-09-22 12:50   ` Guenter Roeck
2018-09-22 18:46     ` Nicolin Chen
2018-09-22 23:59       ` Guenter Roeck [this message]
2018-09-23  0:38         ` Nicolin Chen
2018-09-23  0:50           ` Nicolin Chen
2018-09-23  2:07           ` Guenter Roeck
2018-09-23  3:33             ` Nicolin Chen
2018-09-23  3:39               ` Nicolin Chen
2018-09-23  5:25               ` 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=f8e017c4-10dd-2d0d-84df-b05d3ed03bbf@roeck-us.net \
    --to=linux@roeck-us.net \
    --cc=afd@ti.com \
    --cc=corbet@lwn.net \
    --cc=devicetree@vger.kernel.org \
    --cc=jdelvare@suse.com \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=nicoleotsuka@gmail.com \
    --cc=robh+dt@kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).