Skip to contentSkip to conversation

nvmem: fix a 'makes pointer from integer without a cast' build warning

PATCH In review Bartosz Golaszewski 3 participants 4 messages Jan 10, 2020 NVMEM framework

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 nvmem: fix a 'makes pointer from integer without a cast' build warning

From: Bartosz Golaszewski <[email protected]>

nvmem_register() returns a pointer, not a long int. Use ERR_CAST() to cast the struct gpio_desc pointer to struct nvmem_device.

Fixes 2a127da461a9 ("nvmem: add support for the write-protect pin")
---
 drivers/nvmem/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/nvmem/core.c +1 -1
index 3e1c94c4eee8..408ce702347e 100644
@@ -351,7 +351,7 @@ struct nvmem_device *nvmem_register(const struct nvmem_config *config)
 		nvmem->wp_gpio = gpiod_get_optional(config->dev, "wp",
 						    GPIOD_OUT_HIGH);
 	if (IS_ERR(nvmem->wp_gpio))
-		return PTR_ERR(nvmem->wp_gpio);
+		return ERR_CAST(nvmem->wp_gpio);
 
 
 	kref_init(&nvmem->refcnt);
Signature · 1 line
2.23.0
#1 lore raw

pt., 10 sty 2020 o 09:24 Bartosz Golaszewski <[email protected]> napisał(a):

Quoted 27 lines

From: Bartosz Golaszewski <[email protected]>

nvmem_register() returns a pointer, not a long int. Use ERR_CAST() to cast the struct gpio_desc pointer to struct nvmem_device.

Fixes 2a127da461a9 ("nvmem: add support for the write-protect pin")
---
 drivers/nvmem/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/nvmem/core.c +1 -2
index 3e1c94c4eee8..408ce702347e 100644
@@ -351,7 +351,7 @@ struct nvmem_device *nvmem_register(const struct nvmem_config *config)
                nvmem->wp_gpio = gpiod_get_optional(config->dev, "wp",
                                                    GPIOD_OUT_HIGH);
        if (IS_ERR(nvmem->wp_gpio))
-               return PTR_ERR(nvmem->wp_gpio);
+               return ERR_CAST(nvmem->wp_gpio);
 
 
        kref_init(&nvmem->refcnt);
--
Quoted 2 lines

2.23.0

Srinivas: this fixes a bug introduced in a patch I took through the at24 tree. With your ack I'll apply it as a follow-up.

Bart

Acked-by on v1 1/1
#2 lore raw
In reply to Bartosz Golaszewski

Thanks for the patch.

Quoted 9 lines · Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

nvmem_register() returns a pointer, not a long int. Use ERR_CAST() to cast the struct gpio_desc pointer to struct nvmem_device.

Fixes 2a127da461a9 ("nvmem: add support for the write-protect pin")

---

Quoted 17 lines
  drivers/nvmem/core.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/nvmem/core.c +1 -1
index 3e1c94c4eee8..408ce702347e 100644
@@ -351,7 +351,7 @@ struct nvmem_device *nvmem_register(const struct nvmem_config *config)
  		nvmem->wp_gpio = gpiod_get_optional(config->dev, "wp",
  						    GPIOD_OUT_HIGH);
  	if (IS_ERR(nvmem->wp_gpio))
-		return PTR_ERR(nvmem->wp_gpio);
+		return ERR_CAST(nvmem->wp_gpio);
 
 
  	kref_init(&nvmem->refcnt);
#3 lore raw

pt., 10 sty 2020 o 11:16 Srinivas Kandagatla
<[email protected]> napisał(a):

Quoted 9 lines

Thanks for the patch.

Quoted 5 lines · Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

nvmem_register() returns a pointer, not a long int. Use ERR_CAST() to cast the struct gpio_desc pointer to struct nvmem_device.

Quoted 7 lines
Quoted 4 lines
Fixes 2a127da461a9 ("nvmem: add support for the write-protect pin")

---

Thanks. This is rather uncontroversial, so applied right away.

Bart