All of lore.kernel.org
 help / color / mirror / Atom feed
From: Prameela Rani Garnepudi <prameela.j04cs@gmail.com>
To: linux-wireless@vger.kernel.org, kvalo@codeaurora.org,
	johannes.berg@intel.com, hofrat@osadl.org
Cc: prameela.j04cs@gmail.com, prameela.garnepudi@redpinesignals.com
Subject: [PATCH 8/9] rsi: code clean up and replaced ctrl message timeouts with macros in file rsi_91x_usb.c
Date: Mon, 12 Sep 2016 15:08:23 +0530	[thread overview]
Message-ID: <340487567235056703e4c97170c63cb719fa5460.1473669618.git.prameela.j04cs@gmail.com> (raw)
In-Reply-To: <cover.1473669618.git.prameela.j04cs@gmail.com>
In-Reply-To: <cover.1473669618.git.prameela.j04cs@gmail.com>

Signed-off-by: Prameela Rani Garnepudi <prameela.j04cs@gmail.com>
---
 drivers/net/wireless/rsi/rsi_91x_usb.c | 42 +++++++++++++++++++---------------
 1 file changed, 23 insertions(+), 19 deletions(-)

diff --git a/drivers/net/wireless/rsi/rsi_91x_usb.c b/drivers/net/wireless/rsi/rsi_91x_usb.c
index ef5d394..21957dd 100644
--- a/drivers/net/wireless/rsi/rsi_91x_usb.c
+++ b/drivers/net/wireless/rsi/rsi_91x_usb.c
@@ -1,6 +1,9 @@
 /**
  * Copyright (c) 2014 Redpine Signals Inc.
  *
+ * Developers:
+ *	Prameela Rani Garnepudi	2016 <prameela.garnepudi@redpinesignals.com>
+ *
  * Permission to use, copy, modify, and/or distribute this software for any
  * purpose with or without fee is hereby granted, provided that the above
  * copyright notice and this permission notice appear in all copies.
@@ -19,7 +22,7 @@
 #include "rsi_usb.h"
 
 /**
- * rsi_usb_card_write() - This function writes to the USB Card.
+ * rsi_usb_card_write() - This function writes data to the USB Card.
  * @adapter: Pointer to the adapter structure.
  * @buf: Pointer to the buffer from where the data has to be taken.
  * @len: Length to be written.
@@ -34,7 +37,7 @@ static int rsi_usb_card_write(struct rsi_hw *adapter,
 {
 	struct rsi_91x_usbdev *dev = (struct rsi_91x_usbdev *)adapter->rsi_dev;
 	int status;
-	s32 transfer;
+	int transfer;
 
 	status = usb_bulk_msg(dev->usbdev,
 			      usb_sndbulkpipe(dev->usbdev,
@@ -46,7 +49,7 @@ static int rsi_usb_card_write(struct rsi_hw *adapter,
 
 	if (status < 0) {
 		rsi_dbg(ERR_ZONE,
-			"Card write failed with error code :%10d\n", status);
+			"Card write failed with error code :%d\n", status);
 		dev->write_fail = 1;
 	}
 	return status;
@@ -155,11 +158,11 @@ static int rsi_usb_reg_read(struct usb_device *usbdev,
 			    u16 len)
 {
 	u8 *buf;
-	int status = -ENOMEM;
+	int status = 0;
 
 	buf  = kmalloc(0x04, GFP_KERNEL);
 	if (!buf)
-		return status;
+		return -ENOMEM;
 
 	status = usb_control_msg(usbdev,
 				 usb_rcvctrlpipe(usbdev, 0),
@@ -168,7 +171,7 @@ static int rsi_usb_reg_read(struct usb_device *usbdev,
 				 ((reg & 0xffff0000) >> 16), (reg & 0xffff),
 				 (void *)buf,
 				 len,
-				 HZ * 5);
+				 USB_CTRL_GET_TIMEOUT);
 
 	*value = (buf[0] | (buf[1] << 8));
 	if (status < 0) {
@@ -197,11 +200,11 @@ static int rsi_usb_reg_write(struct usb_device *usbdev,
 			     u16 len)
 {
 	u8 *usb_reg_buf;
-	int status = -ENOMEM;
+	int status = 0;
 
 	usb_reg_buf  = kmalloc(0x04, GFP_KERNEL);
 	if (!usb_reg_buf)
-		return status;
+		return -ENOMEM;
 
 	usb_reg_buf[0] = (value & 0x00ff);
 	usb_reg_buf[1] = (value & 0xff00) >> 8;
@@ -216,7 +219,7 @@ static int rsi_usb_reg_write(struct usb_device *usbdev,
 				 (reg & 0xffff),
 				 (void *)usb_reg_buf,
 				 len,
-				 HZ * 5);
+				 USB_CTRL_SET_TIMEOUT);
 	if (status < 0) {
 		rsi_dbg(ERR_ZONE,
 			"%s: Reg write failed with error code :%d\n",
@@ -275,11 +278,11 @@ static int rsi_rx_urb_submit(struct rsi_hw *adapter)
 
 /**
  * rsi_usb_write_register_multiple() - This function writes multiple bytes of
- *				       information to multiple registers.
- * @adapter: Pointer to the adapter structure.
- * @addr: Address of the register.
- * @data: Pointer to the data that has to be written.
- * @count: Number of multiple bytes to be written on to the registers.
+ *				       information to the given address.
+ * @adapter:	Pointer to the adapter structure.
+ * @addr:	Address of the register.
+ * @data:	Pointer to the data that has to be written.
+ * @count:	Number of multiple bytes to be written on to the registers.
  *
  * Return: status: 0 on success, a negative error code on failure.
  */
