* [PATCH] gpio: virtio: simplify with cleanup API
@ 2026-12-01 5:21 Peng Fan
2026-12-01 5:26 ` sashiko-bot
` (3 more replies)
0 siblings, 4 replies; 9+ messages in thread
From: Peng Fan @ 2026-12-01 5:21 UTC (permalink / raw)
To: Viresh Kumar, Linus Walleij, Bartosz Golaszewski
Cc: linux-gpio, virtualization, Peng Fan
From: Peng Fan <peng.fan@nxp.com>
Use the scope-based cleanup API to replace the manual lock/unlock pairs
and the goto-based error paths:
- _virtio_gpio_req(): guard(mutex) holds the per-line lock over the
whole function and scoped_guard(mutex) covers the virtqueue add/kick
section, so the error paths can return directly instead of jumping
to an unlock label.
- virtio_gpio_irq_enable()/virtio_gpio_irq_disable(): scoped_guard()
around the disabled/masked/queue_pending updates.
- virtio_gpio_irq_mask()/virtio_gpio_irq_unmask() and ignore_irq():
guard(raw_spinlock) with direct returns, dropping the 'ignore'
variable and the unlock label.
- virtio_gpio_irq_bus_sync_unlock(): scoped_guard() with the
raw_spinlock_irqsave class.
No functional changes.
Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
drivers/gpio/gpio-virtio.c | 84 +++++++++++++++++++---------------------------
1 file changed, 34 insertions(+), 50 deletions(-)
diff --git a/drivers/gpio/gpio-virtio.c b/drivers/gpio/gpio-virtio.c
index 1bd532caffae..ff4b694db9da 100644
--- a/drivers/gpio/gpio-virtio.c
+++ b/drivers/gpio/gpio-virtio.c
@@ -9,6 +9,7 @@
* Viresh Kumar <viresh.kumar@linaro.org>
*/
+#include <linux/cleanup.h>
#include <linux/completion.h>
#include <linux/dma-mapping.h>
#include <linux/err.h>
@@ -79,7 +80,7 @@ static int _virtio_gpio_req(struct virtio_gpio *vgpio, u16 type, u16 gpio,
* Linux always accesses a GPIO line sequentially, so this locking shall
* always go through without any delays.
*/
- mutex_lock(&line->lock);
+ guard(mutex)(&line->lock);
req->type = cpu_to_le16(type);
req->gpio = cpu_to_le16(gpio);
@@ -97,37 +98,31 @@ static int _virtio_gpio_req(struct virtio_gpio *vgpio, u16 type, u16 gpio,
* Virtqueue callers need to ensure they don't call its APIs with other
* virtqueue operations at the same time.
*/
- mutex_lock(&vgpio->lock);
- ret = virtqueue_add_sgs(vgpio->request_vq, sgs, 1, 1, line, GFP_KERNEL);
- if (ret) {
- dev_err(dev, "failed to add request to vq\n");
- mutex_unlock(&vgpio->lock);
- goto out;
+ scoped_guard(mutex, &vgpio->lock) {
+ ret = virtqueue_add_sgs(vgpio->request_vq, sgs, 1, 1, line, GFP_KERNEL);
+ if (ret) {
+ dev_err(dev, "failed to add request to vq\n");
+ return ret;
+ }
+ virtqueue_kick(vgpio->request_vq);
}
- virtqueue_kick(vgpio->request_vq);
- mutex_unlock(&vgpio->lock);
-
wait_for_completion(&line->completion);
if (unlikely(res->status != VIRTIO_GPIO_STATUS_OK)) {
dev_err(dev, "GPIO request failed: %d\n", gpio);
- ret = -EINVAL;
- goto out;
+ return -EINVAL;
}
if (unlikely(line->rxlen != rxlen)) {
dev_err(dev, "GPIO operation returned incorrect len (%u : %u)\n",
rxlen, line->rxlen);
- ret = -EINVAL;
- goto out;
+ return -EINVAL;
}
if (rxvalue)
*rxvalue = res->value;
-out:
- mutex_unlock(&line->lock);
return ret;
}
@@ -246,11 +241,11 @@ static void virtio_gpio_irq_enable(struct irq_data *d)
gpiochip_enable_irq(gc, d->hwirq);
- raw_spin_lock(&vgpio->eventq_lock);
- irq_line->disabled = false;
- irq_line->masked = false;
- irq_line->queue_pending = true;
- raw_spin_unlock(&vgpio->eventq_lock);
+ scoped_guard(raw_spinlock, &vgpio->eventq_lock) {
+ irq_line->disabled = false;
+ irq_line->masked = false;
+ irq_line->queue_pending = true;
+ }
irq_line->update_pending = true;
}
@@ -261,11 +256,11 @@ static void virtio_gpio_irq_disable(struct irq_data *d)
struct virtio_gpio *vgpio = gpiochip_get_data(gc);
struct vgpio_irq_line *irq_line = &vgpio->irq_lines[d->hwirq];
- raw_spin_lock(&vgpio->eventq_lock);
- irq_line->disabled = true;
- irq_line->masked = true;
- irq_line->queue_pending = false;
- raw_spin_unlock(&vgpio->eventq_lock);
+ scoped_guard(raw_spinlock, &vgpio->eventq_lock) {
+ irq_line->disabled = true;
+ irq_line->masked = true;
+ irq_line->queue_pending = false;
+ }
irq_line->update_pending = true;
@@ -278,9 +273,8 @@ static void virtio_gpio_irq_mask(struct irq_data *d)
struct virtio_gpio *vgpio = gpiochip_get_data(gc);
struct vgpio_irq_line *irq_line = &vgpio->irq_lines[d->hwirq];
- raw_spin_lock(&vgpio->eventq_lock);
+ guard(raw_spinlock)(&vgpio->eventq_lock);
irq_line->masked = true;
- raw_spin_unlock(&vgpio->eventq_lock);
}
static void virtio_gpio_irq_unmask(struct irq_data *d)
@@ -289,12 +283,11 @@ static void virtio_gpio_irq_unmask(struct irq_data *d)
struct virtio_gpio *vgpio = gpiochip_get_data(gc);
struct vgpio_irq_line *irq_line = &vgpio->irq_lines[d->hwirq];
- raw_spin_lock(&vgpio->eventq_lock);
+ guard(raw_spinlock)(&vgpio->eventq_lock);
irq_line->masked = false;
/* Queue the buffer unconditionally on unmask */
virtio_gpio_irq_prepare(vgpio, d->hwirq);
- raw_spin_unlock(&vgpio->eventq_lock);
}
static int virtio_gpio_irq_set_type(struct irq_data *d, unsigned int type)
@@ -344,7 +337,6 @@ static void virtio_gpio_irq_bus_sync_unlock(struct irq_data *d)
struct virtio_gpio *vgpio = gpiochip_get_data(gc);
struct vgpio_irq_line *irq_line = &vgpio->irq_lines[d->hwirq];
u8 type = irq_line->disabled ? VIRTIO_GPIO_IRQ_TYPE_NONE : irq_line->type;
- unsigned long flags;
if (irq_line->update_pending) {
irq_line->update_pending = false;
@@ -352,12 +344,12 @@ static void virtio_gpio_irq_bus_sync_unlock(struct irq_data *d)
NULL);
/* Queue the buffer only after interrupt is enabled */
- raw_spin_lock_irqsave(&vgpio->eventq_lock, flags);
- if (irq_line->queue_pending) {
- irq_line->queue_pending = false;
- virtio_gpio_irq_prepare(vgpio, d->hwirq);
+ scoped_guard(raw_spinlock_irqsave, &vgpio->eventq_lock) {
+ if (irq_line->queue_pending) {
+ irq_line->queue_pending = false;
+ virtio_gpio_irq_prepare(vgpio, d->hwirq);
+ }
}
- raw_spin_unlock_irqrestore(&vgpio->eventq_lock, flags);
}
mutex_unlock(&vgpio->irq_lock);
@@ -366,16 +358,12 @@ static void virtio_gpio_irq_bus_sync_unlock(struct irq_data *d)
static bool ignore_irq(struct virtio_gpio *vgpio, int gpio,
struct vgpio_irq_line *irq_line)
{
- bool ignore = false;
-
- raw_spin_lock(&vgpio->eventq_lock);
+ guard(raw_spinlock)(&vgpio->eventq_lock);
irq_line->queued = false;
/* Interrupt is disabled currently */
- if (irq_line->masked || irq_line->disabled) {
- ignore = true;
- goto unlock;
- }
+ if (irq_line->masked || irq_line->disabled)
+ return true;
/*
* Buffer is returned as the interrupt was disabled earlier, but is
@@ -383,17 +371,13 @@ static bool ignore_irq(struct virtio_gpio *vgpio, int gpio,
*/
if (irq_line->ires.status == VIRTIO_GPIO_IRQ_STATUS_INVALID) {
virtio_gpio_irq_prepare(vgpio, gpio);
- ignore = true;
- goto unlock;
+ return true;
}
if (WARN_ON(irq_line->ires.status != VIRTIO_GPIO_IRQ_STATUS_VALID))
- ignore = true;
-
-unlock:
- raw_spin_unlock(&vgpio->eventq_lock);
+ return true;
- return ignore;
+ return false;
}
static void virtio_gpio_event_vq(struct virtqueue *vq)
---
base-commit: e5aad2bdbbee783611d32599f89cea3f12f9593d
change-id: 20261201-gpio-virtio-5854ed485b25
Best regards,
--
Peng Fan <peng.fan@nxp.com>
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH] gpio: virtio: simplify with cleanup API
2026-12-01 5:21 [PATCH] gpio: virtio: simplify with cleanup API Peng Fan
@ 2026-12-01 5:26 ` sashiko-bot
2026-12-01 7:53 ` Viresh Kumar
` (2 subsequent siblings)
3 siblings, 0 replies; 9+ messages in thread
From: sashiko-bot @ 2026-12-01 5:26 UTC (permalink / raw)
To: Peng Fan; +Cc: virtualization, Michael S. Tsirkin, Eugenio Perez
> From: Peng Fan <peng.fan@nxp.com>
>
> Use the scope-based cleanup API to replace the manual lock/unlock pairs
> and the goto-based error paths:
>
> - _virtio_gpio_req(): guard(mutex) holds the per-line lock over the
> whole function and scoped_guard(mutex) covers the virtqueue add/kick
> section, so the error paths can return directly instead of jumping
> to an unlock label.
> - virtio_gpio_irq_enable()/virtio_gpio_irq_disable(): scoped_guard()
> around the disabled/masked/queue_pending updates.
> - virtio_gpio_irq_mask()/virtio_gpio_irq_unmask() and ignore_irq():
> guard(raw_spinlock) with direct returns, dropping the 'ignore'
> variable and the unlock label.
> - virtio_gpio_irq_bus_sync_unlock(): scoped_guard() with the
> raw_spinlock_irqsave class.
>
> No functional changes.
>
> Signed-off-by: Peng Fan <peng.fan@nxp.com>
Sashiko has reviewed this patch and found no issues.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261201-gpio-virtio-v1-1-3038754e9b26@nxp.com?part=1
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] gpio: virtio: simplify with cleanup API
2026-12-01 5:21 [PATCH] gpio: virtio: simplify with cleanup API Peng Fan
2026-12-01 5:26 ` sashiko-bot
@ 2026-12-01 7:53 ` Viresh Kumar
2026-12-01 9:50 ` Bartosz Golaszewski
2026-12-01 9:52 ` Bartosz Golaszewski
2026-12-01 13:22 ` Bartosz Golaszewski
3 siblings, 1 reply; 9+ messages in thread
From: Viresh Kumar @ 2026-12-01 7:53 UTC (permalink / raw)
To: Peng Fan
Cc: Viresh Kumar, Linus Walleij, Bartosz Golaszewski, linux-gpio,
virtualization, Peng Fan
On 01-12-26, 13:21, Peng Fan wrote:
> From: Peng Fan <peng.fan@nxp.com>
>
> Use the scope-based cleanup API to replace the manual lock/unlock pairs
> and the goto-based error paths:
>
> - _virtio_gpio_req(): guard(mutex) holds the per-line lock over the
> whole function and scoped_guard(mutex) covers the virtqueue add/kick
> section, so the error paths can return directly instead of jumping
> to an unlock label.
> - virtio_gpio_irq_enable()/virtio_gpio_irq_disable(): scoped_guard()
> around the disabled/masked/queue_pending updates.
> - virtio_gpio_irq_mask()/virtio_gpio_irq_unmask() and ignore_irq():
> guard(raw_spinlock) with direct returns, dropping the 'ignore'
> variable and the unlock label.
> - virtio_gpio_irq_bus_sync_unlock(): scoped_guard() with the
> raw_spinlock_irqsave class.
>
> No functional changes.
>
> Signed-off-by: Peng Fan <peng.fan@nxp.com>
> ---
> drivers/gpio/gpio-virtio.c | 84 +++++++++++++++++++---------------------------
> 1 file changed, 34 insertions(+), 50 deletions(-)
>
> diff --git a/drivers/gpio/gpio-virtio.c b/drivers/gpio/gpio-virtio.c
> index 1bd532caffae..ff4b694db9da 100644
> --- a/drivers/gpio/gpio-virtio.c
> +++ b/drivers/gpio/gpio-virtio.c
> @@ -9,6 +9,7 @@
> * Viresh Kumar <viresh.kumar@linaro.org>
> */
>
> +#include <linux/cleanup.h>
> #include <linux/completion.h>
> #include <linux/dma-mapping.h>
> #include <linux/err.h>
> @@ -79,7 +80,7 @@ static int _virtio_gpio_req(struct virtio_gpio *vgpio, u16 type, u16 gpio,
> * Linux always accesses a GPIO line sequentially, so this locking shall
> * always go through without any delays.
> */
> - mutex_lock(&line->lock);
> + guard(mutex)(&line->lock);
>
> req->type = cpu_to_le16(type);
> req->gpio = cpu_to_le16(gpio);
> @@ -97,37 +98,31 @@ static int _virtio_gpio_req(struct virtio_gpio *vgpio, u16 type, u16 gpio,
> * Virtqueue callers need to ensure they don't call its APIs with other
> * virtqueue operations at the same time.
> */
> - mutex_lock(&vgpio->lock);
> - ret = virtqueue_add_sgs(vgpio->request_vq, sgs, 1, 1, line, GFP_KERNEL);
> - if (ret) {
> - dev_err(dev, "failed to add request to vq\n");
> - mutex_unlock(&vgpio->lock);
> - goto out;
> + scoped_guard(mutex, &vgpio->lock) {
> + ret = virtqueue_add_sgs(vgpio->request_vq, sgs, 1, 1, line, GFP_KERNEL);
> + if (ret) {
> + dev_err(dev, "failed to add request to vq\n");
> + return ret;
> + }
> + virtqueue_kick(vgpio->request_vq);
> }
>
> - virtqueue_kick(vgpio->request_vq);
> - mutex_unlock(&vgpio->lock);
> -
> wait_for_completion(&line->completion);
>
> if (unlikely(res->status != VIRTIO_GPIO_STATUS_OK)) {
> dev_err(dev, "GPIO request failed: %d\n", gpio);
> - ret = -EINVAL;
> - goto out;
> + return -EINVAL;
> }
>
> if (unlikely(line->rxlen != rxlen)) {
> dev_err(dev, "GPIO operation returned incorrect len (%u : %u)\n",
> rxlen, line->rxlen);
> - ret = -EINVAL;
> - goto out;
> + return -EINVAL;
> }
>
> if (rxvalue)
> *rxvalue = res->value;
>
> -out:
> - mutex_unlock(&line->lock);
> return ret;
> }
>
> @@ -246,11 +241,11 @@ static void virtio_gpio_irq_enable(struct irq_data *d)
>
> gpiochip_enable_irq(gc, d->hwirq);
>
> - raw_spin_lock(&vgpio->eventq_lock);
> - irq_line->disabled = false;
> - irq_line->masked = false;
> - irq_line->queue_pending = true;
> - raw_spin_unlock(&vgpio->eventq_lock);
> + scoped_guard(raw_spinlock, &vgpio->eventq_lock) {
> + irq_line->disabled = false;
> + irq_line->masked = false;
> + irq_line->queue_pending = true;
> + }
>
> irq_line->update_pending = true;
> }
> @@ -261,11 +256,11 @@ static void virtio_gpio_irq_disable(struct irq_data *d)
> struct virtio_gpio *vgpio = gpiochip_get_data(gc);
> struct vgpio_irq_line *irq_line = &vgpio->irq_lines[d->hwirq];
>
> - raw_spin_lock(&vgpio->eventq_lock);
> - irq_line->disabled = true;
> - irq_line->masked = true;
> - irq_line->queue_pending = false;
> - raw_spin_unlock(&vgpio->eventq_lock);
> + scoped_guard(raw_spinlock, &vgpio->eventq_lock) {
> + irq_line->disabled = true;
> + irq_line->masked = true;
> + irq_line->queue_pending = false;
> + }
>
> irq_line->update_pending = true;
>
> @@ -278,9 +273,8 @@ static void virtio_gpio_irq_mask(struct irq_data *d)
> struct virtio_gpio *vgpio = gpiochip_get_data(gc);
> struct vgpio_irq_line *irq_line = &vgpio->irq_lines[d->hwirq];
>
> - raw_spin_lock(&vgpio->eventq_lock);
> + guard(raw_spinlock)(&vgpio->eventq_lock);
> irq_line->masked = true;
> - raw_spin_unlock(&vgpio->eventq_lock);
> }
>
> static void virtio_gpio_irq_unmask(struct irq_data *d)
> @@ -289,12 +283,11 @@ static void virtio_gpio_irq_unmask(struct irq_data *d)
> struct virtio_gpio *vgpio = gpiochip_get_data(gc);
> struct vgpio_irq_line *irq_line = &vgpio->irq_lines[d->hwirq];
>
> - raw_spin_lock(&vgpio->eventq_lock);
> + guard(raw_spinlock)(&vgpio->eventq_lock);
> irq_line->masked = false;
>
> /* Queue the buffer unconditionally on unmask */
> virtio_gpio_irq_prepare(vgpio, d->hwirq);
> - raw_spin_unlock(&vgpio->eventq_lock);
> }
>
> static int virtio_gpio_irq_set_type(struct irq_data *d, unsigned int type)
> @@ -344,7 +337,6 @@ static void virtio_gpio_irq_bus_sync_unlock(struct irq_data *d)
> struct virtio_gpio *vgpio = gpiochip_get_data(gc);
> struct vgpio_irq_line *irq_line = &vgpio->irq_lines[d->hwirq];
> u8 type = irq_line->disabled ? VIRTIO_GPIO_IRQ_TYPE_NONE : irq_line->type;
> - unsigned long flags;
>
> if (irq_line->update_pending) {
> irq_line->update_pending = false;
> @@ -352,12 +344,12 @@ static void virtio_gpio_irq_bus_sync_unlock(struct irq_data *d)
> NULL);
>
> /* Queue the buffer only after interrupt is enabled */
> - raw_spin_lock_irqsave(&vgpio->eventq_lock, flags);
> - if (irq_line->queue_pending) {
> - irq_line->queue_pending = false;
> - virtio_gpio_irq_prepare(vgpio, d->hwirq);
> + scoped_guard(raw_spinlock_irqsave, &vgpio->eventq_lock) {
> + if (irq_line->queue_pending) {
> + irq_line->queue_pending = false;
> + virtio_gpio_irq_prepare(vgpio, d->hwirq);
> + }
> }
> - raw_spin_unlock_irqrestore(&vgpio->eventq_lock, flags);
> }
>
> mutex_unlock(&vgpio->irq_lock);
> @@ -366,16 +358,12 @@ static void virtio_gpio_irq_bus_sync_unlock(struct irq_data *d)
> static bool ignore_irq(struct virtio_gpio *vgpio, int gpio,
> struct vgpio_irq_line *irq_line)
> {
> - bool ignore = false;
> -
> - raw_spin_lock(&vgpio->eventq_lock);
> + guard(raw_spinlock)(&vgpio->eventq_lock);
> irq_line->queued = false;
>
> /* Interrupt is disabled currently */
> - if (irq_line->masked || irq_line->disabled) {
> - ignore = true;
> - goto unlock;
> - }
> + if (irq_line->masked || irq_line->disabled)
> + return true;
>
> /*
> * Buffer is returned as the interrupt was disabled earlier, but is
> @@ -383,17 +371,13 @@ static bool ignore_irq(struct virtio_gpio *vgpio, int gpio,
> */
> if (irq_line->ires.status == VIRTIO_GPIO_IRQ_STATUS_INVALID) {
> virtio_gpio_irq_prepare(vgpio, gpio);
> - ignore = true;
> - goto unlock;
> + return true;
> }
>
> if (WARN_ON(irq_line->ires.status != VIRTIO_GPIO_IRQ_STATUS_VALID))
> - ignore = true;
> -
> -unlock:
> - raw_spin_unlock(&vgpio->eventq_lock);
> + return true;
>
> - return ignore;
> + return false;
> }
>
> static void virtio_gpio_event_vq(struct virtqueue *vq)
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
--
viresh
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] gpio: virtio: simplify with cleanup API
2026-12-01 7:53 ` Viresh Kumar
@ 2026-12-01 9:50 ` Bartosz Golaszewski
2026-12-01 10:09 ` Viresh Kumar
0 siblings, 1 reply; 9+ messages in thread
From: Bartosz Golaszewski @ 2026-12-01 9:50 UTC (permalink / raw)
To: Viresh Kumar
Cc: Peng Fan, Viresh Kumar, Linus Walleij, linux-gpio, virtualization,
Peng Fan
On Tue, Dec 01, 2026 at 01:23:36PM +0530, Viresh Kumar wrote:
> On 01-12-26, 13:21, Peng Fan wrote:
> > From: Peng Fan <peng.fan@nxp.com>
> >
> > Use the scope-based cleanup API to replace the manual lock/unlock pairs
> > and the goto-based error paths:
> >
> > - _virtio_gpio_req(): guard(mutex) holds the per-line lock over the
> > whole function and scoped_guard(mutex) covers the virtqueue add/kick
> > section, so the error paths can return directly instead of jumping
> > to an unlock label.
> > - virtio_gpio_irq_enable()/virtio_gpio_irq_disable(): scoped_guard()
> > around the disabled/masked/queue_pending updates.
> > - virtio_gpio_irq_mask()/virtio_gpio_irq_unmask() and ignore_irq():
> > guard(raw_spinlock) with direct returns, dropping the 'ignore'
> > variable and the unlock label.
> > - virtio_gpio_irq_bus_sync_unlock(): scoped_guard() with the
> > raw_spinlock_irqsave class.
> >
> > No functional changes.
> >
> > Signed-off-by: Peng Fan <peng.fan@nxp.com>
> > ---
>
> Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
>
Hi Viresh, please try to drop unneeded context from your replies,
there's really no need to quite the entire patch.
Thanks,
Bartosz
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] gpio: virtio: simplify with cleanup API
2026-12-01 5:21 [PATCH] gpio: virtio: simplify with cleanup API Peng Fan
2026-12-01 5:26 ` sashiko-bot
2026-12-01 7:53 ` Viresh Kumar
@ 2026-12-01 9:52 ` Bartosz Golaszewski
2026-12-01 11:16 ` Peng Fan
2026-12-01 13:22 ` Bartosz Golaszewski
3 siblings, 1 reply; 9+ messages in thread
From: Bartosz Golaszewski @ 2026-12-01 9:52 UTC (permalink / raw)
To: Peng Fan
Cc: Viresh Kumar, Linus Walleij, linux-gpio, virtualization, Peng Fan
On Tue, Dec 01, 2026 at 01:21:46PM +0800, Peng Fan wrote:
> From: Peng Fan <peng.fan@nxp.com>
>
> Use the scope-based cleanup API to replace the manual lock/unlock pairs
> and the goto-based error paths:
>
> - _virtio_gpio_req(): guard(mutex) holds the per-line lock over the
> whole function and scoped_guard(mutex) covers the virtqueue add/kick
> section, so the error paths can return directly instead of jumping
> to an unlock label.
> - virtio_gpio_irq_enable()/virtio_gpio_irq_disable(): scoped_guard()
> around the disabled/masked/queue_pending updates.
> - virtio_gpio_irq_mask()/virtio_gpio_irq_unmask() and ignore_irq():
> guard(raw_spinlock) with direct returns, dropping the 'ignore'
> variable and the unlock label.
> - virtio_gpio_irq_bus_sync_unlock(): scoped_guard() with the
> raw_spinlock_irqsave class.
>
> No functional changes.
>
> Signed-off-by: Peng Fan <peng.fan@nxp.com>
> ---
Hi!
Doesn't apply on top of my gpio/for-current branch.
Thanks,
Bartosz
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] gpio: virtio: simplify with cleanup API
2026-12-01 9:50 ` Bartosz Golaszewski
@ 2026-12-01 10:09 ` Viresh Kumar
0 siblings, 0 replies; 9+ messages in thread
From: Viresh Kumar @ 2026-12-01 10:09 UTC (permalink / raw)
To: Bartosz Golaszewski
Cc: Peng Fan, Viresh Kumar, Linus Walleij, linux-gpio, virtualization,
Peng Fan
On 01-12-26, 10:50, Bartosz Golaszewski wrote:
> On Tue, Dec 01, 2026 at 01:23:36PM +0530, Viresh Kumar wrote:
> > On 01-12-26, 13:21, Peng Fan wrote:
> > > From: Peng Fan <peng.fan@nxp.com>
> > >
> > > Use the scope-based cleanup API to replace the manual lock/unlock pairs
> > > and the goto-based error paths:
> > >
> > > - _virtio_gpio_req(): guard(mutex) holds the per-line lock over the
> > > whole function and scoped_guard(mutex) covers the virtqueue add/kick
> > > section, so the error paths can return directly instead of jumping
> > > to an unlock label.
> > > - virtio_gpio_irq_enable()/virtio_gpio_irq_disable(): scoped_guard()
> > > around the disabled/masked/queue_pending updates.
> > > - virtio_gpio_irq_mask()/virtio_gpio_irq_unmask() and ignore_irq():
> > > guard(raw_spinlock) with direct returns, dropping the 'ignore'
> > > variable and the unlock label.
> > > - virtio_gpio_irq_bus_sync_unlock(): scoped_guard() with the
> > > raw_spinlock_irqsave class.
> > >
> > > No functional changes.
> > >
> > > Signed-off-by: Peng Fan <peng.fan@nxp.com>
> > > ---
> >
> > Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
> >
>
> Hi Viresh, please try to drop unneeded context from your replies,
> there's really no need to quite the entire patch.
Sure Bartosz.
I normally drop the extra stuff for longer patches and reply below SOB, but
for shorter patches I reply at the end :)
This one could have been dropped though.
--
viresh
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] gpio: virtio: simplify with cleanup API
2026-12-01 9:52 ` Bartosz Golaszewski
@ 2026-12-01 11:16 ` Peng Fan
2026-12-01 13:22 ` Bartosz Golaszewski
0 siblings, 1 reply; 9+ messages in thread
From: Peng Fan @ 2026-12-01 11:16 UTC (permalink / raw)
To: Bartosz Golaszewski
Cc: Peng Fan, Viresh Kumar, Linus Walleij, linux-gpio, virtualization,
Peng Fan
Hi Bartosz,
On Tue, Dec 01, 2026 at 10:52:35AM +0100, Bartosz Golaszewski wrote:
>On Tue, Dec 01, 2026 at 01:21:46PM +0800, Peng Fan wrote:
>> From: Peng Fan <peng.fan@nxp.com>
>>
>> Use the scope-based cleanup API to replace the manual lock/unlock pairs
>> and the goto-based error paths:
>>
>Hi!
>
>Doesn't apply on top of my gpio/for-current branch.
This patch is based on linux-next/master, seems some patches
are in linux-next/master, but not in your for-current branch:
0fa38ba784896f2fc gpio: Unify style of various *_device_id arrays
7c01eb6861833cfb9 gpio: virtio: Use a named initializer for virtio_device_id array
d5d4132419a41d711 gpio: virtio: convert to immutable irq_chip
This patch is not bug fix. I see your gpio/for-current branch only
has bug fixes, or I may miss-understand.
Should I repost this patch based on gpio/for-current branch?
Thanks
Peng
>
>Thanks,
>Bartosz
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] gpio: virtio: simplify with cleanup API
2026-12-01 11:16 ` Peng Fan
@ 2026-12-01 13:22 ` Bartosz Golaszewski
0 siblings, 0 replies; 9+ messages in thread
From: Bartosz Golaszewski @ 2026-12-01 13:22 UTC (permalink / raw)
To: Peng Fan
Cc: Peng Fan, Viresh Kumar, Linus Walleij, linux-gpio, virtualization,
Peng Fan
On Tue, Dec 01, 2026 at 07:16:44PM +0800, Peng Fan wrote:
> Hi Bartosz,
> On Tue, Dec 01, 2026 at 10:52:35AM +0100, Bartosz Golaszewski wrote:
> >On Tue, Dec 01, 2026 at 01:21:46PM +0800, Peng Fan wrote:
> >> From: Peng Fan <peng.fan@nxp.com>
> >>
> >> Use the scope-based cleanup API to replace the manual lock/unlock pairs
> >> and the goto-based error paths:
> >>
> >Hi!
> >
> >Doesn't apply on top of my gpio/for-current branch.
>
> This patch is based on linux-next/master, seems some patches
> are in linux-next/master, but not in your for-current branch:
>
> 0fa38ba784896f2fc gpio: Unify style of various *_device_id arrays
> 7c01eb6861833cfb9 gpio: virtio: Use a named initializer for virtio_device_id array
> d5d4132419a41d711 gpio: virtio: convert to immutable irq_chip
>
> This patch is not bug fix. I see your gpio/for-current branch only
> has bug fixes, or I may miss-understand.
>
> Should I repost this patch based on gpio/for-current branch?
>
Ah, no sorry, I don't know why I though this was a bug-fix.
Nevermind my comment.
Bart
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] gpio: virtio: simplify with cleanup API
2026-12-01 5:21 [PATCH] gpio: virtio: simplify with cleanup API Peng Fan
` (2 preceding siblings ...)
2026-12-01 9:52 ` Bartosz Golaszewski
@ 2026-12-01 13:22 ` Bartosz Golaszewski
3 siblings, 0 replies; 9+ messages in thread
From: Bartosz Golaszewski @ 2026-12-01 13:22 UTC (permalink / raw)
To: Viresh Kumar, Linus Walleij, Bartosz Golaszewski, Peng Fan
Cc: Bartosz Golaszewski, linux-gpio, virtualization, Peng Fan
On Tue, 01 Dec 2026 13:21:46 +0800, Peng Fan wrote:
> Use the scope-based cleanup API to replace the manual lock/unlock pairs
> and the goto-based error paths:
>
> - _virtio_gpio_req(): guard(mutex) holds the per-line lock over the
> whole function and scoped_guard(mutex) covers the virtqueue add/kick
> section, so the error paths can return directly instead of jumping
> to an unlock label.
> - virtio_gpio_irq_enable()/virtio_gpio_irq_disable(): scoped_guard()
> around the disabled/masked/queue_pending updates.
> - virtio_gpio_irq_mask()/virtio_gpio_irq_unmask() and ignore_irq():
> guard(raw_spinlock) with direct returns, dropping the 'ignore'
> variable and the unlock label.
> - virtio_gpio_irq_bus_sync_unlock(): scoped_guard() with the
> raw_spinlock_irqsave class.
>
> [...]
Applied, thanks!
[1/1] gpio: virtio: simplify with cleanup API
https://git.kernel.org/brgl/c/b07cca0071f050fddaec1d0ebef652eba6263934
Best regards,
--
Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2026-12-01 13:23 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-01 5:21 [PATCH] gpio: virtio: simplify with cleanup API Peng Fan
2026-12-01 5:26 ` sashiko-bot
2026-12-01 7:53 ` Viresh Kumar
2026-12-01 9:50 ` Bartosz Golaszewski
2026-12-01 10:09 ` Viresh Kumar
2026-12-01 9:52 ` Bartosz Golaszewski
2026-12-01 11:16 ` Peng Fan
2026-12-01 13:22 ` Bartosz Golaszewski
2026-12-01 13:22 ` Bartosz Golaszewski
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.