From: Guenter Roeck <linux@roeck-us.net>
To: Wenliang Yan <wenliang202407@163.com>
Cc: Jean Delvare <jdelvare@suse.com>, Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Jonathan Corbet <corbet@lwn.net>,
linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 2/2] hwmon:(ina238)Add support for SQ52206
Date: Mon, 13 Jan 2025 09:45:48 -0800 [thread overview]
Message-ID: <c7c3503f-526e-41f3-8b82-ba7c7c68e89e@roeck-us.net> (raw)
In-Reply-To: <20250113035023.365697-3-wenliang202407@163.com>
On Mon, Jan 13, 2025 at 11:50:23AM +0800, Wenliang Yan wrote:
> Add support for SQ52206 to the Ina238 driver. Add registers,
> add calculation formulas, increase compatibility, add
> compatibility programs for multiple chips.
>
> Signed-off-by: Wenliang Yan <wenliang202407@163.com>
> ---
...
> @@ -452,6 +554,9 @@ static umode_t ina238_is_visible(const void *drvdata,
> enum hwmon_sensor_types type,
> u32 attr, int channel)
> {
> + const struct ina238_data *data = drvdata;
> + bool has_power_highest = data->config->has_power_highest;
> +
> switch (type) {
> case hwmon_in:
> switch (attr) {
> @@ -479,6 +584,10 @@ static umode_t ina238_is_visible(const void *drvdata,
> return 0444;
> case hwmon_power_max:
> return 0644;
> + case hwmon_power_input_highest:
> + if (has_power_highest)
> + return 0444;
> + break;
This doesn't work as intended. The break; results in the code
entering the hwmon_temp: case. It has to be "return 0;" or
the entire function needs to be rewritten to use "break;"
to exit the switch statements, and "return 0;" at the end
of the function.
> static int ina238_probe(struct i2c_client *client)
> {
...
> - if (data->gain == 1)
> + config = data->config->config_default;
> + if (chip == sq52206)
> + if (data->gain == 1)
> + config |= SQ52206_CONFIG_ADCRANGE_HIGH; /* ADCRANGE = 10/11 is /1 */
> + else if (data->gain == 2)
> + config |= SQ52206_CONFIG_ADCRANGE_LOW; /* ADCRANGE = 01 is /2 */
> + else if (data->gain == 1)
The "else" here is the else from "if (data->gain == 2)" which is wrong.
The entire if/else block from "if (chip == sq52206)" needs to be in {}
to avoid that.
> config |= INA238_CONFIG_ADCRANGE; /* ADCRANGE = 1 is /1 */
> ret = regmap_write(data->regmap, INA238_CONFIG, config);
> if (ret < 0) {
> @@ -605,7 +735,8 @@ static int ina238_probe(struct i2c_client *client)
>
> hwmon_dev = devm_hwmon_device_register_with_info(dev, client->name, data,
> &ina238_chip_info,
> - NULL);
> + data->config->has_energy ?
> + NULL : ina238_groups);
This seems to be wrong check. I would assume that ina238_groups is passed
if data->config->has_energy is true, not if it is false.
Guenter
next prev parent reply other threads:[~2025-01-13 17:45 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-13 3:50 [PATCH v2 0/2] " Wenliang Yan
2025-01-13 3:50 ` [PATCH v2 1/2] dt-bindings:Add SQ52206 to ina2xx devicetree bindings Wenliang Yan
2025-01-13 17:12 ` Conor Dooley
2025-01-14 7:43 ` [PATCH v2 2/2] hwmon:(ina238)Add support for SQ52206 Wenliang Yan
2025-01-13 3:50 ` Wenliang Yan
2025-01-13 6:52 ` kernel test robot
2025-01-13 17:45 ` Guenter Roeck [this message]
2025-01-14 7:44 ` Wenliang Yan
2025-01-13 18:30 ` kernel test robot
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=c7c3503f-526e-41f3-8b82-ba7c7c68e89e@roeck-us.net \
--to=linux@roeck-us.net \
--cc=conor+dt@kernel.org \
--cc=corbet@lwn.net \
--cc=jdelvare@suse.com \
--cc=krzk+dt@kernel.org \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=robh@kernel.org \
--cc=wenliang202407@163.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
all inboxes | Powered by JetHome®