leds: various: use dev_of_node(dev) instead of dev->of_node
authorMarek Behún <marek.behun@nic.cz>
Thu, 17 Sep 2020 22:32:54 +0000 (00:32 +0200)
committerPavel Machek <pavel@ucw.cz>
Sat, 26 Sep 2020 19:56:39 +0000 (21:56 +0200)
The dev_of_node function should be preferred.

Signed-off-by: Marek Behún <marek.behun@nic.cz>
Cc: Orson Zhai <orsonzhai@gmail.com>
Cc: Baolin Wang <baolin.wang7@gmail.com>
Cc: Chunyan Zhang <zhang.lyra@gmail.com>
Cc: Sean Wang <sean.wang@mediatek.com>
Cc: Matthias Brugger <matthias.bgg@gmail.com>
Cc: Riku Voipio <riku.voipio@iki.fi>
Signed-off-by: Pavel Machek <pavel@ucw.cz>
28 files changed:
drivers/leds/leds-88pm860x.c
drivers/leds/leds-aat1290.c
drivers/leds/leds-an30259a.c
drivers/leds/leds-aw2013.c
drivers/leds/leds-bcm6328.c
drivers/leds/leds-bcm6358.c
drivers/leds/leds-is31fl319x.c
drivers/leds/leds-is31fl32xx.c
drivers/leds/leds-ktd2692.c
drivers/leds/leds-lp5521.c
drivers/leds/leds-lp5523.c
drivers/leds/leds-lp5562.c
drivers/leds/leds-lp8501.c
drivers/leds/leds-lp8860.c
drivers/leds/leds-lt3593.c
drivers/leds/leds-max77693.c
drivers/leds/leds-mc13783.c
drivers/leds/leds-mt6323.c
drivers/leds/leds-netxbig.c
drivers/leds/leds-ns2.c
drivers/leds/leds-pca9532.c
drivers/leds/leds-pm8058.c
drivers/leds/leds-sc27xx-bltc.c
drivers/leds/leds-spi-byte.c
drivers/leds/leds-syscon.c
drivers/leds/leds-tca6507.c
drivers/leds/leds-tlc591xx.c
drivers/leds/leds-turris-omnia.c

index 465c3755cf2e4a7844cc979f288d8538c56f41fa..2d1b3269e0f7f51027ed78f80242bf7d88fc587d 100644 (file)
@@ -118,9 +118,9 @@ static int pm860x_led_dt_init(struct platform_device *pdev,
        struct device_node *nproot, *np;
        int iset = 0;
 
-       if (!pdev->dev.parent->of_node)
+       if (!dev_of_node(pdev->dev.parent))
                return -ENODEV;
-       nproot = of_get_child_by_name(pdev->dev.parent->of_node, "leds");
+       nproot = of_get_child_by_name(dev_of_node(pdev->dev.parent), "leds");
        if (!nproot) {
                dev_err(&pdev->dev, "failed to find leds node\n");
                return -ENODEV;
index 5a0fe7b7b8bc7ed03bd519b60970e9386ea728f6..589484b22c796c81abc91c01dc7f8790dd3aa345 100644 (file)
@@ -248,7 +248,7 @@ static int aat1290_led_parse_dt(struct aat1290_led *led,
        }
 #endif
 
-       child_node = of_get_next_available_child(dev->of_node, NULL);
+       child_node = of_get_next_available_child(dev_of_node(dev), NULL);
        if (!child_node) {
                dev_err(dev, "No DT child node found for connected LED.\n");
                return -EINVAL;
index 82350a28a56445468cb35d2b94e4be75bf7b0e25..8ec23ccd02d699089b196bb10c95b6aff4be909c 100644 (file)
@@ -202,7 +202,7 @@ error:
 static int an30259a_dt_init(struct i2c_client *client,
                            struct an30259a *chip)
 {
-       struct device_node *np = client->dev.of_node, *child;
+       struct device_node *np = dev_of_node(&client->dev), *child;
        int count, ret;
        int i = 0;
        const char *str;
index d709cc1f949e36ec3b23697582651d4eb6a3a44e..3aeed4f68a8a35a27eb521677fd142c77f23e533 100644 (file)
@@ -261,7 +261,7 @@ out:
 
 static int aw2013_probe_dt(struct aw2013 *chip)
 {
-       struct device_node *np = chip->client->dev.of_node, *child;
+       struct device_node *np = dev_of_node(&chip->client->dev), *child;
        int count, ret = 0, i = 0;
        struct aw2013_led *led;
 
index bad7efb751120631516ce86f483b9ec891cd013f..73b385d03c0ee7bfedc11d82530445dcebfeed00 100644 (file)
@@ -395,7 +395,7 @@ static int bcm6328_led(struct device *dev, struct device_node *nc, u32 reg,
 static int bcm6328_leds_probe(struct platform_device *pdev)
 {
        struct device *dev = &pdev->dev;
-       struct device_node *np = pdev->dev.of_node;
+       struct device_node *np = dev_of_node(&pdev->dev);
        struct device_node *child;
        void __iomem *mem;
        spinlock_t *lock; /* memory lock */
index 94fefd456ba076aa61031f4cf95f0442d5ee7139..2f71f4b5b72eefd6139212637ab08fbcb15f87c6 100644 (file)
@@ -149,7 +149,7 @@ static int bcm6358_led(struct device *dev, struct device_node *nc, u32 reg,
 static int bcm6358_leds_probe(struct platform_device *pdev)
 {
        struct device *dev = &pdev->dev;
-       struct device_node *np = pdev->dev.of_node;
+       struct device_node *np = dev_of_node(&pdev->dev);
        struct device_node *child;
        void __iomem *mem;
        spinlock_t *lock; /* memory lock */
index b039ffa33559ca975ce4cdf42879d7f2d7732767..e6d185ad0b7e627169e03b1db8056cb25caf59d4 100644 (file)
@@ -202,7 +202,7 @@ static int is31fl319x_parse_child_dt(const struct device *dev,
 static int is31fl319x_parse_dt(struct device *dev,
                               struct is31fl319x_chip *is31)
 {
-       struct device_node *np = dev->of_node, *child;
+       struct device_node *np = dev_of_node(dev), *child;
        int count;
        int ret;
 
index acf51e17e8df6aa4785a7ee2332c4791ac40c0d4..82bbf0290ff9d11ab06b9f4186fc1586defe08cc 100644 (file)
@@ -372,7 +372,7 @@ static int is31fl32xx_parse_dt(struct device *dev,
        struct device_node *child;
        int ret = 0;
 
-       for_each_child_of_node(dev->of_node, child) {
+       for_each_child_of_node(dev_of_node(dev), child) {
                struct is31fl32xx_led_data *led_data =
                        &priv->leds[priv->num_leds];
                const struct is31fl32xx_led_data *other_led_data;
@@ -435,7 +435,7 @@ static int is31fl32xx_probe(struct i2c_client *client,
 
        cdef = device_get_match_data(dev);
 
-       count = of_get_child_count(dev->of_node);
+       count = of_get_child_count(dev_of_node(dev));
        if (!count)
                return -EINVAL;
 
index 670efee9b1317affa4eb80d2c4f8866223e96cdf..632f10db4b3ff5509663af940f8df43f7a11f371 100644 (file)
@@ -259,11 +259,11 @@ static void ktd2692_setup(struct ktd2692_context *led)
 static int ktd2692_parse_dt(struct ktd2692_context *led, struct device *dev,
                            struct ktd2692_led_config_data *cfg)
 {
-       struct device_node *np = dev->of_node;
+       struct device_node *np = dev_of_node(dev);
        struct device_node *child_node;
        int ret;
 
-       if (!dev->of_node)
+       if (!dev_of_node(dev))
                return -ENXIO;
 
        led->ctrl_gpio = devm_gpiod_get(dev, "ctrl", GPIOD_ASIS);
index ef8c3bfa8f3c4a8581c94fd7bd09623f69a7eeb3..a9e7507c998cd797b7717e3a60061eef270cbfbe 100644 (file)
@@ -523,7 +523,7 @@ static int lp5521_probe(struct i2c_client *client,
        struct lp55xx_chip *chip;
        struct lp55xx_led *led;
        struct lp55xx_platform_data *pdata = dev_get_platdata(&client->dev);
-       struct device_node *np = client->dev.of_node;
+       struct device_node *np = dev_of_node(&client->dev);
 
        chip = devm_kzalloc(&client->dev, sizeof(*chip), GFP_KERNEL);
        if (!chip)
index f55d97258d5e7824346829819f01f5dd31871ceb..fc433e63b1dc0319966fb52493f9c6d99d218368 100644 (file)
@@ -891,7 +891,7 @@ static int lp5523_probe(struct i2c_client *client,
        struct lp55xx_chip *chip;
        struct lp55xx_led *led;
        struct lp55xx_platform_data *pdata = dev_get_platdata(&client->dev);
-       struct device_node *np = client->dev.of_node;
+       struct device_node *np = dev_of_node(&client->dev);
 
        chip = devm_kzalloc(&client->dev, sizeof(*chip), GFP_KERNEL);
        if (!chip)
index 7ecdd199d7efc8d979fd69845ab6478344c570af..31c14016d2896e7ea3597ff75818447c44e6724f 100644 (file)
@@ -518,7 +518,7 @@ static int lp5562_probe(struct i2c_client *client,
        struct lp55xx_chip *chip;
        struct lp55xx_led *led;
        struct lp55xx_platform_data *pdata = dev_get_platdata(&client->dev);
-       struct device_node *np = client->dev.of_node;
+       struct device_node *np = dev_of_node(&client->dev);
 
        chip = devm_kzalloc(&client->dev, sizeof(*chip), GFP_KERNEL);
        if (!chip)
index ac2c31db4a65cdc845782f004e69978980189b97..2d2fda2ab10461e56ed77c254e1dc62d71cb03c1 100644 (file)
@@ -306,7 +306,7 @@ static int lp8501_probe(struct i2c_client *client,
        struct lp55xx_chip *chip;
        struct lp55xx_led *led;
        struct lp55xx_platform_data *pdata = dev_get_platdata(&client->dev);
-       struct device_node *np = client->dev.of_node;
+       struct device_node *np = dev_of_node(&client->dev);
 
        chip = devm_kzalloc(&client->dev, sizeof(*chip), GFP_KERNEL);
        if (!chip)
index ac2f5d6272dc0e7389bed88b76a1d2e943590576..e9b16f3358d6fa6f7fa1fab1316de4461bf97b0a 100644 (file)
@@ -380,7 +380,7 @@ static int lp8860_probe(struct i2c_client *client,
 {
        int ret;
        struct lp8860_led *led;
-       struct device_node *np = client->dev.of_node;
+       struct device_node *np = dev_of_node(&client->dev);
        struct device_node *child_node;
        struct led_init_data init_data = {};
 
index 9079850e6ea44990b07cfd23cbbd55a0404d91a1..c2d7ffebacc56a28dc27c9d5cf1ee7a7d59a6705 100644 (file)
@@ -68,7 +68,7 @@ static int lt3593_led_probe(struct platform_device *pdev)
        struct led_init_data init_data = {};
        const char *tmp;
 
-       if (!dev->of_node)
+       if (!dev_of_node(dev))
                return -ENODEV;
 
        led_data = devm_kzalloc(dev, sizeof(*led_data), GFP_KERNEL);
index fec56090c2ba3d8b38d232237a985c7cb509451b..5c1faeb55a314225847a4d381b8bf4accfe50d3a 100644 (file)
@@ -599,7 +599,7 @@ static int max77693_led_parse_dt(struct max77693_led_device *led,
 {
        struct device *dev = &led->pdev->dev;
        struct max77693_sub_led *sub_leds = led->sub_leds;
-       struct device_node *node = dev->of_node, *child_node;
+       struct device_node *node = dev_of_node(dev), *child_node;
        struct property *prop;
        u32 led_sources[2];
        int i, ret, fled_id;
index 5cd810c545f3ed0d02ec2c842f10a18e37c19c1b..ee37f4a2d65b4a24deab3ca66788e2949e747b29 100644 (file)
@@ -121,7 +121,7 @@ static struct mc13xxx_leds_platform_data __init *mc13xxx_led_probe_dt(
        if (!pdata)
                return ERR_PTR(-ENOMEM);
 
-       parent = of_get_child_by_name(dev->parent->of_node, "leds");
+       parent = of_get_child_by_name(dev_of_node(dev->parent), "leds");
        if (!parent)
                goto out_node_put;
 
@@ -192,7 +192,7 @@ static int __init mc13xxx_led_probe(struct platform_device *pdev)
        leds->master = mcdev;
        platform_set_drvdata(pdev, leds);
 
-       if (dev->parent->of_node) {
+       if (dev_of_node(dev->parent)) {
                pdata = mc13xxx_led_probe_dt(pdev);
                if (IS_ERR(pdata))
                        return PTR_ERR(pdata);
index 7b240771e45bbb6cd996302d19ab0264ee1d4e1e..88deec9d0ef4f815a635f535e636c213c7be9f43 100644 (file)
@@ -369,7 +369,7 @@ static int mt6323_led_set_dt_default(struct led_classdev *cdev,
 static int mt6323_led_probe(struct platform_device *pdev)
 {
        struct device *dev = &pdev->dev;
-       struct device_node *np = pdev->dev.of_node;
+       struct device_node *np = dev_of_node(&pdev->dev);
        struct device_node *child;
        struct mt6397_chip *hw = dev_get_drvdata(pdev->dev.parent);
        struct mt6323_leds *leds;
index ceceeb6a0e966c5ad7b7ec4b55f250fb65d1f32d..9a3b2d15764d297144cf0457c28ab244a057031d 100644 (file)
@@ -419,7 +419,7 @@ static int netxbig_gpio_ext_get(struct device *dev,
 static int netxbig_leds_get_of_pdata(struct device *dev,
                                     struct netxbig_led_platform_data *pdata)
 {
-       struct device_node *np = dev->of_node;
+       struct device_node *np = dev_of_node(dev);
        struct device_node *gpio_ext_np;
        struct platform_device *gpio_ext_pdev;
        struct device *gpio_ext_dev;
index bd806e7c8017bc9844e654a060ba4c5b66436014..9cbd2d7251af9d7c205acfac31073341a9e90021 100644 (file)
@@ -246,7 +246,7 @@ static void delete_ns2_led(struct ns2_led_data *led_dat)
 static int
 ns2_leds_get_of_pdata(struct device *dev, struct ns2_led_platform_data *pdata)
 {
-       struct device_node *np = dev->of_node;
+       struct device_node *np = dev_of_node(dev);
        struct device_node *child;
        struct ns2_led *led, *leds;
        int ret, num_leds = 0;
index 7d515d5e57bd0a4b76c738dd71e803bcb4f94ea6..b1ae34e509588ad059ddd463510f4041b4319c9a 100644 (file)
@@ -507,7 +507,7 @@ static int pca9532_probe(struct i2c_client *client,
        struct pca9532_data *data = i2c_get_clientdata(client);
        struct pca9532_platform_data *pca9532_pdata =
                        dev_get_platdata(&client->dev);
-       struct device_node *np = client->dev.of_node;
+       struct device_node *np = dev_of_node(&client->dev);
 
        if (!pca9532_pdata) {
                if (np) {
index 7869ccdf70ce643ce283b33ab4c6aeffcbd7c4a5..69a7f7e63ea76e4cae1e5f29c9d490ac53d320e8 100644 (file)
@@ -88,7 +88,7 @@ static enum led_brightness pm8058_led_get(struct led_classdev *cled)
 static int pm8058_led_probe(struct platform_device *pdev)
 {
        struct pm8058_led *led;
-       struct device_node *np = pdev->dev.of_node;
+       struct device_node *np = dev_of_node(&pdev->dev);
        int ret;
        struct regmap *map;
        const char *state;
index 0ede87420bfc7f2470b60d255ed80c029d98da5a..f8fe09ecd0d181ec22726aea7451c9cfff78a81d 100644 (file)
@@ -276,7 +276,7 @@ static int sc27xx_led_register(struct device *dev, struct sc27xx_led_priv *priv)
 static int sc27xx_led_probe(struct platform_device *pdev)
 {
        struct device *dev = &pdev->dev;
-       struct device_node *np = dev->of_node, *child;
+       struct device_node *np = dev_of_node(dev), *child;
        struct sc27xx_led_priv *priv;
        u32 base, count, reg;
        int err;
index 9632eb84f8de1d0e473d775dec17fda53d5d541a..ecfd349fa53beb3076ab6acade121122dbba842a 100644 (file)
@@ -87,11 +87,11 @@ static int spi_byte_probe(struct spi_device *spi)
        const char *state;
        int ret;
 
-       if (of_get_child_count(dev->of_node) != 1) {
+       if (of_get_child_count(dev_of_node(dev)) != 1) {
                dev_err(dev, "Device must have exactly one LED sub-node.");
                return -EINVAL;
        }
-       child = of_get_next_child(dev->of_node, NULL);
+       child = of_get_next_child(dev_of_node(dev), NULL);
 
        led = devm_kzalloc(dev, sizeof(*led), GFP_KERNEL);
        if (!led)
index b58f3cafe16f4bf8324c21b6abf49025ea56d8f5..d7230da81543071d2d8f6c8269287741da8113b4 100644 (file)
@@ -56,7 +56,7 @@ static void syscon_led_set(struct led_classdev *led_cdev,
 static int syscon_led_probe(struct platform_device *pdev)
 {
        struct device *dev = &pdev->dev;
-       struct device_node *np = dev->of_node;
+       struct device_node *np = dev_of_node(dev);
        struct device *parent;
        struct regmap *map;
        struct syscon_led *sled;
@@ -68,7 +68,7 @@ static int syscon_led_probe(struct platform_device *pdev)
                dev_err(dev, "no parent for syscon LED\n");
                return -ENODEV;
        }
-       map = syscon_node_to_regmap(parent->of_node);
+       map = syscon_node_to_regmap(dev_of_node(parent));
        if (IS_ERR(map)) {
                dev_err(dev, "no regmap for syscon LED parent\n");
                return PTR_ERR(map);
index 1128ac75443c0489d1639eaeb04c058902321aa5..d44b64af6d6e7486e5b702d519627468e7ffafda 100644 (file)
@@ -656,7 +656,7 @@ static int tca6507_probe_gpios(struct i2c_client *client,
        tca->gpio.set = tca6507_gpio_set_value;
        tca->gpio.parent = &client->dev;
 #ifdef CONFIG_OF_GPIO
-       tca->gpio.of_node = of_node_get(client->dev.of_node);
+       tca->gpio.of_node = of_node_get(dev_of_node(&client->dev));
 #endif
        err = gpiochip_add_data(&tca->gpio, tca);
        if (err) {
@@ -689,7 +689,7 @@ static void tca6507_remove_gpio(struct tca6507_chip *tca)
 static struct tca6507_platform_data *
 tca6507_led_dt_init(struct i2c_client *client)
 {
-       struct device_node *np = client->dev.of_node, *child;
+       struct device_node *np = dev_of_node(&client->dev), *child;
        struct tca6507_platform_data *pdata;
        struct led_info *tca_leds;
        int count;
index aeedf1aa62976c559234c3569b8cbcb57539a94f..f4d5785f0068f937044e53cfb4e6141e0ba8dd3b 100644 (file)
@@ -148,7 +148,7 @@ static int
 tlc591xx_probe(struct i2c_client *client,
               const struct i2c_device_id *id)
 {
-       struct device_node *np = client->dev.of_node, *child;
+       struct device_node *np = dev_of_node(&client->dev), *child;
        struct device *dev = &client->dev;
        const struct tlc591xx *tlc591xx;
        struct tlc591xx_priv *priv;
index bb23d8e166144b80a3cf16e82d4b82da05078355..ea7da8517220d5ce40e915534d73742d85e00961 100644 (file)
@@ -210,7 +210,7 @@ static int omnia_leds_probe(struct i2c_client *client,
                            const struct i2c_device_id *id)
 {
        struct device *dev = &client->dev;
-       struct device_node *np = dev->of_node, *child;
+       struct device_node *np = dev_of_node(dev), *child;
        struct omnia_leds *leds;
        struct omnia_led *led;
        int ret, count;