* [PATCH v1 1/2] gpiolib: of: Drop redundant check in of_mm_gpiochip_remove()
@ 2022-11-09 15:07 Andy Shevchenko
2022-11-09 15:07 ` [PATCH v1 2/2] gpiolib: Get rid of not used of_node member Andy Shevchenko
2022-11-09 15:14 ` [PATCH v1 1/2] gpiolib: of: Drop redundant check in of_mm_gpiochip_remove() Andy Shevchenko
0 siblings, 2 replies; 4+ messages in thread
From: Andy Shevchenko @ 2022-11-09 15:07 UTC (permalink / raw)
To: Andy Shevchenko, Raul E Rangel, Bartosz Golaszewski,
Dmitry Torokhov, linux-gpio, linux-acpi, linux-kernel
Cc: Mika Westerberg, Linus Walleij
The callers never call the function with invalid pointer.
Moreover, compiler quite likely dropped that check anyway
because we use that pointer before the check.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/gpio/gpiolib-of.c | 3 ---
1 file changed, 3 deletions(-)
diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c
index feeb9e8e846d..83997434215e 100644
--- a/drivers/gpio/gpiolib-of.c
+++ b/drivers/gpio/gpiolib-of.c
@@ -963,9 +963,6 @@ void of_mm_gpiochip_remove(struct of_mm_gpio_chip *mm_gc)
{
struct gpio_chip *gc = &mm_gc->gc;
- if (!mm_gc)
- return;
-
gpiochip_remove(gc);
iounmap(mm_gc->regs);
kfree(gc->label);
--
2.35.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH v1 2/2] gpiolib: Get rid of not used of_node member
2022-11-09 15:07 [PATCH v1 1/2] gpiolib: of: Drop redundant check in of_mm_gpiochip_remove() Andy Shevchenko
@ 2022-11-09 15:07 ` Andy Shevchenko
2022-11-09 15:15 ` Andy Shevchenko
2022-11-09 15:14 ` [PATCH v1 1/2] gpiolib: of: Drop redundant check in of_mm_gpiochip_remove() Andy Shevchenko
1 sibling, 1 reply; 4+ messages in thread
From: Andy Shevchenko @ 2022-11-09 15:07 UTC (permalink / raw)
To: Andy Shevchenko, Raul E Rangel, Bartosz Golaszewski,
Dmitry Torokhov, linux-gpio, linux-acpi, linux-kernel
Cc: Mika Westerberg, Linus Walleij
All new drivers should use fwnode and / or parent to provide the
necessary information to the GPIO library.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/gpio/gpiolib-acpi.c | 10 ----------
drivers/gpio/gpiolib-acpi.h | 4 ----
drivers/gpio/gpiolib-of.c | 22 +++-------------------
drivers/gpio/gpiolib-of.h | 5 -----
drivers/gpio/gpiolib.c | 15 +--------------
include/linux/gpio/driver.h | 7 -------
6 files changed, 4 insertions(+), 59 deletions(-)
diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c
index a7d2358736fe..5c6ebb249863 100644
--- a/drivers/gpio/gpiolib-acpi.c
+++ b/drivers/gpio/gpiolib-acpi.c
@@ -1363,16 +1363,6 @@ void acpi_gpiochip_remove(struct gpio_chip *chip)
kfree(acpi_gpio);
}
-void acpi_gpio_dev_init(struct gpio_chip *gc, struct gpio_device *gdev)
-{
- /* Set default fwnode to parent's one if present */
- if (gc->parent)
- ACPI_COMPANION_SET(&gdev->dev, ACPI_COMPANION(gc->parent));
-
- if (gc->fwnode)
- device_set_node(&gdev->dev, gc->fwnode);
-}
-
static int acpi_gpio_package_count(const union acpi_object *obj)
{
const union acpi_object *element = obj->package.elements;
diff --git a/drivers/gpio/gpiolib-acpi.h b/drivers/gpio/gpiolib-acpi.h
index 1ac6816839db..a15495ef19ea 100644
--- a/drivers/gpio/gpiolib-acpi.h
+++ b/drivers/gpio/gpiolib-acpi.h
@@ -38,8 +38,6 @@ struct acpi_gpio_info {
void acpi_gpiochip_add(struct gpio_chip *chip);
void acpi_gpiochip_remove(struct gpio_chip *chip);
-void acpi_gpio_dev_init(struct gpio_chip *gc, struct gpio_device *gdev);
-
void acpi_gpiochip_request_interrupts(struct gpio_chip *chip);
void acpi_gpiochip_free_interrupts(struct gpio_chip *chip);
@@ -62,8 +60,6 @@ int acpi_gpio_count(struct device *dev, const char *con_id);
static inline void acpi_gpiochip_add(struct gpio_chip *chip) { }
static inline void acpi_gpiochip_remove(struct gpio_chip *chip) { }
-static inline void acpi_gpio_dev_init(struct gpio_chip *gc, struct gpio_device *gdev) { }
-
static inline void
acpi_gpiochip_request_interrupts(struct gpio_chip *chip) { }
diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c
index 83997434215e..e22d25d85c7e 100644
--- a/drivers/gpio/gpiolib-of.c
+++ b/drivers/gpio/gpiolib-of.c
@@ -669,7 +669,7 @@ static struct gpio_desc *of_parse_own_gpio(struct device_node *np,
u32 tmp;
int ret;
- chip_np = chip->of_node;
+ chip_np = to_of_node(chip->fwnode);
if (!chip_np)
return ERR_PTR(-EINVAL);
@@ -761,7 +761,7 @@ static int of_gpiochip_scan_gpios(struct gpio_chip *chip)
struct device_node *np;
int ret;
- for_each_available_child_of_node(chip->of_node, np) {
+ for_each_available_child_of_node(to_of_node(chip->fwnode), np) {
if (!of_property_read_bool(np, "gpio-hog"))
continue;
@@ -972,7 +972,7 @@ EXPORT_SYMBOL_GPL(of_mm_gpiochip_remove);
#ifdef CONFIG_PINCTRL
static int of_gpiochip_add_pin_range(struct gpio_chip *chip)
{
- struct device_node *np = chip->of_node;
+ struct device_node *np = to_of_node(chip->fwnode);
struct of_phandle_args pinspec;
struct pinctrl_dev *pctldev;
int index = 0, ret;
@@ -1094,19 +1094,3 @@ void of_gpiochip_remove(struct gpio_chip *chip)
{
fwnode_handle_put(chip->fwnode);
}
-
-void of_gpio_dev_init(struct gpio_chip *gc, struct gpio_device *gdev)
-{
- /* Set default OF node to parent's one if present */
- if (gc->parent)
- gdev->dev.of_node = gc->parent->of_node;
-
- if (gc->fwnode)
- gc->of_node = to_of_node(gc->fwnode);
-
- /* If the gpiochip has an assigned OF node this takes precedence */
- if (gc->of_node)
- gdev->dev.of_node = gc->of_node;
- else
- gc->of_node = gdev->dev.of_node;
-}
diff --git a/drivers/gpio/gpiolib-of.h b/drivers/gpio/gpiolib-of.h
index 2c32a332ede5..f128a7f45945 100644
--- a/drivers/gpio/gpiolib-of.h
+++ b/drivers/gpio/gpiolib-of.h
@@ -14,7 +14,6 @@ struct gpio_desc *of_find_gpio(struct device *dev,
int of_gpiochip_add(struct gpio_chip *gc);
void of_gpiochip_remove(struct gpio_chip *gc);
int of_gpio_get_count(struct device *dev, const char *con_id);
-void of_gpio_dev_init(struct gpio_chip *gc, struct gpio_device *gdev);
#else
static inline struct gpio_desc *of_find_gpio(struct device *dev,
const char *con_id,
@@ -29,10 +28,6 @@ static inline int of_gpio_get_count(struct device *dev, const char *con_id)
{
return 0;
}
-static inline void of_gpio_dev_init(struct gpio_chip *gc,
- struct gpio_device *gdev)
-{
-}
#endif /* CONFIG_OF_GPIO */
extern struct notifier_block gpio_of_notifier;
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 11fb7ec883e9..4032fbb6994c 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -646,7 +646,6 @@ int gpiochip_add_data_with_key(struct gpio_chip *gc, void *data,
struct lock_class_key *lock_key,
struct lock_class_key *request_key)
{
- struct fwnode_handle *fwnode = NULL;
struct gpio_device *gdev;
unsigned long flags;
int base = gc->base;
@@ -654,11 +653,6 @@ int gpiochip_add_data_with_key(struct gpio_chip *gc, void *data,
int ret = 0;
u32 ngpios;
- if (gc->fwnode)
- fwnode = gc->fwnode;
- else if (gc->parent)
- fwnode = dev_fwnode(gc->parent);
-
/*
* First: allocate and populate the internal stat container, and
* set up the struct device.
@@ -671,14 +665,7 @@ int gpiochip_add_data_with_key(struct gpio_chip *gc, void *data,
gdev->chip = gc;
gc->gpiodev = gdev;
- of_gpio_dev_init(gc, gdev);
- acpi_gpio_dev_init(gc, gdev);
-
- /*
- * Assign fwnode depending on the result of the previous calls,
- * if none of them succeed, assign it to the parent's one.
- */
- gdev->dev.fwnode = dev_fwnode(&gdev->dev) ?: fwnode;
+ device_set_node(&gdev->dev, gc->fwnode ?: dev_fwnode(gc->parent));
gdev->id = ida_alloc(&gpio_ida, GFP_KERNEL);
if (gdev->id < 0) {
diff --git a/include/linux/gpio/driver.h b/include/linux/gpio/driver.h
index 6aeea1071b1b..12c2c32d42d2 100644
--- a/include/linux/gpio/driver.h
+++ b/include/linux/gpio/driver.h
@@ -503,13 +503,6 @@ struct gpio_chip {
* the device tree automatically may have an OF translation
*/
- /**
- * @of_node:
- *
- * Pointer to a device tree node representing this GPIO controller.
- */
- struct device_node *of_node;
-
/**
* @of_gpio_n_cells:
*
--
2.35.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v1 1/2] gpiolib: of: Drop redundant check in of_mm_gpiochip_remove()
2022-11-09 15:07 [PATCH v1 1/2] gpiolib: of: Drop redundant check in of_mm_gpiochip_remove() Andy Shevchenko
2022-11-09 15:07 ` [PATCH v1 2/2] gpiolib: Get rid of not used of_node member Andy Shevchenko
@ 2022-11-09 15:14 ` Andy Shevchenko
1 sibling, 0 replies; 4+ messages in thread
From: Andy Shevchenko @ 2022-11-09 15:14 UTC (permalink / raw)
To: Raul E Rangel, Bartosz Golaszewski, Dmitry Torokhov, linux-gpio,
linux-acpi, linux-kernel
Cc: Mika Westerberg, Linus Walleij
On Wed, Nov 09, 2022 at 05:07:05PM +0200, Andy Shevchenko wrote:
> The callers never call the function with invalid pointer.
> Moreover, compiler quite likely dropped that check anyway
> because we use that pointer before the check.
Please, ignore this series, it was wrong offset to send the patches from.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v1 2/2] gpiolib: Get rid of not used of_node member
2022-11-09 15:07 ` [PATCH v1 2/2] gpiolib: Get rid of not used of_node member Andy Shevchenko
@ 2022-11-09 15:15 ` Andy Shevchenko
0 siblings, 0 replies; 4+ messages in thread
From: Andy Shevchenko @ 2022-11-09 15:15 UTC (permalink / raw)
To: Raul E Rangel, Bartosz Golaszewski, Dmitry Torokhov, linux-gpio,
linux-acpi, linux-kernel
Cc: Mika Westerberg, Linus Walleij
On Wed, Nov 09, 2022 at 05:07:06PM +0200, Andy Shevchenko wrote:
> All new drivers should use fwnode and / or parent to provide the
> necessary information to the GPIO library.
Please, ignore this series, it was wrong offset to send the patches from.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-11-09 15:15 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-11-09 15:07 [PATCH v1 1/2] gpiolib: of: Drop redundant check in of_mm_gpiochip_remove() Andy Shevchenko
2022-11-09 15:07 ` [PATCH v1 2/2] gpiolib: Get rid of not used of_node member Andy Shevchenko
2022-11-09 15:15 ` Andy Shevchenko
2022-11-09 15:14 ` [PATCH v1 1/2] gpiolib: of: Drop redundant check in of_mm_gpiochip_remove() Andy Shevchenko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox