From patchwork Sun Apr 7 07:55:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "yiyang \(D\)" X-Patchwork-Id: 786856 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 76007DDBD; Sun, 7 Apr 2024 07:59:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.187 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712476750; cv=none; b=rp00vffms7HIFlyDzD3m6DBFrQsyEVTNwPpkybAf98OCEV2pD8EBprzO6fu5B1VqMzxCiJOxcYv/IOk/DW72QDa9UcmPdQJRH6VTVEnX9gLUvQdYHWe7RHlSdNEXj722r7m+ydYFvULNb8l5aixA0PPp5CkI5BR22QnmsIGgMMw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712476750; c=relaxed/simple; bh=cN2nfIJctyVX2abj+BMVaCeo6vMBONneF88FutMZ6Wc=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=NluZu9DChoDYEqFxPzaH/urarRFDvkSwRG3Na5lZgLnrh9m6h1du3CZT8wJ3Bu14oGB5nPtLNfZBd+RWH3kc/ZFd2IFs56YH+GVO6zILdyKsir0z6NANEdW5LBgYfQDVbH3+t+XgkLeDdMTiSww0TH9xeKLeLLsdePWmWDF/LG0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.187 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.163.252]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4VC4Kp2KPlzwRTB; Sun, 7 Apr 2024 15:56:14 +0800 (CST) Received: from kwepemm600014.china.huawei.com (unknown [7.193.23.54]) by mail.maildlp.com (Postfix) with ESMTPS id 64D82180A9B; Sun, 7 Apr 2024 15:59:06 +0800 (CST) Received: from huawei.com (10.67.174.78) by kwepemm600014.china.huawei.com (7.193.23.54) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Sun, 7 Apr 2024 15:59:05 +0800 From: Yi Yang To: , , , , , CC: , , , Subject: [PATCH net 1/2] net: usb: asix: Add check for usbnet_get_endpoints Date: Sun, 7 Apr 2024 07:55:12 +0000 Message-ID: <20240407075513.923435-2-yiyang13@huawei.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240407075513.923435-1-yiyang13@huawei.com> References: <20240407075513.923435-1-yiyang13@huawei.com> Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To kwepemm600014.china.huawei.com (7.193.23.54) Add check for usbnet_get_endpoints() and return the error if it fails in order to transfer the error. Cc: stable@vger.kernel.org Fixes: 2e55cc7210fe ("[PATCH] USB: usbnet (3/9) module for ASIX Ethernet adapters") Fixes: 4ad1438f025e ("NET: fix phy init for AX88772 USB ethernet") Fixes: 933a27d39e0e ("USB: asix - Add AX88178 support and many other changes") Signed-off-by: Yi Yang --- drivers/net/usb/asix_devices.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/net/usb/asix_devices.c b/drivers/net/usb/asix_devices.c index f7cff58fe044..d8f86bafad6a 100644 --- a/drivers/net/usb/asix_devices.c +++ b/drivers/net/usb/asix_devices.c @@ -230,7 +230,9 @@ static int ax88172_bind(struct usbnet *dev, struct usb_interface *intf) int i; unsigned long gpio_bits = dev->driver_info->data; - usbnet_get_endpoints(dev,intf); + ret = usbnet_get_endpoints(dev, intf); + if (ret) + goto out; /* Toggle the GPIOs in a manufacturer/model specific way */ for (i = 2; i >= 0; i--) { @@ -834,7 +836,9 @@ static int ax88772_bind(struct usbnet *dev, struct usb_interface *intf) dev->driver_priv = priv; - usbnet_get_endpoints(dev, intf); + ret = usbnet_get_endpoints(dev, intf); + if (ret) + return ret; /* Maybe the boot loader passed the MAC address via device tree */ if (!eth_platform_get_mac_address(&dev->udev->dev, buf)) { @@ -1258,7 +1262,9 @@ static int ax88178_bind(struct usbnet *dev, struct usb_interface *intf) int ret; u8 buf[ETH_ALEN] = {0}; - usbnet_get_endpoints(dev,intf); + ret = usbnet_get_endpoints(dev, intf); + if (ret) + return ret; /* Get the MAC address */ ret = asix_read_cmd(dev, AX_CMD_READ_NODE_ID, 0, 0, ETH_ALEN, buf, 0); From patchwork Sun Apr 7 07:55:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "yiyang \(D\)" X-Patchwork-Id: 786855 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C7522F4E7; Sun, 7 Apr 2024 07:59:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.188 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712476750; cv=none; b=uiAfq5Z5ka8lHxz/rAPL3mYy3UJ9mTMfBviU+TgduSNcXvusyL5JXafI3CzbuE17wN9NEUK9xdE5YUUWA6S2eTQm0mhD0au2de4k+VfVW1mJ2KL5h5bsP5TfHYh+sKygvosSTmirkFE8BfZCclxjIkxP8wEGevOSXaugVtrvv98= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712476750; c=relaxed/simple; bh=umpEPG5e4IRUn6CQljWlAIot08VG+XtIQj73ktnnmY0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=omd83Mm5L690Gfj92UtGN4hSaplk3S3VfM3Em5iipTyqhtYJ+FIT4MjwzmxVdtnnqhv0ZUlwUyJAgqcjvxrMnznXKGLvpJ/LMIF9iAqvzLjTZwnP/bV7R/zH5D9pfeEjDSQNViXPpU2KHqjb3yvWlebwPN4Sg97ZLxomdwrcRVs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.188 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.88.105]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4VC4N20xm9zbfMx; Sun, 7 Apr 2024 15:58:10 +0800 (CST) Received: from kwepemm600014.china.huawei.com (unknown [7.193.23.54]) by mail.maildlp.com (Postfix) with ESMTPS id D9C3D14010C; Sun, 7 Apr 2024 15:59:06 +0800 (CST) Received: from huawei.com (10.67.174.78) by kwepemm600014.china.huawei.com (7.193.23.54) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Sun, 7 Apr 2024 15:59:06 +0800 From: Yi Yang To: , , , , , CC: , , , Subject: [PATCH net 2/2] net: usb: asix: Replace the direct return with goto statement Date: Sun, 7 Apr 2024 07:55:13 +0000 Message-ID: <20240407075513.923435-3-yiyang13@huawei.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240407075513.923435-1-yiyang13@huawei.com> References: <20240407075513.923435-1-yiyang13@huawei.com> Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To kwepemm600014.china.huawei.com (7.193.23.54) Replace the direct return statement in ax88772_bind() with goto, to adhere to the kernel coding style. Signed-off-by: Yi Yang --- drivers/net/usb/asix_devices.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/net/usb/asix_devices.c b/drivers/net/usb/asix_devices.c index d8f86bafad6a..11417ed86d9e 100644 --- a/drivers/net/usb/asix_devices.c +++ b/drivers/net/usb/asix_devices.c @@ -838,7 +838,7 @@ static int ax88772_bind(struct usbnet *dev, struct usb_interface *intf) ret = usbnet_get_endpoints(dev, intf); if (ret) - return ret; + goto mdio_err; /* Maybe the boot loader passed the MAC address via device tree */ if (!eth_platform_get_mac_address(&dev->udev->dev, buf)) { @@ -862,7 +862,7 @@ static int ax88772_bind(struct usbnet *dev, struct usb_interface *intf) if (ret < 0) { netdev_dbg(dev->net, "Failed to read MAC address: %d\n", ret); - return ret; + goto mdio_err; } } @@ -875,7 +875,7 @@ static int ax88772_bind(struct usbnet *dev, struct usb_interface *intf) ret = asix_read_phy_addr(dev, true); if (ret < 0) - return ret; + goto mdio_err; priv->phy_addr = ret; priv->embd_phy = ((priv->phy_addr & 0x1f) == AX_EMBD_PHY_ADDR); @@ -884,7 +884,7 @@ static int ax88772_bind(struct usbnet *dev, struct usb_interface *intf) &priv->chipcode, 0); if (ret < 0) { netdev_dbg(dev->net, "Failed to read STATMNGSTS_REG: %d\n", ret); - return ret; + goto mdio_err; } priv->chipcode &= AX_CHIPCODE_MASK; @@ -899,7 +899,7 @@ static int ax88772_bind(struct usbnet *dev, struct usb_interface *intf) ret = priv->reset(dev, 0); if (ret < 0) { netdev_dbg(dev->net, "Failed to reset AX88772: %d\n", ret); - return ret; + goto mdio_err; } /* Asix framing packs multiple eth frames into a 2K usb bulk transfer */