From: Oliver Neukum <oneukum@suse.com>
To: Hayes Wang <hayeswang@realtek.com>
Cc: netdev@vger.kernel.org, nic_swsd@realtek.com,
linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org
Subject: Re: [PATCH net 1/2] r8152: add pre_reset and post_reset
Date: Tue, 28 Jul 2015 10:52:42 +0200 [thread overview]
Message-ID: <1438073562.11934.2.camel@suse.com> (raw)
In-Reply-To: <1394712342-15778-157-Taiwan-albertk@realtek.com>
On Tue, 2015-07-28 at 15:36 +0800, Hayes Wang wrote:
> Add rtl8152_pre_reset() and rtl8152_post_reset() which are used when
> calling usb_reset_device(). The two functions could reduce the time
> of reset when calling usb_reset_device() after probe().
>
> Signed-off-by: Hayes Wang <hayeswang@realtek.com>
> ---
> drivers/net/usb/r8152.c | 68 +++++++++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 68 insertions(+)
>
> diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
> index 144dc64..a6caa60 100644
> --- a/drivers/net/usb/r8152.c
> +++ b/drivers/net/usb/r8152.c
> @@ -3342,6 +3342,72 @@ static void r8153_init(struct r8152 *tp)
> r8153_u2p3en(tp, true);
> }
>
> +static int rtl8152_pre_reset(struct usb_interface *intf)
> +{
> + struct r8152 *tp = usb_get_intfdata(intf);
> + struct net_device *netdev;
> + int ret;
> +
> + if (intf->condition != USB_INTERFACE_BOUND || !tp)
If the interface weren't bound, you wouldn't be called.
> + return 0;
> +
> + netdev = tp->netdev;
> + if (!netif_running(netdev))
> + return 0;
> +
> + ret = usb_autopm_get_interface(intf);
> + if (ret < 0)
> + return ret;
What sense does this make?
> +
> + napi_disable(&tp->napi);
> + clear_bit(WORK_ENABLE, &tp->flags);
> + usb_kill_urb(tp->intr_urb);
> + cancel_delayed_work_sync(&tp->schedule);
> + if (netif_carrier_ok(netdev)) {
> + netif_stop_queue(netdev);
> + mutex_lock(&tp->control);
> + tp->rtl_ops.disable(tp);
> + mutex_unlock(&tp->control);
> + }
> +
> + usb_autopm_put_interface(intf);
> +
> + return 0;
> +}
> +
> +static int rtl8152_post_reset(struct usb_interface *intf)
> +{
> + struct r8152 *tp = usb_get_intfdata(intf);
> + struct net_device *netdev;
> + int ret;
> +
> + if (intf->condition != USB_INTERFACE_BOUND || !tp)
Again unnecessary
> + return 0;
> +
> + netdev = tp->netdev;
> + if (!netif_running(netdev))
> + return 0;
> +
> + ret = usb_autopm_get_interface(intf);
The device will be awake.
> + if (ret < 0)
> + return ret;
> +
> + set_bit(WORK_ENABLE, &tp->flags);
> + if (netif_carrier_ok(netdev)) {
> + mutex_lock(&tp->control);
> + tp->rtl_ops.enable(tp);
> + rtl8152_set_rx_mode(netdev);
> + mutex_unlock(&tp->control);
> + netif_wake_queue(netdev);
> + }
> +
> + napi_enable(&tp->napi);
> +
> + usb_autopm_put_interface(intf);
> +
> + return ret;
> +}
> +
HTH
Oliver
next prev parent reply other threads:[~2015-07-28 8:52 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-28 7:36 [PATCH net 0/2] r8152: device reset Hayes Wang
2015-07-28 7:36 ` [PATCH net 1/2] r8152: add pre_reset and post_reset Hayes Wang
2015-07-28 8:52 ` Oliver Neukum [this message]
[not found] ` <1438073562.11934.2.camel-IBi9RG/b67k@public.gmane.org>
2015-07-28 9:52 ` Hayes Wang
2015-07-28 12:05 ` Oliver Neukum
2015-07-28 7:36 ` [PATCH net 2/2] r8152: reset device when tx timeout Hayes Wang
2015-07-28 8:56 ` Oliver Neukum
2015-07-28 9:52 ` Hayes Wang
2015-07-28 12:08 ` [PATCH net v2 0/2] r8152: device reset Hayes Wang
2015-07-28 12:08 ` [PATCH net v2 1/2] r8152: add pre_reset and post_reset Hayes Wang
2015-07-28 12:08 ` [PATCH net v2 2/2] r8152: reset device when tx timeout Hayes Wang
2015-07-28 12:14 ` Oliver Neukum
2015-07-28 12:31 ` Hayes Wang
2015-07-28 12:58 ` Oliver Neukum
2015-07-29 2:06 ` Hayes Wang
2015-07-29 7:22 ` Oliver Neukum
2015-07-29 11:09 ` Hayes Wang
2015-07-29 12:39 ` [PATCH net v3 0/2] r8152: device reset Hayes Wang
2015-07-29 12:39 ` [PATCH net v3 1/2] r8152: add pre_reset and post_reset Hayes Wang
2015-07-29 12:39 ` [PATCH net v3 2/2] r8152: reset device when tx timeout Hayes Wang
2015-07-30 21:04 ` [PATCH net v3 0/2] r8152: device reset David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1438073562.11934.2.camel@suse.com \
--to=oneukum@suse.com \
--cc=hayeswang@realtek.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=nic_swsd@realtek.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).