public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] gpio: mpsse: drop redundant device reference
@ 2026-03-05 12:49 Johan Hovold
  2026-03-08 23:40 ` Linus Walleij
  2026-03-09  9:19 ` Bartosz Golaszewski
  0 siblings, 2 replies; 3+ messages in thread
From: Johan Hovold @ 2026-03-05 12:49 UTC (permalink / raw)
  To: Linus Walleij, Bartosz Golaszewski; +Cc: linux-gpio, linux-kernel, Johan Hovold

Driver core holds a reference to the USB interface and its parent USB
device while the interface is bound to a driver and there is no need to
take additional references unless the structures are needed after
disconnect.

Drop the redundant device reference to reduce cargo culting, make it
easier to spot drivers where an extra reference is needed, and reduce
the risk of memory leaks when drivers fail to release it.

Signed-off-by: Johan Hovold <johan@kernel.org>
---
 drivers/gpio/gpio-mpsse.c | 13 +------------
 1 file changed, 1 insertion(+), 12 deletions(-)

diff --git a/drivers/gpio/gpio-mpsse.c b/drivers/gpio/gpio-mpsse.c
index 12191aeb6566..a859deab2bca 100644
--- a/drivers/gpio/gpio-mpsse.c
+++ b/drivers/gpio/gpio-mpsse.c
@@ -548,13 +548,6 @@ static void gpio_mpsse_ida_remove(void *data)
 	ida_free(&gpio_mpsse_ida, priv->id);
 }
 
-static void gpio_mpsse_usb_put_dev(void *data)
-{
-	struct mpsse_priv *priv = data;
-
-	usb_put_dev(priv->udev);
-}
-
 static int mpsse_init_valid_mask(struct gpio_chip *chip,
 				 unsigned long *valid_mask,
 				 unsigned int ngpios)
@@ -598,11 +591,7 @@ static int gpio_mpsse_probe(struct usb_interface *interface,
 
 	INIT_LIST_HEAD(&priv->workers);
 
-	priv->udev = usb_get_dev(interface_to_usbdev(interface));
-	err = devm_add_action_or_reset(dev, gpio_mpsse_usb_put_dev, priv);
-	if (err)
-		return err;
-
+	priv->udev = interface_to_usbdev(interface);
 	priv->intf = interface;
 	priv->intf_id = interface->cur_altsetting->desc.bInterfaceNumber;
 
-- 
2.52.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] gpio: mpsse: drop redundant device reference
  2026-03-05 12:49 [PATCH] gpio: mpsse: drop redundant device reference Johan Hovold
@ 2026-03-08 23:40 ` Linus Walleij
  2026-03-09  9:19 ` Bartosz Golaszewski
  1 sibling, 0 replies; 3+ messages in thread
From: Linus Walleij @ 2026-03-08 23:40 UTC (permalink / raw)
  To: Johan Hovold; +Cc: Bartosz Golaszewski, linux-gpio, linux-kernel

On Thu, Mar 5, 2026 at 1:49 PM Johan Hovold <johan@kernel.org> wrote:

> Driver core holds a reference to the USB interface and its parent USB
> device while the interface is bound to a driver and there is no need to
> take additional references unless the structures are needed after
> disconnect.
>
> Drop the redundant device reference to reduce cargo culting, make it
> easier to spot drivers where an extra reference is needed, and reduce
> the risk of memory leaks when drivers fail to release it.
>
> Signed-off-by: Johan Hovold <johan@kernel.org>

Looks right to me.
Reviewed-by: Linus Walleij <linusw@kernel.org>

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] gpio: mpsse: drop redundant device reference
  2026-03-05 12:49 [PATCH] gpio: mpsse: drop redundant device reference Johan Hovold
  2026-03-08 23:40 ` Linus Walleij
@ 2026-03-09  9:19 ` Bartosz Golaszewski
  1 sibling, 0 replies; 3+ messages in thread
From: Bartosz Golaszewski @ 2026-03-09  9:19 UTC (permalink / raw)
  To: Linus Walleij, Bartosz Golaszewski, Johan Hovold
  Cc: Bartosz Golaszewski, linux-gpio, linux-kernel


On Thu, 05 Mar 2026 13:49:45 +0100, Johan Hovold wrote:
> Driver core holds a reference to the USB interface and its parent USB
> device while the interface is bound to a driver and there is no need to
> take additional references unless the structures are needed after
> disconnect.
> 
> Drop the redundant device reference to reduce cargo culting, make it
> easier to spot drivers where an extra reference is needed, and reduce
> the risk of memory leaks when drivers fail to release it.
> 
> [...]

Applied, thanks!

[1/1] gpio: mpsse: drop redundant device reference
      https://git.kernel.org/brgl/c/3671411e9073cb06d726dbf10835d158e18f0796

Best regards,
-- 
Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-03-09  9:19 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-05 12:49 [PATCH] gpio: mpsse: drop redundant device reference Johan Hovold
2026-03-08 23:40 ` Linus Walleij
2026-03-09  9:19 ` Bartosz Golaszewski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox