mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH net-next 0/3] r8152: rtl_ops_init modify
@ 2014-11-06  4:47 Hayes Wang
  2014-11-06  4:47 ` [PATCH net-next 1/3] r8152: move r8152b_get_version Hayes Wang
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Hayes Wang @ 2014-11-06  4:47 UTC (permalink / raw)
  To: netdev; +Cc: nic_swsd, linux-kernel, linux-usb, Hayes Wang

Initialize the ops through tp->version. This could skip checking
each VID/PID.

Hayes Wang (3):
  r8152: move r8152b_get_version
  r8152: modify rtl_ops_init
  r8152: remove the definitions of the PID

 drivers/net/usb/r8152.c | 92 +++++++++++++++++--------------------------------
 1 file changed, 32 insertions(+), 60 deletions(-)

-- 
1.9.3


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH net-next 1/3] r8152: move r8152b_get_version
  2014-11-06  4:47 [PATCH net-next 0/3] r8152: rtl_ops_init modify Hayes Wang
@ 2014-11-06  4:47 ` Hayes Wang
  2014-11-06  4:47 ` [PATCH net-next 2/3] r8152: modify rtl_ops_init Hayes Wang
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Hayes Wang @ 2014-11-06  4:47 UTC (permalink / raw)
  To: netdev; +Cc: nic_swsd, linux-kernel, linux-usb, Hayes Wang

Move r8152b_get_version() to the location before rtl_ops_init().
Then, the rtl_ops_init() could use tp->version.

Signed-off-by: Hayes Wang <hayeswang@realtek.com>
---
 drivers/net/usb/r8152.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
index fd41675..4b6db8a 100644
--- a/drivers/net/usb/r8152.c
+++ b/drivers/net/usb/r8152.c
@@ -3833,6 +3833,7 @@ static int rtl8152_probe(struct usb_interface *intf,
 	tp->netdev = netdev;
 	tp->intf = intf;
 
+	r8152b_get_version(tp);
 	ret = rtl_ops_init(tp, id);
 	if (ret)
 		goto out;
@@ -3866,11 +3867,9 @@ static int rtl8152_probe(struct usb_interface *intf,
 	tp->mii.phy_id_mask = 0x3f;
 	tp->mii.reg_num_mask = 0x1f;
 	tp->mii.phy_id = R8152_PHY_ID;
-	tp->mii.supports_gmii = 0;
 
 	intf->needs_remote_wakeup = 1;
 
-	r8152b_get_version(tp);
 	tp->rtl_ops.init(tp);
 	set_ethernet_addr(tp);
 
-- 
1.9.3


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH net-next 2/3] r8152: modify rtl_ops_init
  2014-11-06  4:47 [PATCH net-next 0/3] r8152: rtl_ops_init modify Hayes Wang
  2014-11-06  4:47 ` [PATCH net-next 1/3] r8152: move r8152b_get_version Hayes Wang
@ 2014-11-06  4:47 ` Hayes Wang
  2016-06-02  1:47   ` Grant Grundler
  2014-11-06  4:47 ` [PATCH net-next 3/3] r8152: remove the definitions of the PID Hayes Wang
  2014-11-06 20:15 ` [PATCH net-next 0/3] r8152: rtl_ops_init modify David Miller
  3 siblings, 1 reply; 6+ messages in thread
From: Hayes Wang @ 2014-11-06  4:47 UTC (permalink / raw)
  To: netdev; +Cc: nic_swsd, linux-kernel, linux-usb, Hayes Wang

Replace using VID/PID with using tp->version to initialize the ops.

Signed-off-by: Hayes Wang <hayeswang@realtek.com>
---
 drivers/net/usb/r8152.c | 79 ++++++++++++++++++-------------------------------
 1 file changed, 28 insertions(+), 51 deletions(-)

diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
index 4b6db8a..cf1b8a7 100644
--- a/drivers/net/usb/r8152.c
+++ b/drivers/net/usb/r8152.c
@@ -3742,66 +3742,43 @@ static void rtl8153_unload(struct r8152 *tp)
 	r8153_power_cut_en(tp, false);
 }
 
-static int rtl_ops_init(struct r8152 *tp, const struct usb_device_id *id)
+static int rtl_ops_init(struct r8152 *tp)
 {
 	struct rtl_ops *ops = &tp->rtl_ops;
-	int ret = -ENODEV;
-
-	switch (id->idVendor) {
-	case VENDOR_ID_REALTEK:
-		switch (id->idProduct) {
-		case PRODUCT_ID_RTL8152:
-			ops->init		= r8152b_init;
-			ops->enable		= rtl8152_enable;
-			ops->disable		= rtl8152_disable;
-			ops->up			= rtl8152_up;
-			ops->down		= rtl8152_down;
-			ops->unload		= rtl8152_unload;
-			ops->eee_get		= r8152_get_eee;
-			ops->eee_set		= r8152_set_eee;
-			ret = 0;
-			break;
-		case PRODUCT_ID_RTL8153:
-			ops->init		= r8153_init;
-			ops->enable		= rtl8153_enable;
-			ops->disable		= rtl8153_disable;
-			ops->up			= rtl8153_up;
-			ops->down		= rtl8153_down;
-			ops->unload		= rtl8153_unload;
-			ops->eee_get		= r8153_get_eee;
-			ops->eee_set		= r8153_set_eee;
-			ret = 0;
-			break;
-		default:
-			break;
-		}
+	int ret = 0;
+
+	switch (tp->version) {
+	case RTL_VER_01:
+	case RTL_VER_02:
+		ops->init		= r8152b_init;
+		ops->enable		= rtl8152_enable;
+		ops->disable		= rtl8152_disable;
+		ops->up			= rtl8152_up;
+		ops->down		= rtl8152_down;
+		ops->unload		= rtl8152_unload;
+		ops->eee_get		= r8152_get_eee;
+		ops->eee_set		= r8152_set_eee;
 		break;
 
-	case VENDOR_ID_SAMSUNG:
-		switch (id->idProduct) {
-		case PRODUCT_ID_SAMSUNG:
-			ops->init		= r8153_init;
-			ops->enable		= rtl8153_enable;
-			ops->disable		= rtl8153_disable;
-			ops->up			= rtl8153_up;
-			ops->down		= rtl8153_down;
-			ops->unload		= rtl8153_unload;
-			ops->eee_get		= r8153_get_eee;
-			ops->eee_set		= r8153_set_eee;
-			ret = 0;
-			break;
-		default:
-			break;
-		}
+	case RTL_VER_03:
+	case RTL_VER_04:
+	case RTL_VER_05:
+		ops->init		= r8153_init;
+		ops->enable		= rtl8153_enable;
+		ops->disable		= rtl8153_disable;
+		ops->up			= rtl8153_up;
+		ops->down		= rtl8153_down;
+		ops->unload		= rtl8153_unload;
+		ops->eee_get		= r8153_get_eee;
+		ops->eee_set		= r8153_set_eee;
 		break;
 
 	default:
+		ret = -ENODEV;
+		netif_err(tp, probe, tp->netdev, "Unknown Device\n");
 		break;
 	}
 
-	if (ret)
-		netif_err(tp, probe, tp->netdev, "Unknown Device\n");
-
 	return ret;
 }
 
@@ -3834,7 +3811,7 @@ static int rtl8152_probe(struct usb_interface *intf,
 	tp->intf = intf;
 
 	r8152b_get_version(tp);
-	ret = rtl_ops_init(tp, id);
+	ret = rtl_ops_init(tp);
 	if (ret)
 		goto out;
 
-- 
1.9.3


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH net-next 3/3] r8152: remove the definitions of the PID
  2014-11-06  4:47 [PATCH net-next 0/3] r8152: rtl_ops_init modify Hayes Wang
  2014-11-06  4:47 ` [PATCH net-next 1/3] r8152: move r8152b_get_version Hayes Wang
  2014-11-06  4:47 ` [PATCH net-next 2/3] r8152: modify rtl_ops_init Hayes Wang
@ 2014-11-06  4:47 ` Hayes Wang
  2014-11-06 20:15 ` [PATCH net-next 0/3] r8152: rtl_ops_init modify David Miller
  3 siblings, 0 replies; 6+ messages in thread
From: Hayes Wang @ 2014-11-06  4:47 UTC (permalink / raw)
  To: netdev; +Cc: nic_swsd, linux-kernel, linux-usb, Hayes Wang

The PIDs are only used in the id table, so the definitions are
unnacessary. Remove them wouldn't have confusion.

Signed-off-by: Hayes Wang <hayeswang@realtek.com>
---
 drivers/net/usb/r8152.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
index cf1b8a7..66b139a 100644
--- a/drivers/net/usb/r8152.c
+++ b/drivers/net/usb/r8152.c
@@ -461,11 +461,7 @@ enum rtl8152_flags {
 
 /* Define these values to match your device */
 #define VENDOR_ID_REALTEK		0x0bda
-#define PRODUCT_ID_RTL8152		0x8152
-#define PRODUCT_ID_RTL8153		0x8153
-
 #define VENDOR_ID_SAMSUNG		0x04e8
-#define PRODUCT_ID_SAMSUNG		0xa101
 
 #define MCU_TYPE_PLA			0x0100
 #define MCU_TYPE_USB			0x0000
@@ -3898,9 +3894,9 @@ static void rtl8152_disconnect(struct usb_interface *intf)
 
 /* table of devices that work with this driver */
 static struct usb_device_id rtl8152_table[] = {
-	{USB_DEVICE(VENDOR_ID_REALTEK, PRODUCT_ID_RTL8152)},
-	{USB_DEVICE(VENDOR_ID_REALTEK, PRODUCT_ID_RTL8153)},
-	{USB_DEVICE(VENDOR_ID_SAMSUNG, PRODUCT_ID_SAMSUNG)},
+	{USB_DEVICE(VENDOR_ID_REALTEK, 0x8152)},
+	{USB_DEVICE(VENDOR_ID_REALTEK, 0x8153)},
+	{USB_DEVICE(VENDOR_ID_SAMSUNG, 0xa101)},
 	{}
 };
 
-- 
1.9.3


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH net-next 0/3] r8152: rtl_ops_init modify
  2014-11-06  4:47 [PATCH net-next 0/3] r8152: rtl_ops_init modify Hayes Wang
                   ` (2 preceding siblings ...)
  2014-11-06  4:47 ` [PATCH net-next 3/3] r8152: remove the definitions of the PID Hayes Wang
@ 2014-11-06 20:15 ` David Miller
  3 siblings, 0 replies; 6+ messages in thread
From: David Miller @ 2014-11-06 20:15 UTC (permalink / raw)
  To: hayeswang; +Cc: netdev, nic_swsd, linux-kernel, linux-usb

From: Hayes Wang <hayeswang@realtek.com>
Date: Thu, 6 Nov 2014 12:47:37 +0800

> Initialize the ops through tp->version. This could skip checking
> each VID/PID.

Series applied, thank you.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH net-next 2/3] r8152: modify rtl_ops_init
  2014-11-06  4:47 ` [PATCH net-next 2/3] r8152: modify rtl_ops_init Hayes Wang
@ 2016-06-02  1:47   ` Grant Grundler
  0 siblings, 0 replies; 6+ messages in thread
From: Grant Grundler @ 2016-06-02  1:47 UTC (permalink / raw)
  To: linux-kernel

Hayes Wang <hayeswang <at> realtek.com> writes:
> Replace using VID/PID with using tp->version to initialize the ops.

Hayes,
This patch breaks new HW with existing drivers. more below.

> 
> Signed-off-by: Hayes Wang <hayeswang <at> realtek.com>
> ---
>  drivers/net/usb/r8152.c | 79 ++++++++++++++++++--------------------------
-----
>  1 file changed, 28 insertions(+), 51 deletions(-)
> 
> diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
> index 4b6db8a..cf1b8a7 100644
> --- a/drivers/net/usb/r8152.c
> +++ b/drivers/net/usb/r8152.c
>  <at>  <at>  -3742,66 +3742,43  <at>  <at>  static void 
rtl8153_unload(struct r8152 *tp)
>  	r8153_power_cut_en(tp, false);
>  }
> 
> -static int rtl_ops_init(struct r8152 *tp, const struct usb_device_id *id)
> +static int rtl_ops_init(struct r8152 *tp)
>  {
>  	struct rtl_ops *ops = &tp->rtl_ops;
> -	int ret = -ENODEV;
> -
> -	switch (id->idVendor) {
> -	case VENDOR_ID_REALTEK:
> -		switch (id->idProduct) {
...
>  	default:
> +		ret = -ENODEV;
> +		netif_err(tp, probe, tp->netdev, "Unknown Device\n");

This hunk causes r8152 driver to refuse to bind to a device that was working 
(AFAICT) before this change.  This means every new version of the HW 
requires a driver update for every kernel in every distribution that 
incorporates this patch.

I've tried to "align" chromeos-3.18 branch with kernel.org r8152 driver:

I'm getting this output in dmesg:
r8152 2-1:1.0 (unnamed net_device) (uninitialized): Unknown version 0x6010
r8152 2-1:1.0 (unnamed net_device) (uninitialized): Unknown Device

Could you take a look at the hack I've uploaded for chromeos-3.18 kernel:
    https://chromium-review.googlesource.com/348951

cheers,
grant

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2016-06-02  1:50 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-11-06  4:47 [PATCH net-next 0/3] r8152: rtl_ops_init modify Hayes Wang
2014-11-06  4:47 ` [PATCH net-next 1/3] r8152: move r8152b_get_version Hayes Wang
2014-11-06  4:47 ` [PATCH net-next 2/3] r8152: modify rtl_ops_init Hayes Wang
2016-06-02  1:47   ` Grant Grundler
2014-11-06  4:47 ` [PATCH net-next 3/3] r8152: remove the definitions of the PID Hayes Wang
2014-11-06 20:15 ` [PATCH net-next 0/3] r8152: rtl_ops_init modify David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®