diff mbox series

[2/2] net: rtl8150: convert control messages to the new send/recv scheme.

Message ID 20200925160200.4364-3-petkan@nucleusys.com (mailing list archive)
State New, archived
Headers show
Series utilize the new control message send and receive API | expand

Commit Message

Petko Manolov Sept. 25, 2020, 4:02 p.m. UTC
From: Petko Manolov <petko.manolov@konsulko.com>

Move all control transfers to safer usb_control_msg_send/recv() API.

Signed-off-by: Petko Manolov <petko.manolov@konsulko.com>
---
 drivers/net/usb/rtl8150.c | 32 ++++++--------------------------
 1 file changed, 6 insertions(+), 26 deletions(-)

Comments

kernel test robot Sept. 25, 2020, 8:14 p.m. UTC | #1
Hi Petko,

I love your patch! Yet something to improve:

[auto build test ERROR on linus/master]
[also build test ERROR on v5.9-rc6 next-20200925]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Petko-Manolov/utilize-the-new-control-message-send-and-receive-API/20200926-000418
base:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 171d4ff79f965c1f164705ef0aaea102a6ad238b
config: sh-allmodconfig (attached as .config)
compiler: sh4-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/0day-ci/linux/commit/dc81887ca37bd0f3530fae6a7ab5979b30e0b21e
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Petko-Manolov/utilize-the-new-control-message-send-and-receive-API/20200926-000418
        git checkout dc81887ca37bd0f3530fae6a7ab5979b30e0b21e
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=sh 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All error/warnings (new ones prefixed by >>):

   drivers/net/usb/rtl8150.c: In function 'get_registers':
>> drivers/net/usb/rtl8150.c:155:2: error: 'ret' undeclared (first use in this function); did you mean 'net'?
     155 |  ret = usb_control_msg_recv(dev->udev, 0, RTL8150_REQ_GET_REGS,
         |  ^~~
         |  net
   drivers/net/usb/rtl8150.c:155:2: note: each undeclared identifier is reported only once for each function it appears in
   drivers/net/usb/rtl8150.c:155:8: error: implicit declaration of function 'usb_control_msg_recv'; did you mean 'usb_control_msg'? [-Werror=implicit-function-declaration]
     155 |  ret = usb_control_msg_recv(dev->udev, 0, RTL8150_REQ_GET_REGS,
         |        ^~~~~~~~~~~~~~~~~~~~
         |        usb_control_msg
>> drivers/net/usb/rtl8150.c:158:1: warning: no return statement in function returning non-void [-Wreturn-type]
     158 | }
         | ^
   drivers/net/usb/rtl8150.c: In function 'set_registers':
   drivers/net/usb/rtl8150.c:162:2: error: 'ret' undeclared (first use in this function); did you mean 'net'?
     162 |  ret = usb_control_msg_send(dev->udev, 0, RTL8150_REQ_SET_REGS,
         |  ^~~
         |  net
   drivers/net/usb/rtl8150.c:162:8: error: implicit declaration of function 'usb_control_msg_send'; did you mean 'usb_control_msg'? [-Werror=implicit-function-declaration]
     162 |  ret = usb_control_msg_send(dev->udev, 0, RTL8150_REQ_SET_REGS,
         |        ^~~~~~~~~~~~~~~~~~~~
         |        usb_control_msg
   drivers/net/usb/rtl8150.c:165:1: warning: no return statement in function returning non-void [-Wreturn-type]
     165 | }
         | ^
   cc1: some warnings being treated as errors

vim +155 drivers/net/usb/rtl8150.c

   147	
   148	/*
   149	**
   150	**	device related part of the code
   151	**
   152	*/
   153	static int get_registers(rtl8150_t * dev, u16 indx, u16 size, void *data)
   154	{
 > 155		ret = usb_control_msg_recv(dev->udev, 0, RTL8150_REQ_GET_REGS,
   156					   RTL8150_REQT_READ, indx, 0, data, size,
   157					   1000, GFP_NOIO);
 > 158	}
   159	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
diff mbox series

Patch

diff --git a/drivers/net/usb/rtl8150.c b/drivers/net/usb/rtl8150.c
index 733f120c852b..f76d20d290d9 100644
--- a/drivers/net/usb/rtl8150.c
+++ b/drivers/net/usb/rtl8150.c
@@ -152,36 +152,16 @@  static const char driver_name [] = "rtl8150";
 */
 static int get_registers(rtl8150_t * dev, u16 indx, u16 size, void *data)
 {
-	void *buf;
-	int ret;
-
-	buf = kmalloc(size, GFP_NOIO);
-	if (!buf)
-		return -ENOMEM;
-
-	ret = usb_control_msg(dev->udev, usb_rcvctrlpipe(dev->udev, 0),
-			      RTL8150_REQ_GET_REGS, RTL8150_REQT_READ,
-			      indx, 0, buf, size, 500);
-	if (ret > 0 && ret <= size)
-		memcpy(data, buf, ret);
-	kfree(buf);
-	return ret;
+	ret = usb_control_msg_recv(dev->udev, 0, RTL8150_REQ_GET_REGS,
+				   RTL8150_REQT_READ, indx, 0, data, size,
+				   1000, GFP_NOIO);
 }
 
 static int set_registers(rtl8150_t * dev, u16 indx, u16 size, const void *data)
 {
-	void *buf;
-	int ret;
-
-	buf = kmemdup(data, size, GFP_NOIO);
-	if (!buf)
-		return -ENOMEM;
-
-	ret = usb_control_msg(dev->udev, usb_sndctrlpipe(dev->udev, 0),
-			      RTL8150_REQ_SET_REGS, RTL8150_REQT_WRITE,
-			      indx, 0, buf, size, 500);
-	kfree(buf);
-	return ret;
+	ret = usb_control_msg_send(dev->udev, 0, RTL8150_REQ_SET_REGS,
+				   RTL8150_REQT_WRITE, indx, 0, data, size,
+				   1000, GFP_NOIO);
 }
 
 static void async_set_reg_cb(struct urb *urb)