Skip to contentSkip to conversation

gpiolib: Get rid of not used of_node member

PATCH Superseded Andy Shevchenko 3 participants 4 messages Nov 3, 2022 – Nov 8, 2022

Subsystems (3)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Andy Shevchenko

author maintainer
#0 lore raw

PATCH v2 1/1 gpiolib: Get rid of not used of_node member

All new drivers should use fwnode and / or parent to provide the necessary information to the GPIO library.

---
v2: resent against latest Linux Next: expected not to fail now
(Linux Next has no more users of of_node member of gpio_chip)
v1: to test for now (using CIs and build bots) what is left uncoverted
(Expected to fail in some configurations!)

 drivers/gpio/gpiolib-acpi.c | 10 -------
 drivers/gpio/gpiolib-acpi.h |  4 ---
 drivers/gpio/gpiolib-of.c   | 60 ++++++++++++++-----------------------
 drivers/gpio/gpiolib-of.h   |  5 ----
 drivers/gpio/gpiolib.c      | 15 +---------
 include/linux/gpio/driver.h |  7 -----
 6 files changed, 24 insertions(+), 77 deletions(-)
drivers/gpio/gpiolib-acpi.c +0 -10
index 064ba5150fd4..251e76b3a1f5 100644
@@ -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;
drivers/gpio/gpiolib-acpi.h +0 -4
index 01e0cb480a00..be26751b7b69 100644
@@ -50,8 +50,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);
 
@@ -74,8 +72,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) { }
 
drivers/gpio/gpiolib-of.c +23 -37

160 lines not on this page · raw message

drivers/gpio/gpiolib-of.h +0 -5
index 1b5df39a952e..34415be0ac61 100644
@@ -24,7 +24,6 @@ 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);
 bool of_gpio_need_valid_mask(const struct gpio_chip *gc);
-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,
@@ -43,10 +42,6 @@ static inline bool of_gpio_need_valid_mask(const struct gpio_chip *gc)
 {
 	return false;
 }
-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;
drivers/gpio/gpiolib.c +1 -14
index e8faedca6b14..be3240b805b4 100644
@@ -594,7 +594,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;
@@ -602,11 +601,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.
@@ -619,14 +613,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) {
include/linux/gpio/driver.h +0 -7
index 2a44600b01f7..ee382712f066 100644
@@ -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:
 	 *

base-commit: 81214a573d19ae2fa5b528286ba23cd1cb17feec

Signature · 1 line
2.35.1
#1 lore raw
Quoted 6 lines · Andy Shevchenko

All new drivers should use fwnode and / or parent to provide the necessary information to the GPIO library.

---

This looks good to me. I'm thinking about just applying it and giving it a spin in next right away.

Linus: any objections?

Bartosz

author maintainer
#2 lore raw
Quoted 5 lines · Bartosz Golaszewski
Quoted 3 lines · Andy Shevchenko

All new drivers should use fwnode and / or parent to provide the necessary information to the GPIO library.

...

Quoted 1 line

This looks good to me.

Thank you!

Quoted 2 lines

I'm thinking about just applying it and giving
it a spin in next right away.

I would like to split it, one patch, btw, had been already sent separately.

So, if you are going for the Linux Next, I would like to ask for rebasing later on.

Also note, it requires patches that are in Linus' W. and mine trees. It will fail if you apply without those to be proceeded first.

Quoted 1 line

Linus: any objections?

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#3 lore raw
In reply to Bartosz Golaszewski
Quoted 6 lines · Bartosz Golaszewski
Quoted 4 lines · Andy Shevchenko

All new drivers should use fwnode and / or parent to provide the necessary information to the GPIO library.

Quoted 7 lines
Quoted 2 lines

---

This looks good to me. I'm thinking about just applying it and giving it a spin in next right away.

Linus: any objections?

No objections, sorry for taking some days to respond.

Separation of concerns is always good :)

Yours,
Linus Walleij