gpio: mpsse: drop redundant device reference
PATCH 1/1 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.
--- drivers/gpio/gpio-mpsse.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-)
drivers/gpio/gpio-mpsse.c +1 -12
@@ -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;
Signature · 1 line
2.52.0
Quoted 10 lines · 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 <[email protected]>
Looks right to me.
Yours,
Linus Walleij
Bartosz Golaszewski
AppliedQuoted 10 lines · 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.
[...]
Applied, thanks!
[1/1] gpio: mpsse: drop redundant device reference
https://git.kernel.org/brgl/c/3671411e9073cb06d726dbf10835d158e18f0796
Best regards,
Signature · 1 line
Bartosz Golaszewski <[email protected]>