From: Olof Johansson <olof@lixom•net>
To: tmarri@apm•com
Cc: Mark Miesfeld <mmiesfeld@apm•com>,
greg@kroah•com, linux-usb@vger•kernel.org,
linuxppc-dev@lists•ozlabs.org, Fushen Chen <fchen@apm•com>
Subject: Re: [PATCH v15 04/10] USB/ppc4xx: Add Synopsys DWC OTG HCD function
Date: Fri, 21 Oct 2011 10:48:13 -0700 [thread overview]
Message-ID: <20111021174813.GD27652@quad.lixom.net> (raw)
In-Reply-To: <1318630133-14264-1-git-send-email-tmarri@apm.com>
Some more hit-and-run comments.
On Fri, Oct 14, 2011 at 03:08:53PM -0700, tmarri@apm•com wrote:
> +static int dwc_otg_hcd_disconnect_cb(void *_p)
> +{
> + u32 intr;
> + struct dwc_hcd *hcd = hcd_to_dwc_otg_hcd(_p);
> + struct core_if *core_if = hcd->core_if;
> +
> + /* Set status flags for the hub driver. */
> + hcd->flags.b.port_connect_status_change = 1;
> + hcd->flags.b.port_connect_status = 0;
> +
> + /*
> + * Shutdown any transfers in process by clearing the Tx FIFO Empty
> + * interrupt mask and status bits and disabling subsequent host
> + * channel interrupts.
> + */
> + intr = 0;
> + intr |= DWC_INTMSK_NP_TXFIFO_EMPT;
> + intr |= DWC_INTMSK_P_TXFIFO_EMPTY;
> + intr |= DWC_INTMSK_HST_CHAN;
> + spin_lock(&hcd->lock);
> + dwc_reg_modify(gintmsk_reg(hcd), 0, intr, 0);
> + dwc_reg_modify(gintsts_reg(hcd), 0, intr, 0);
> + spin_unlock(&hcd->lock);
> +
> + del_timers(hcd);
> +
> + /*
> + * Turn off the vbus power only if the core has transitioned to device
> + * mode. If still in host mode, need to keep power on to detect a
> + * reconnection.
> + */
> + if (dwc_otg_is_device_mode(core_if)) {
> + if (core_if->xceiv->state != OTG_STATE_A_SUSPEND) {
> + u32 hprt0 = 0;
> +
> + pr_info("Disconnect: PortPower off\n");
> + hprt0 = DWC_HPRT0_PRT_PWR_RW(hprt0, 0);
> + dwc_reg_write(core_if->host_if->hprt0, 0, hprt0);
> + }
> + dwc_otg_disable_host_interrupts(core_if);
> + }
> +
> + /* Respond with an error status to all URBs in the schedule. */
> + kill_all_urbs(hcd);
> + if (dwc_otg_is_host_mode(core_if)) {
> + /* Clean up any host channels that were in use. */
> + int num_channels;
> + u32 i;
> + struct dwc_hc *channel;
> + ulong regs;
> + u32 hcchar;
If you need these many local variables here, and this much indentation, then
please refactor to a helper function. That will get rid of the crazy
linewrapping below too.
> +
> + num_channels = core_if->core_params->host_channels;
> + if (!core_if->dma_enable) {
> + /* Flush out any channel requests in slave mode. */
> + for (i = 0; i < num_channels; i++) {
> + channel = hcd->hc_ptr_array[i];
> + if (list_empty(&channel->hc_list_entry)) {
> + regs =
> + core_if->host_if->hc_regs[i];
> + hcchar = dwc_reg_read(regs, DWC_HCCHAR);
> +
> + if (DWC_HCCHAR_ENA_RD(hcchar)) {
> + hcchar =
> + DWC_HCCHAR_ENA_RW(hcchar,
> + 0);
> + hcchar =
> + DWC_HCCHAR_DIS_RW(hcchar,
> + 1);
> + hcchar =
> + DWC_HCCHAR_EPDIR_RW(hcchar,
> + 0);
> + dwc_reg_write(regs, DWC_HCCHAR,
> + hcchar);
> + }
> + }
> + }
> + }
> +
> + for (i = 0; i < num_channels; i++) {
> + channel = hcd->hc_ptr_array[i];
> + if (list_empty(&channel->hc_list_entry)) {
> + regs = core_if->host_if->hc_regs[i];
> + hcchar = dwc_reg_read(regs, DWC_HCCHAR);
> +
> + if (DWC_HCCHAR_ENA_RD(hcchar)) {
> + /* Halt the channel. */
> + hcchar = DWC_HCCHAR_DIS_RW(hcchar, 1);
> + dwc_reg_write(regs, DWC_HCCHAR, hcchar);
> + }
> + dwc_otg_hc_cleanup(core_if, channel);
> + list_add_tail(&channel->hc_list_entry,
> + &hcd->free_hc_list);
> + }
> + }
> + }
> +
> + /*
> + * A disconnect will end the session so the B-Device is no
> + * longer a B-host.
> + */
> + ((struct usb_hcd *)_p)->self.is_b_host = 0;
> + return 1;
> +}
> +
-Olof
prev parent reply other threads:[~2011-10-21 17:48 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-10-14 22:08 [PATCH v15 04/10] USB/ppc4xx: Add Synopsys DWC OTG HCD function tmarri
2011-10-20 9:13 ` Pratyush Anand
2011-10-21 17:48 ` Olof Johansson [this message]
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=20111021174813.GD27652@quad.lixom.net \
--to=olof@lixom$(echo .)net \
--cc=fchen@apm$(echo .)com \
--cc=greg@kroah$(echo .)com \
--cc=linux-usb@vger$(echo .)kernel.org \
--cc=linuxppc-dev@lists$(echo .)ozlabs.org \
--cc=mmiesfeld@apm$(echo .)com \
--cc=tmarri@apm$(echo .)com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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