Thread (3 messages) 3 messages, 2 authors, 2d ago

Re: [PATCH] net: usb: net1080: add error handling to nc_vendor_write()

From: Andrew Lunn <andrew@lunn.ch>
Date: 2026-07-27 14:42:27
Also in: linux-usb, lkml

On Mon, Jul 27, 2026 at 07:47:33PM +0530, Ashwin Gundarapu wrote:
quoted
From 70278069430a8b7d71728bc3c24400dc2bdffb63 Mon Sep 17 00:00:00 2001
From: Ashwin Gundarapu <redacted>
Date: Mon, 27 Jul 2026 19:34:16 +0530
Subject: [PATCH] net: usb: net1080: add error handling to nc_vendor_write()

The nc_vendor_write() function currently ignores the return value of
usbnet_write_cmd(). This can lead to silent failures when USB
communication fails.

Change nc_vendor_write() and nc_register_write() to return int
instead of void, and propagate the error from usbnet_write_cmd()
back to the caller.
The caller being:

static int net1080_reset(struct usbnet *dev)
{
	u16		usbctl, status, ttl;
	u16		vp;
	int		retval;

	// nc_dump_registers(dev);

	if ((retval = nc_register_read(dev, REG_STATUS, &vp)) < 0) {
		netdev_dbg(dev->net, "can't read %s-%s status: %d\n",
			   dev->udev->bus->bus_name, dev->udev->devpath, retval);
		goto done;
	}
	status = vp;
	nc_dump_status(dev, status);

	if ((retval = nc_register_read(dev, REG_USBCTL, &vp)) < 0) {
		netdev_dbg(dev->net, "can't read USBCTL, %d\n", retval);
		goto done;
	}
	usbctl = vp;
	nc_dump_usbctl(dev, usbctl);

	nc_register_write(dev, REG_USBCTL,
			USBCTL_FLUSH_THIS | USBCTL_FLUSH_OTHER);

which just ignores the return value. How is this better?

https://www.kernel.org/doc/html/latest/process/maintainer-netdev.html

    Andrew

---
pw-bot: cr
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help