@@ -308,16 +311,17 @@ int rsi_usb_write_register_multiple(struct rsi_hw *adapter,
 					 (addr & 0xffff),
 					 (void *)buf,
 					 transfer,
-					 HZ * 5);
+					 USB_CTRL_SET_TIMEOUT);
 		if (status < 0) {
 			rsi_dbg(ERR_ZONE,
 				"Reg write failed with error code :%d\n",
 				status);
-		} else {
-			count -= transfer;
-			data += transfer;
-			addr += transfer;
+			kfree(buf);
+			return status;
 		}
+		count -= transfer;
+		data += transfer;
+		addr += transfer;
 	}
 
 	kfree(buf);
-- 
2.4.11

  parent reply	other threads:[~2016-09-12  9:43 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-12  9:38 [PATCH 0/9] rsi: code clean-up Prameela Rani Garnepudi
2016-09-12  9:38 ` [PATCH 1/9] rsi: cleanup and added debug prints in file rsi_91x_core.c Prameela Rani Garnepudi
2016-09-12  9:38 ` [PATCH 2/9] rsi: Spelling and code format corrections in rsi_91x_debugfs.c Prameela Rani Garnepudi
2016-09-12  9:38 ` [PATCH 3/9] rsi: Added freeing of allocated buffers (sbands and dfsentry) Cleanup (spelling mistakes, code format corrections, empty lines after declaration) Prameela Rani Garnepudi
2016-09-12 12:05   ` kbuild test robot
2016-09-12 12:05   ` [PATCH] rsi: fix ifnullfree.cocci warnings kbuild test robot
2016-09-12  9:38 ` [PATCH 4/9] rsi: code clean up in file rsi_91x_main.c Prameela Rani Garnepudi
2016-09-12  9:38 ` [PATCH 5/9] rsi: code cleanup in file rsi_91x_mgmt.c Prameela Rani Garnepudi
2016-09-12  9:38 ` [PATCH 6/9] rsi: code cleanup (spelling mistakes and new line after declaration) in file rsi_91x_sdio.c Added developer name Prameela Rani Garnepudi
2016-09-12  9:38 ` [PATCH 7/9] rsi: zone changed for debug message and cleanup in file rsi_91x_sdio_ops.c Prameela Rani Garnepudi
2016-09-12  9:38 ` Prameela Rani Garnepudi [this message]
2016-09-12  9:38 ` [PATCH 9/9] rsi: code cleanup in file rsi_91x_usb_ops.c Prameela Rani Garnepudi
2016-09-12 12:53 ` [PATCH 0/9] rsi: code clean-up Kalle Valo
2016-09-12 18:50   ` Joe Perches

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=340487567235056703e4c97170c63cb719fa5460.1473669618.git.prameela.j04cs@gmail.com \
    --to=prameela.j04cs@gmail.com \
    --cc=hofrat@osadl.org \
    --cc=johannes.berg@intel.com \
    --cc=kvalo@codeaurora.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=prameela.garnepudi@redpinesignals.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.