From: Tzung-Bi Shih <tzungbi@kernel.org>
To: Guenter Roeck <linux@roeck-us.net>
Cc: Hardware Monitoring <linux-hwmon@vger.kernel.org>
Subject: Re: [PATCH v2 11/14] hwmon: (ina2xx) Convert to use with_info hwmon API
Date: Fri, 30 Aug 2024 20:30:13 +0800 [thread overview]
Message-ID: <ZtG7VaILKoZUHTkC@tzungbi-laptop> (raw)
In-Reply-To: <20240830010554.1462861-12-linux@roeck-us.net>
On Thu, Aug 29, 2024 at 06:05:51PM -0700, Guenter Roeck wrote:
> +static int ina2xx_chip_read(struct device *dev, u32 attr, long *val)
> {
> - struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
> struct ina2xx_data *data = dev_get_drvdata(dev);
> - unsigned int mask;
> - int alarm = 0;
> + u32 regval;
> int ret;
>
> - ret = regmap_read_bypassed(data->regmap, INA226_MASK_ENABLE, &mask);
> + switch (attr) {
> + case hwmon_chip_update_interval:
> + ret = regmap_read(data->regmap, INA2XX_CONFIG, ®val);
> + if (ret)
> + return ret;
> +
> + *val = ina226_reg_to_interval(regval);
> + break;
> + default:
> + return -EOPNOTSUPP;
> + }
> + return 0;
......(1)
> +static int ina2xx_power_read(struct device *dev, u32 attr, long *val)
> +{
> + struct ina2xx_data *data = dev_get_drvdata(dev);
> +
> + switch (attr) {
> + case hwmon_power_input:
> + return ina2xx_read_init(dev, INA2XX_POWER, val);
> + case hwmon_power_crit:
> + return ina226_alert_limit_read(data, INA226_POWER_OVER_LIMIT_MASK,
> + INA2XX_POWER, val);
> + case hwmon_power_crit_alarm:
> + return ina226_alert_read(data->regmap, INA226_POWER_OVER_LIMIT_MASK, val);
> + default:
> + return -EOPNOTSUPP;
> + }
......(2)
Just noticed a nit: there are some *_read() and *_write() functions mainly
contain a switch-case block. Some of them returns 0 at the end of the function
(1); some of them don't (2). (1) should be unreachable, however, I'm not sure
whether some checkers might complain about case (2).
In either cases, it would be great if make them consistent.
With that,
Reviewed-by: Tzung-Bi Shih <tzungbi@kernel.org>
next prev parent reply other threads:[~2024-08-30 12:30 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-30 1:05 [PATCH v2 00/14] hwmon: (ina2xx) Cleanup and convert to use with_info API Guenter Roeck
2024-08-30 1:05 ` [PATCH v2 01/14] hwmon: (ina2xx) Reorder include files to alphabetic order Guenter Roeck
2024-08-30 1:05 ` [PATCH v2 02/14] hwmon: (ina2xx) Replace platform data with device properties Guenter Roeck
2024-08-30 1:05 ` [PATCH v2 03/14] hwmon: (ina2xx) Use bit operations Guenter Roeck
2024-08-30 1:05 ` [PATCH v2 04/14] hwmon: (ina2xx) Mark regmap_config as const Guenter Roeck
2024-08-30 12:28 ` Tzung-Bi Shih
2024-08-30 1:05 ` [PATCH v2 05/14] hwmon: (ina2xx) Use local regmap pointer if used more than once Guenter Roeck
2024-08-30 1:05 ` [PATCH v2 06/14] hwmon: (ina2xx) Re-initialize chip using regmap functions Guenter Roeck
2024-08-30 12:29 ` Tzung-Bi Shih
2024-08-30 1:05 ` [PATCH v2 07/14] hwmon: (ina2xx) Fix various overflow issues Guenter Roeck
2024-08-30 1:05 ` [PATCH v2 08/14] hwmon: (ina2xx) Consolidate chip initialization code Guenter Roeck
2024-08-30 12:29 ` Tzung-Bi Shih
2024-08-30 1:05 ` [PATCH v2 09/14] hwmon: (ina2xx) Set alert latch Guenter Roeck
2024-08-30 12:29 ` Tzung-Bi Shih
2024-08-30 1:05 ` [PATCH v2 10/14] hwmon: (ina2xx) Move ina2xx_get_value() Guenter Roeck
2024-08-30 1:05 ` [PATCH v2 11/14] hwmon: (ina2xx) Convert to use with_info hwmon API Guenter Roeck
2024-08-30 12:30 ` Tzung-Bi Shih [this message]
2024-08-30 15:32 ` Guenter Roeck
2024-08-30 1:05 ` [PATCH v2 12/14] hwmon: (ina2xx) Pass register to alert limit write functions Guenter Roeck
2024-08-30 12:30 ` Tzung-Bi Shih
2024-08-30 1:05 ` [PATCH v2 13/14] hwmon: (ina2xx) Add support for current limits Guenter Roeck
2024-08-30 12:30 ` Tzung-Bi Shih
2024-08-30 1:05 ` [PATCH v2 14/14] hwmon: (ina2xx) Use shunt voltage to calculate current Guenter Roeck
2024-08-30 12:30 ` Tzung-Bi Shih
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=ZtG7VaILKoZUHTkC@tzungbi-laptop \
--to=tzungbi@kernel.org \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux@roeck-us.net \
/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