Search Linux Wireless

[v2 05/11] rsi: Remove unnecessary buffer allocation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Prameela Rani Garnepudi <prameela.j04cs@xxxxxxxxx>

In functions usb read register and usb write register, dynamic allocation
of 4 bytes is used. This is removed as it is unncessary for local variable
and for such small data.

Signed-off-by: Prameela Rani Garnepudi <prameela.j04cs@xxxxxxxxx>
Signed-off-by: Amitkumar Karwar <amit.karwar@xxxxxxxxxxxxxxxxxx>
---
 drivers/net/wireless/rsi/rsi_91x_usb.c | 18 ++++--------------
 1 file changed, 4 insertions(+), 14 deletions(-)

diff --git a/drivers/net/wireless/rsi/rsi_91x_usb.c b/drivers/net/wireless/rsi/rsi_91x_usb.c
index 73b01a8..8eb7407 100644
--- a/drivers/net/wireless/rsi/rsi_91x_usb.c
+++ b/drivers/net/wireless/rsi/rsi_91x_usb.c
@@ -157,12 +157,8 @@ static int rsi_usb_reg_read(struct usb_device *usbdev,
 			    u16 *value,
 			    u16 len)
 {
-	u8 *buf;
-	int status = -ENOMEM;
-
-	buf  = kmalloc(0x04, GFP_KERNEL);
-	if (!buf)
-		return status;
+	u8 buf[4];
+	int status;
 
 	status = usb_control_msg(usbdev,
 				 usb_rcvctrlpipe(usbdev, 0),
@@ -179,7 +175,6 @@ static int rsi_usb_reg_read(struct usb_device *usbdev,
 			"%s: Reg read failed with error code :%d\n",
 			__func__, status);
 	}
-	kfree(buf);
 
 	return status;
 }
@@ -199,12 +194,8 @@ static int rsi_usb_reg_write(struct usb_device *usbdev,
 			     u16 value,
 			     u16 len)
 {
-	u8 *usb_reg_buf;
-	int status = -ENOMEM;
-
-	usb_reg_buf  = kmalloc(0x04, GFP_KERNEL);
-	if (!usb_reg_buf)
-		return status;
+	u8 usb_reg_buf[4];
+	int status;
 
 	usb_reg_buf[0] = (value & 0x00ff);
 	usb_reg_buf[1] = (value & 0xff00) >> 8;
@@ -225,7 +216,6 @@ static int rsi_usb_reg_write(struct usb_device *usbdev,
 			"%s: Reg write failed with error code :%d\n",
 			__func__, status);
 	}
-	kfree(usb_reg_buf);
 
 	return status;
 }
-- 
2.7.4




[Index of Archives]     [Linux Host AP]     [ATH6KL]     [Linux Wireless Personal Area Network]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Linux Kernel]     [IDE]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite Hiking]     [MIPS Linux]     [ARM Linux]     [Linux RAID]

  Powered by Linux