* [PATCH] platform/x86: intel: int0002_vgpio: use gpiochip_get_data
@ 2024-12-03 23:35 Rosen Penev
2024-12-04 13:19 ` Hans de Goede
0 siblings, 1 reply; 2+ messages in thread
From: Rosen Penev @ 2024-12-03 23:35 UTC (permalink / raw)
To: platform-driver-x86; +Cc: Hans de Goede, Ilpo Järvinen, open list
Instead of using container_of, we can pass the pointer to
gpiochip_add_data and use it.
Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
drivers/platform/x86/intel/int0002_vgpio.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/platform/x86/intel/int0002_vgpio.c b/drivers/platform/x86/intel/int0002_vgpio.c
index 0cc80603a8a9..7ce0774b3896 100644
--- a/drivers/platform/x86/intel/int0002_vgpio.c
+++ b/drivers/platform/x86/intel/int0002_vgpio.c
@@ -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;
--
2.47.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] platform/x86: intel: int0002_vgpio: use gpiochip_get_data
2024-12-03 23:35 [PATCH] platform/x86: intel: int0002_vgpio: use gpiochip_get_data Rosen Penev
@ 2024-12-04 13:19 ` Hans de Goede
0 siblings, 0 replies; 2+ messages in thread
From: Hans de Goede @ 2024-12-04 13:19 UTC (permalink / raw)
To: Rosen Penev, platform-driver-x86; +Cc: Ilpo Järvinen, open list
Hi Rosen,
Thank you for your patch.
On 4-Dec-24 12:35 AM, Rosen Penev wrote:
> 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
>
> Signed-off-by: Rosen Penev <rosenp@gmail.com>
> ---
> drivers/platform/x86/intel/int0002_vgpio.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/platform/x86/intel/int0002_vgpio.c b/drivers/platform/x86/intel/int0002_vgpio.c
> index 0cc80603a8a9..7ce0774b3896 100644
> --- a/drivers/platform/x86/intel/int0002_vgpio.c
> +++ b/drivers/platform/x86/intel/int0002_vgpio.c
> @@ -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;
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-12-04 13:19 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-03 23:35 [PATCH] platform/x86: intel: int0002_vgpio: use gpiochip_get_data Rosen Penev
2024-12-04 13:19 ` Hans de Goede
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox