Skip to contentSkip to conversation

platform/x86: intel: int0002_vgpio: use gpiochip_get_data

PATCH In review Rosen Penev 2 participants 2 messages Dec 3, 2024 – Dec 4, 2024 x86 platform drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 platform/x86: intel: int0002_vgpio: use gpiochip_get_data

Instead of using container_of, we can pass the pointer to gpiochip_add_data and use it.

---
 drivers/platform/x86/intel/int0002_vgpio.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/platform/x86/intel/int0002_vgpio.c +2 -2
index 0cc80603a8a9..7ce0774b3896 100644
@@ -102,7 +102,7 @@ static void int0002_irq_mask(struct irq_data *data)
 static int int0002_irq_set_wake(struct irq_data *data, unsigned int on)
 {
 	struct gpio_chip *chip = irq_data_get_irq_chip_data(data);
-	struct int0002_data *int0002 = container_of(chip, struct int0002_data, chip);
+	struct int0002_data *int0002 = gpiochip_get_data(chip);
 
 	/*
 	 * Applying of the wakeup flag to our parent IRQ is delayed till system
@@ -211,7 +211,7 @@ static int int0002_probe(struct platform_device *pdev)
 	girq->default_type = IRQ_TYPE_NONE;
 	girq->handler = handle_edge_irq;
 
-	ret = devm_gpiochip_add_data(dev, chip, NULL);
+	ret = devm_gpiochip_add_data(dev, chip, int0002);
 	if (ret) {
 		dev_err(dev, "Error adding gpio chip: %d\n", ret);
 		return ret;
Signature · 1 line
2.47.0
#1 lore raw

Hi Rosen,

Thank you for your patch.

Quoted 2 lines · Rosen Penev

Instead of using container_of, we can pass the pointer to gpiochip_add_data and use it.

Yes that is possible, but why? What is the advantage of doing this?

Given that the struct gpio_chip is the first member of struct int0002_data it is actually free as it turns into a no-op.

Where as gpiochip_get_data() is a non inline helper, so your replacing a no-op with a function call here I don't see how this makes things better?

Regards,

Hans

Quoted 31 lines
---
 drivers/platform/x86/intel/int0002_vgpio.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/platform/x86/intel/int0002_vgpio.c +2 -2
index 0cc80603a8a9..7ce0774b3896 100644
@@ -102,7 +102,7 @@ static void int0002_irq_mask(struct irq_data *data)
 static int int0002_irq_set_wake(struct irq_data *data, unsigned int on)
 {
 	struct gpio_chip *chip = irq_data_get_irq_chip_data(data);
-	struct int0002_data *int0002 = container_of(chip, struct int0002_data, chip);
+	struct int0002_data *int0002 = gpiochip_get_data(chip);
 
 	/*
 	 * Applying of the wakeup flag to our parent IRQ is delayed till system
@@ -211,7 +211,7 @@ static int int0002_probe(struct platform_device *pdev)
 	girq->default_type = IRQ_TYPE_NONE;
 	girq->handler = handle_edge_irq;
 
-	ret = devm_gpiochip_add_data(dev, chip, NULL);
+	ret = devm_gpiochip_add_data(dev, chip, int0002);
 	if (ret) {
 		dev_err(dev, "Error adding gpio chip: %d\n", ret);
 		return ret;