From: Johan Hovold <johan@kernel.org>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Bastien Nocera <hadess@hadess.net>,
Valentina Manea <valentina.manea.m@gmail.com>,
Shuah Khan <shuah@kernel.org>, Hongren Zheng <i@zenithal.me>,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
Johan Hovold <johan@kernel.org>
Subject: [PATCH 1/2] USB: apple-mfi-fastcharge: drop redundant device reference
Date: Thu, 5 Mar 2026 14:38:50 +0100 [thread overview]
Message-ID: <20260305133851.2952-2-johan@kernel.org> (raw)
In-Reply-To: <20260305133851.2952-1-johan@kernel.org>
Driver core holds a reference to the USB device while it is bound to a
driver and there is no need to take additional references unless the
structure is 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/usb/misc/apple-mfi-fastcharge.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/usb/misc/apple-mfi-fastcharge.c b/drivers/usb/misc/apple-mfi-fastcharge.c
index 339f6cd2e9b2..af266e19f2fd 100644
--- a/drivers/usb/misc/apple-mfi-fastcharge.c
+++ b/drivers/usb/misc/apple-mfi-fastcharge.c
@@ -210,7 +210,7 @@ static int mfi_fc_probe(struct usb_device *udev)
goto err_free_name;
}
- mfi->udev = usb_get_dev(udev);
+ mfi->udev = udev;
dev_set_drvdata(&udev->dev, mfi);
return 0;
@@ -231,7 +231,6 @@ static void mfi_fc_disconnect(struct usb_device *udev)
power_supply_unregister(mfi->battery);
kfree(mfi->battery_desc.name);
dev_set_drvdata(&udev->dev, NULL);
- usb_put_dev(mfi->udev);
kfree(mfi);
}
--
2.52.0
next prev parent reply other threads:[~2026-03-05 13:39 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-05 13:38 [PATCH 0/2] USB: drop further redundant device references Johan Hovold
2026-03-05 13:38 ` Johan Hovold [this message]
2026-03-10 14:38 ` [PATCH 1/2] USB: apple-mfi-fastcharge: drop redundant device reference Bastien Nocera
2026-03-05 13:38 ` [PATCH 2/2] USB: usbip: " Johan Hovold
2026-03-09 20:26 ` Shuah Khan
2026-03-10 8:35 ` Johan Hovold
2026-03-10 21:51 ` Shuah Khan
2026-03-11 8:02 ` Johan Hovold
2026-03-23 19:29 ` Shuah Khan
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=20260305133851.2952-2-johan@kernel.org \
--to=johan@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=hadess@hadess.net \
--cc=i@zenithal.me \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=shuah@kernel.org \
--cc=valentina.manea.m@gmail.com \
/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