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 465c375..2d1b326 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 5a0fe7b..589484b 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 82350a2..8ec23cc 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 d709cc1..3aeed4f 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 bad7efb..73b385d 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 94fefd4..2f71f4b 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 b039ffa..e6d185a 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 acf51e1..82bbf02 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 670efee..632f10d 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 ef8c3bf..a9e7507 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 f55d972..fc433e6 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 7ecdd19..31c1401 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 ac2c31d..2d2fda2 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 ac2f5d6..e9b16f3 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 9079850..c2d7ffe 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 fec5609..5c1faeb 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 5cd810c..ee37f4a 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 7b24077..88deec9 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 ceceeb6..9a3b2d1 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 bd806e7..9cbd2d7 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 7d515d5..b1ae34e 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 7869ccd..69a7f7e 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 0ede874..f8fe09e 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 9632eb8..ecfd349 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 b58f3ca..d7230da 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 1128ac7..d44b64a 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 aeedf1a..f4d5785 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 bb23d8e..ea7da85 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;