History log of /linux-master/drivers/hwmon/ltc2992.c
Revision Date Author Comments
# d8a66f36 30-Apr-2024 Uwe Kleine-König <u.kleine-koenig@pengutronix.de>

hwmon: Drop explicit initialization of struct i2c_device_id::driver_data to 0

These drivers don't use the driver_data member of struct i2c_device_id,
so don't explicitly initialize this member.

This prepares putting driver_data in an anonymous union which requires
either no initialization or named designators. But it's also a nice
cleanup on its own.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Link: https://lore.kernel.org/r/20240430085654.1028864-2-u.kleine-koenig@pengutronix.de
Signed-off-by: Guenter Roeck <linux@roeck-us.net>


# 10b02902 11-Oct-2023 Antoniu Miclaus <antoniu.miclaus@analog.com>

hwmon: (ltc2992) Avoid division by zero

Do not allow setting shunt resistor to 0. This results in a division by
zero when performing current value computations based on input voltages
and connected resistor values.

Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com>
Link: https://lore.kernel.org/r/20231011135754.13508-1-antoniu.miclaus@analog.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>


# 1975d167 05-May-2023 Uwe Kleine-König <u.kleine-koenig@pengutronix.de>

hwmon: Switch i2c drivers back to use .probe()

After commit b8a1a4cd5a98 ("i2c: Provide a temporary .probe_new()
call-back type"), all drivers being converted to .probe_new() and then
03c835f498b5 ("i2c: Switch .probe() to not take an id parameter") convert
back to (the new) .probe() to be able to eventually drop .probe_new() from
struct i2c_driver.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Link: https://lore.kernel.org/r/20230505131718.1210071-1-u.kleine-koenig@pengutronix.de
[groeck: Added missing change in pmbus/acbel-fsg032.c]
Signed-off-by: Guenter Roeck <linux@roeck-us.net>


# 8cbafa6e 06-Apr-2023 Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>

hwmon: ltc2992: constify pointers to hwmon_channel_info

Statically allocated array of pointed to hwmon_channel_info can be made
const for safety.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>


# ab007093 14-Mar-2023 Lars-Peter Clausen <lars@metafoo.de>

hwmon: (ltc2992) Set `can_sleep` flag for GPIO chip

The ltc2992 drivers uses a mutex and I2C bus access in its GPIO chip `set`
and `get` implementation. This means these functions can sleep and the GPIO
chip should set the `can_sleep` property to true.

This will ensure that a warning is printed when trying to set or get the
GPIO value from a context that potentially can't sleep.

Fixes: 9ca26df1ba25 ("hwmon: (ltc2992) Add support for GPIOs.")
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Link: https://lore.kernel.org/r/20230314093146.2443845-2-lars@metafoo.de
Signed-off-by: Guenter Roeck <linux@roeck-us.net>


# deeab9ea 11-Oct-2022 Stephen Kitt <steve@sk2.org>

hwmon: use simple i2c probe

All these drivers have an i2c probe function which doesn't use the
"struct i2c_device_id *id" parameter, so they can trivially be
converted to the "probe_new" style of probe with a single argument.

This is part of an ongoing transition to single-argument i2c probe
functions. Old-style probe functions involve a call to i2c_match_id:
in drivers/i2c/i2c-core-base.c,

/*
* When there are no more users of probe(),
* rename probe_new to probe.
*/
if (driver->probe_new)
status = driver->probe_new(client);
else if (driver->probe)
status = driver->probe(client,
i2c_match_id(driver->id_table, client));
else
status = -EINVAL;

Drivers which don't need the second parameter can be declared using
probe_new instead, avoiding the call to i2c_match_id. Drivers which do
can still be converted to probe_new-style, calling i2c_match_id
themselves (as is done currently for of_match_id).

This change was done using the following Coccinelle script, and fixed
up for whitespace changes:

@ rule1 @
identifier fn;
identifier client, id;
@@

- static int fn(struct i2c_client *client, const struct i2c_device_id *id)
+ static int fn(struct i2c_client *client)
{
...when != id
}

@ rule2 depends on rule1 @
identifier rule1.fn;
identifier driver;
@@

struct i2c_driver driver = {
- .probe
+ .probe_new
=
(
fn
|
- &fn
+ fn
)
,
};

Signed-off-by: Stephen Kitt <steve@sk2.org>
Link: https://lore.kernel.org/r/20221011143309.3141267-1-steve@sk2.org
Signed-off-by: Guenter Roeck <linux@roeck-us.net>


# c2e81343 12-May-2022 Guenter Roeck <linux@roeck-us.net>

hwmon: (ltc2992) Use HWMON_CHANNEL_INFO macro

The HWMON_CHANNEL_INFO macro simplifies the code, reduces the likelihood
of errors, and makes the code easier to read.

The conversion was done automatically with coccinelle. The semantic patch
used to make this change is as follows.

@s@
identifier i,j,ty;
@@

-struct hwmon_channel_info j = {
- .type = ty,
- .config = i,
-};

@r@
initializer list elements;
identifier s.i;
@@

-u32 i[] = {
- elements,
- 0
-};

@script:ocaml t@
ty << s.ty;
elements << r.elements;
shorter;
elems;
@@

shorter :=
make_ident (List.hd(List.rev (Str.split (Str.regexp "_") ty)));
elems :=
make_ident
(String.concat ","
(List.map (fun x -> Printf.sprintf "\n\t\t\t %s" x)
(Str.split (Str.regexp " , ") elements)))

@@
identifier s.j,t.shorter;
identifier t.elems;
@@

- &j
+ HWMON_CHANNEL_INFO(shorter,elems)

This patch does not introduce functional changes. Many thanks to
Julia Lawall for providing the coccinelle script.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>


# 749443de 14-Aug-2021 Yury Norov <yury.norov@gmail.com>

Replace for_each_*_bit_from() with for_each_*_bit() where appropriate

A couple of kernel functions call for_each_*_bit_from() with start
bit equal to 0. Replace them with for_each_*_bit().

No functional changes, but might improve on readability.

Signed-off-by: Yury Norov <yury.norov@gmail.com>
Tested-by: Wolfram Sang <wsa+renesas@sang-engineering.com>


# 8370e5b0 10-May-2021 Andy Shevchenko <andy.shevchenko@gmail.com>

hwmon: (ltc2992) Put fwnode in error case during ->probe()

In each iteration fwnode_for_each_available_child_node() bumps a reference
counting of a loop variable followed by dropping in on a next iteration,

Since in error case the loop is broken, we have to drop a reference count
by ourselves. Do it for port_fwnode in error case during ->probe().

Fixes: b0bd407e94b0 ("hwmon: (ltc2992) Add support")
Cc: Alexandru Tachici <alexandru.tachici@analog.com>
Signed-off-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Link: https://lore.kernel.org/r/20210510100136.3303142-1-andy.shevchenko@gmail.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>


# e1d15969 07-Dec-2020 Colin Ian King <colin.king@canonical.com>

hwmon: (ltc2992) Fix less than zero comparisons with an unsigned integer

There are several occurrances of a less than zero error check on
a u32 unsigned integer. These will never be true. Fix this by making
reg_value a plain int.

Addresses-Coverity: ("Unsigned comparison against zero")
Fixes: e126370240e0 ("hwmon: (ltc2992) Add support")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Link: https://lore.kernel.org/r/20201207142410.168987-1-colin.king@canonical.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>


# 9ca26df1 03-Dec-2020 Alexandru Tachici <alexandru.tachici@analog.com>

hwmon: (ltc2992) Add support for GPIOs.

LTC2992 has 4 open-drain GPIOS. This patch exports to user
space the 4 GPIOs using the GPIO driver Linux API.

Signed-off-by: Alexandru Tachici <alexandru.tachici@analog.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>


# b0bd407e 03-Dec-2020 Alexandru Tachici <alexandru.tachici@analog.com>

hwmon: (ltc2992) Add support

LTC2992 is a rail-to-rail system monitor that
measures current, voltage, and power of two supplies.

Two ADCs simultaneously measure each supply’s current.
A third ADC monitors the input voltages and four
auxiliary external voltages.

Signed-off-by: Alexandru Tachici <alexandru.tachici@analog.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>