mfd: dln2: Switch to managed resources and fix bare unsigned types
PATCH 1/1 mfd: dln2: Switch to managed resources and fix bare unsigned types
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.
--- drivers/mfd/dln2.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-)
drivers/mfd/dln2.c +8 -10
@@ -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 ;
Signature · 1 line
2.43.0
Re: (subset) [PATCH] mfd: dln2: Switch to managed resources and fix bare unsigned types
Quoted 9 lines · Subhash Rawat
Convert
dln2_probeanddln2_setup_rx_urbsto usedevm_kzalloc()anddevm_kmalloc()respectively. This simplifies resource management by allowing the removal of manualkfree()calls indln2_free()anddln2_free_rx_urbs().Additionally, update bare 'unsigned' types to 'unsigned int' to satisfy checkpatch.pl warnings and comply with the Linux kernel coding style.
[...]
Applied, thanks!
[1/1] mfd: dln2: Switch to managed resources and fix bare unsigned types
commit: e95325f037e5b78c7cf0e614872337c1b0151fa4
--
Lee Jones [李琼斯]