From: Subhash Rawat <rawatsubhash02@gmail.com>
To: lee@kernel.org
Cc: linux-kernel@vger.kernel.org, Subhash Rawat <rawatsubhash02@gmail.com>
Subject: [PATCH] mfd: dln2: Switch to managed resources and fix bare unsigned types
Date: Tue, 3 Mar 2026 18:32:36 +0000 [thread overview]
Message-ID: <20260303183236.574940-1-rawatsubhash02@gmail.com> (raw)
Convert dln2_probe and dln2_setup_rx_urbs to use devm_kzalloc() and
devm_kmalloc() respectively. This simplifies resource management by
allowing the removal of manual kfree() calls in dln2_free() and
dln2_free_rx_urbs().
Additionally, update bare 'unsigned' types to 'unsigned int' to satisfy
checkpatch.pl warnings and comply with the Linux kernel coding style.
Signed-off-by: Subhash Rawat <rawatsubhash02@gmail.com>
---
drivers/mfd/dln2.c | 18 ++++++++----------
1 file changed, 8 insertions(+), 10 deletions(-)
diff --git a/drivers/mfd/dln2.c b/drivers/mfd/dln2.c
index d12510e39..7f281b409 100644
--- a/drivers/mfd/dln2.c
+++ b/drivers/mfd/dln2.c
@@ -424,8 +424,8 @@ static void free_rx_slot(struct dln2_dev *dln2, u16 handle, int slot)
}
static int _dln2_transfer(struct dln2_dev *dln2, u16 handle, u16 cmd,
- const void *obuf, unsigned obuf_len,
- void *ibuf, unsigned *ibuf_len)
+ const void *obuf, unsigned int obuf_len,
+ void *ibuf, unsigned int *ibuf_len)
{
int ret = 0;
int rx_slot;
@@ -511,8 +511,8 @@ static int _dln2_transfer(struct dln2_dev *dln2, u16 handle, u16 cmd,
}
int dln2_transfer(struct platform_device *pdev, u16 cmd,
- const void *obuf, unsigned obuf_len,
- void *ibuf, unsigned *ibuf_len)
+ const void *obuf, unsigned int obuf_len,
+ void *ibuf, unsigned int *ibuf_len)
{
struct dln2_platform_data *dln2_pdata;
struct dln2_dev *dln2;
@@ -583,10 +583,8 @@ static void dln2_free_rx_urbs(struct dln2_dev *dln2)
{
int i;
- for (i = 0; i < DLN2_MAX_URBS; i++) {
+ for (i = 0; i < DLN2_MAX_URBS; i++)
usb_free_urb(dln2->rx_urb[i]);
- kfree(dln2->rx_buf[i]);
- }
}
static void dln2_stop_rx_urbs(struct dln2_dev *dln2)
@@ -601,7 +599,6 @@ static void dln2_free(struct dln2_dev *dln2)
{
dln2_free_rx_urbs(dln2);
usb_put_dev(dln2->usb_dev);
- kfree(dln2);
}
static int dln2_setup_rx_urbs(struct dln2_dev *dln2,
@@ -609,9 +606,10 @@ static int dln2_setup_rx_urbs(struct dln2_dev *dln2,
{
int i;
const int rx_max_size = DLN2_RX_BUF_SIZE;
+ struct device *dev = &dln2->interface->dev;
for (i = 0; i < DLN2_MAX_URBS; i++) {
- dln2->rx_buf[i] = kmalloc(rx_max_size, GFP_KERNEL);
+ dln2->rx_buf[i] = devm_kmalloc(dev, rx_max_size, GFP_KERNEL);
if (!dln2->rx_buf[i])
return -ENOMEM;
@@ -778,7 +776,7 @@ static int dln2_probe(struct usb_interface *interface,
if (ret)
return ret;
- dln2 = kzalloc_obj(*dln2);
+ dln2 = devm_kzalloc(dev, sizeof(*dln2), GFP_KERNEL);
if (!dln2)
return -ENOMEM;
--
2.43.0
next reply other threads:[~2026-03-03 18:32 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-03 18:32 Subhash Rawat [this message]
2026-03-06 14:10 ` (subset) " Lee Jones
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=20260303183236.574940-1-rawatsubhash02@gmail.com \
--to=rawatsubhash02@gmail.com \
--cc=lee@kernel.org \
--cc=linux-kernel@vger.kernel.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
all inboxes | Powered by JetHome®