diff mbox series

[net,2/9] r8152: reset flow control patch when linking on for RTL8153B

Message ID 1394712342-15778-340-Taiwan-albertk@realtek.com (mailing list archive)
State Superseded
Headers show
Series r8152: serial fixes | expand

Commit Message

Hayes Wang Jan. 21, 2020, 12:40 p.m. UTC
When linking ON, the patch of flow control has to be reset. This
makes sure the patch works normally.

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

Comments

David Miller Jan. 21, 2020, 12:54 p.m. UTC | #1
From: Hayes Wang <hayeswang@realtek.com>
Date: Tue, 21 Jan 2020 20:40:28 +0800

> When linking ON, the patch of flow control has to be reset. This
> makes sure the patch works normally.
> 
> Signed-off-by: Hayes Wang <hayeswang@realtek.com>
> ---
>  drivers/net/usb/r8152.c | 10 ++++++++++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
> index 115559707683..64efd58279b3 100644
> --- a/drivers/net/usb/r8152.c
> +++ b/drivers/net/usb/r8152.c
> @@ -2857,6 +2857,7 @@ static void r8153_set_rx_early_size(struct r8152 *tp)
>  
>  static int rtl8153_enable(struct r8152 *tp)
>  {
> +	u32 ocp_data;
>  	if (test_bit(RTL8152_UNPLUG, &tp->flags))
>  		return -ENODEV;
>  

Please put an empty line after the local variable declarations.

Thank you.
Joe Perches Jan. 21, 2020, 1:01 p.m. UTC | #2
On Tue, 2020-01-21 at 13:54 +0100, David Miller wrote:
> From: Hayes Wang <hayeswang@realtek.com>
> Date: Tue, 21 Jan 2020 20:40:28 +0800
> 
> > When linking ON, the patch of flow control has to be reset. This
> > makes sure the patch works normally.
[]
> > diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
[]
> > @@ -2857,6 +2857,7 @@ static void r8153_set_rx_early_size(struct r8152 *tp)
> >  
> >  static int rtl8153_enable(struct r8152 *tp)
> >  {
> > +     u32 ocp_data;
> >       if (test_bit(RTL8152_UNPLUG, &tp->flags))
> >               return -ENODEV;
> >  
> 
> Please put an empty line after the local variable declarations.

Local scoping is generally better.

Perhaps declare ocp_data inside the if branch
where it's used.
Hayes Wang Jan. 21, 2020, 1:19 p.m. UTC | #3
Joe Perches [mailto:joe@perches.com]
> Sent: Tuesday, January 21, 2020 9:01 PM
> To: David Miller; Hayes Wang
[...]
> > >  static int rtl8153_enable(struct r8152 *tp)
> > >  {
> > > +     u32 ocp_data;
> > >       if (test_bit(RTL8152_UNPLUG, &tp->flags))
> > >               return -ENODEV;
> > >
> >
> > Please put an empty line after the local variable declarations.
> 
> Local scoping is generally better.
> 
> Perhaps declare ocp_data inside the if branch
> where it's used.

OK. I would move it.

Best Regards,
Hayes
diff mbox series

Patch

diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
index 115559707683..64efd58279b3 100644
--- a/drivers/net/usb/r8152.c
+++ b/drivers/net/usb/r8152.c
@@ -2857,6 +2857,7 @@  static void r8153_set_rx_early_size(struct r8152 *tp)
 
 static int rtl8153_enable(struct r8152 *tp)
 {
+	u32 ocp_data;
 	if (test_bit(RTL8152_UNPLUG, &tp->flags))
 		return -ENODEV;
 
@@ -2865,6 +2866,15 @@  static int rtl8153_enable(struct r8152 *tp)
 	r8153_set_rx_early_timeout(tp);
 	r8153_set_rx_early_size(tp);
 
+	if (tp->version == RTL_VER_09) {
+		ocp_data = ocp_read_word(tp, MCU_TYPE_USB, USB_FW_TASK);
+		ocp_data &= ~FC_PATCH_TASK;
+		ocp_write_word(tp, MCU_TYPE_USB, USB_FW_TASK, ocp_data);
+		usleep_range(1000, 2000);
+		ocp_data |= FC_PATCH_TASK;
+		ocp_write_word(tp, MCU_TYPE_USB, USB_FW_TASK, ocp_data);
+	}
+
 	return rtl_enable(tp);
 }