From: Johan Hovold <johan@kernel.org>
To: Sean Young <sean@mess.org>,
Mauro Carvalho Chehab <mchehab@kernel.org>,
Hans Verkuil <hverkuil@kernel.org>
Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
Johan Hovold <johan@kernel.org>
Subject: [PATCH 1/4] media: imon: drop redundant device references
Date: Thu, 5 Mar 2026 11:39:16 +0100 [thread overview]
Message-ID: <20260305103919.15560-2-johan@kernel.org> (raw)
In-Reply-To: <20260305103919.15560-1-johan@kernel.org>
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 references to reduce cargo culting, make it
easier to spot drivers where extra references are needed, and reduce the
risk of memory leaks when drivers fail to release them.
Signed-off-by: Johan Hovold <johan@kernel.org>
---
drivers/media/rc/imon.c | 13 +++----------
1 file changed, 3 insertions(+), 10 deletions(-)
diff --git a/drivers/media/rc/imon.c b/drivers/media/rc/imon.c
index 7e92161105d5..ecea0085d411 100644
--- a/drivers/media/rc/imon.c
+++ b/drivers/media/rc/imon.c
@@ -2250,7 +2250,7 @@ static struct imon_context *imon_init_intf0(struct usb_interface *intf,
mutex_lock(&ictx->lock);
ictx->dev = dev;
- ictx->usbdev_intf0 = usb_get_dev(interface_to_usbdev(intf));
+ ictx->usbdev_intf0 = interface_to_usbdev(intf);
ictx->rx_urb_intf0 = rx_urb;
ictx->tx_urb = tx_urb;
ictx->rf_device = false;
@@ -2308,7 +2308,6 @@ static struct imon_context *imon_init_intf0(struct usb_interface *intf,
usb_kill_urb(ictx->rx_urb_intf0);
urb_submit_failed:
find_endpoint_failed:
- usb_put_dev(ictx->usbdev_intf0);
mutex_unlock(&ictx->lock);
usb_free_urb(tx_urb);
tx_urb_alloc_failed:
@@ -2338,7 +2337,7 @@ static struct imon_context *imon_init_intf1(struct usb_interface *intf,
timer_setup(&ictx->ttimer, imon_touch_display_timeout, 0);
}
- ictx->usbdev_intf1 = usb_get_dev(interface_to_usbdev(intf));
+ ictx->usbdev_intf1 = interface_to_usbdev(intf);
ictx->rx_urb_intf1 = rx_urb;
ret = -ENODEV;
@@ -2377,7 +2376,6 @@ static struct imon_context *imon_init_intf1(struct usb_interface *intf,
input_unregister_device(ictx->touch);
touch_setup_failed:
find_endpoint_failed:
- usb_put_dev(ictx->usbdev_intf1);
ictx->usbdev_intf1 = NULL;
mutex_unlock(&ictx->lock);
usb_free_urb(rx_urb);
@@ -2426,7 +2424,7 @@ static int imon_probe(struct usb_interface *interface,
struct imon_context *ictx = NULL;
u16 vendor, product;
- usbdev = usb_get_dev(interface_to_usbdev(interface));
+ usbdev = interface_to_usbdev(interface);
iface_desc = interface->cur_altsetting;
ifnum = iface_desc->desc.bInterfaceNumber;
vendor = le16_to_cpu(usbdev->descriptor.idVendor);
@@ -2495,12 +2493,9 @@ static int imon_probe(struct usb_interface *interface,
vendor, product, ifnum,
usbdev->bus->busnum, usbdev->devnum);
- usb_put_dev(usbdev);
-
return 0;
fail:
- usb_put_dev(usbdev);
dev_err(dev, "unable to register, err %d\n", ret);
return ret;
@@ -2550,7 +2545,6 @@ static void imon_disconnect(struct usb_interface *interface)
else if (ictx->display_type == IMON_DISPLAY_TYPE_VFD)
usb_deregister_dev(interface, &imon_vfd_class);
}
- usb_put_dev(ictx->usbdev_intf0);
} else {
ictx->dev_present_intf1 = false;
usb_kill_urb(ictx->rx_urb_intf1);
@@ -2558,7 +2552,6 @@ static void imon_disconnect(struct usb_interface *interface)
timer_delete_sync(&ictx->ttimer);
input_unregister_device(ictx->touch);
}
- usb_put_dev(ictx->usbdev_intf1);
}
if (refcount_dec_and_test(&ictx->users))
--
2.52.0
next prev parent reply other threads:[~2026-03-05 10:39 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-05 10:39 [PATCH 0/4] media: drop redundant device references Johan Hovold
2026-03-05 10:39 ` Johan Hovold [this message]
2026-03-05 10:39 ` [PATCH 2/4] media: mceusb: drop redundant device reference Johan Hovold
2026-03-05 10:39 ` [PATCH 3/4] media: go7007-loader: " Johan Hovold
2026-03-05 10:39 ` [PATCH 4/4] media: usbtv: " Johan Hovold
[not found] ` <69a98f03.050a0220.1fe09d.ec95@mx.google.com>
2026-03-10 8:40 ` [0/4] media: drop redundant device references Johan Hovold
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260305103919.15560-2-johan@kernel.org \
--to=johan@kernel.org \
--cc=hverkuil@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=sean@mess.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox