diff mbox series

hwmon/ltc2990: Generalise DT to fwnode support

Message ID 20190816090731.12809-1-max@enpas.org (mailing list archive)
State Superseded
Headers show
Series hwmon/ltc2990: Generalise DT to fwnode support | expand

Commit Message

Max Staudt Aug. 16, 2019, 9:07 a.m. UTC
ltc2990 will now use device_property_read_u32_array() instead of
of_property_read_u32_array() - allowing the use of software nodes
via fwnode_create_software_node().

This allows code using i2c_new_device() to specify a default
measurement mode for the LTC2990 via fwnode_create_software_node().

Signed-off-by: Max Staudt <max@enpas.org>
---
 drivers/hwmon/ltc2990.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

Geert Uytterhoeven Aug. 16, 2019, 11:07 a.m. UTC | #1
Hi Max,

On Fri, Aug 16, 2019 at 11:09 AM Max Staudt <max@enpas.org> wrote:
> ltc2990 will now use device_property_read_u32_array() instead of
> of_property_read_u32_array() - allowing the use of software nodes
> via fwnode_create_software_node().
>
> This allows code using i2c_new_device() to specify a default
> measurement mode for the LTC2990 via fwnode_create_software_node().
>
> Signed-off-by: Max Staudt <max@enpas.org>

Thanks for your patch!

Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org>

One minor nit: as the driver no longer uses any of_*() symbols, you can replace
#include <linux/of.h> by #include <linux/property.h>.

> --- a/drivers/hwmon/ltc2990.c
> +++ b/drivers/hwmon/ltc2990.c
> @@ -206,7 +206,6 @@ static int ltc2990_i2c_probe(struct i2c_client *i2c,
>         int ret;
>         struct device *hwmon_dev;
>         struct ltc2990_data *data;
> -       struct device_node *of_node = i2c->dev.of_node;
>
>         if (!i2c_check_functionality(i2c->adapter, I2C_FUNC_SMBUS_BYTE_DATA |
>                                      I2C_FUNC_SMBUS_WORD_DATA))
> @@ -218,9 +217,10 @@ static int ltc2990_i2c_probe(struct i2c_client *i2c,
>
>         data->i2c = i2c;
>
> -       if (of_node) {
> -               ret = of_property_read_u32_array(of_node, "lltc,meas-mode",
> -                                                data->mode, 2);
> +       if (dev_fwnode(&i2c->dev)) {
> +               ret = device_property_read_u32_array(&i2c->dev,
> +                                                    "lltc,meas-mode",
> +                                                    data->mode, 2);
>                 if (ret < 0)
>                         return ret;

Gr{oetje,eeting}s,

                        Geert
Max Staudt Aug. 16, 2019, 12:26 p.m. UTC | #2
On 08/16/2019 01:07 PM, Geert Uytterhoeven wrote:
> Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org>

Thank you!


> One minor nit: as the driver no longer uses any of_*() symbols, you can replace
> #include <linux/of.h> by #include <linux/property.h>.

I should have thought of that, sorry.

Another patch, or will you do it?


Max
Geert Uytterhoeven Aug. 16, 2019, 12:36 p.m. UTC | #3
Hi Max,

On Fri, Aug 16, 2019 at 2:25 PM Max Staudt <max@enpas.org> wrote:
> On 08/16/2019 01:07 PM, Geert Uytterhoeven wrote:
> > One minor nit: as the driver no longer uses any of_*() symbols, you can replace
> > #include <linux/of.h> by #include <linux/property.h>.
>
> I should have thought of that, sorry.
>
> Another patch, or will you do it?

As the patch won't go through my tree, I cannot, but the hwmon maintainer
might do.

Gr{oetje,eeting}s,

                        Geert
Max Staudt Aug. 16, 2019, 12:43 p.m. UTC | #4
On 08/16/2019 02:36 PM, Geert Uytterhoeven wrote:
> Hi Max,
> 
> On Fri, Aug 16, 2019 at 2:25 PM Max Staudt <max@enpas.org> wrote:
>> On 08/16/2019 01:07 PM, Geert Uytterhoeven wrote:
>>> One minor nit: as the driver no longer uses any of_*() symbols, you can replace
>>> #include <linux/of.h> by #include <linux/property.h>.
>>
>> I should have thought of that, sorry.
>>
>> Another patch, or will you do it?
> 
> As the patch won't go through my tree, I cannot, but the hwmon maintainer
> might do.

As I'll be fixing one of the I2C patches, I'll send an updated hwmon patch with it.


Thanks!
Max
Guenter Roeck Aug. 16, 2019, 1:24 p.m. UTC | #5
On 8/16/19 5:43 AM, Max Staudt wrote:
> On 08/16/2019 02:36 PM, Geert Uytterhoeven wrote:
>> Hi Max,
>>
>> On Fri, Aug 16, 2019 at 2:25 PM Max Staudt <max@enpas.org> wrote:
>>> On 08/16/2019 01:07 PM, Geert Uytterhoeven wrote:
>>>> One minor nit: as the driver no longer uses any of_*() symbols, you can replace
>>>> #include <linux/of.h> by #include <linux/property.h>.
>>>
>>> I should have thought of that, sorry.
>>>
>>> Another patch, or will you do it?
>>
>> As the patch won't go through my tree, I cannot, but the hwmon maintainer
>> might do.
> 
> As I'll be fixing one of the I2C patches, I'll send an updated hwmon patch with it.
> 

Ok, I'll wait for that patch.

Guenter
diff mbox series

Patch

diff --git a/drivers/hwmon/ltc2990.c b/drivers/hwmon/ltc2990.c
index f9431ad43..ff11189ea 100644
--- a/drivers/hwmon/ltc2990.c
+++ b/drivers/hwmon/ltc2990.c
@@ -206,7 +206,6 @@  static int ltc2990_i2c_probe(struct i2c_client *i2c,
 	int ret;
 	struct device *hwmon_dev;
 	struct ltc2990_data *data;
-	struct device_node *of_node = i2c->dev.of_node;
 
 	if (!i2c_check_functionality(i2c->adapter, I2C_FUNC_SMBUS_BYTE_DATA |
 				     I2C_FUNC_SMBUS_WORD_DATA))
@@ -218,9 +217,10 @@  static int ltc2990_i2c_probe(struct i2c_client *i2c,
 
 	data->i2c = i2c;
 
-	if (of_node) {
-		ret = of_property_read_u32_array(of_node, "lltc,meas-mode",
-						 data->mode, 2);
+	if (dev_fwnode(&i2c->dev)) {
+		ret = device_property_read_u32_array(&i2c->dev,
+						     "lltc,meas-mode",
+						     data->mode, 2);
 		if (ret < 0)
 			return ret;