Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

gpio: mpsse: drop redundant device reference

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>
Reviewed-by: Linus Walleij <linusw@kernel.org>
Link: https://patch.msgid.link/20260305124945.10781-1-johan@kernel.org
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>

authored by

Johan Hovold and committed by
Bartosz Golaszewski
3671411e b678676b

+1 -12
+1 -12
drivers/gpio/gpio-mpsse.c
··· 548 548 ida_free(&gpio_mpsse_ida, priv->id); 549 549 } 550 550 551 - static void gpio_mpsse_usb_put_dev(void *data) 552 - { 553 - struct mpsse_priv *priv = data; 554 - 555 - usb_put_dev(priv->udev); 556 - } 557 - 558 551 static int mpsse_init_valid_mask(struct gpio_chip *chip, 559 552 unsigned long *valid_mask, 560 553 unsigned int ngpios) ··· 591 598 592 599 INIT_LIST_HEAD(&priv->workers); 593 600 594 - priv->udev = usb_get_dev(interface_to_usbdev(interface)); 595 - err = devm_add_action_or_reset(dev, gpio_mpsse_usb_put_dev, priv); 596 - if (err) 597 - return err; 598 - 601 + priv->udev = interface_to_usbdev(interface); 599 602 priv->intf = interface; 600 603 priv->intf_id = interface->cur_altsetting->desc.bInterfaceNumber; 601 604