From: Felipe Balbi <balbi@ti.com>
To: Vivek Gautam <gautam.vivek@samsung.com>
Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-omap@vger.kernel.org, gregkh@linuxfoundation.org,
balbi@ti.com, kishon@ti.com
Subject: Re: [PATCH RFC] usb: dwc3: Set GCTL.PrtCapDir based on selected mode.
Date: Mon, 25 Feb 2013 10:17:23 +0200 [thread overview]
Message-ID: <20130225081723.GD25749@arwen.pp.htv.fi> (raw)
In-Reply-To: <1360071958-20797-1-git-send-email-gautam.vivek@samsung.com>
[-- Attachment #1: Type: text/plain, Size: 4078 bytes --]
Hi,
On Tue, Feb 05, 2013 at 07:15:58PM +0530, Vivek Gautam wrote:
> Now that machines may select the mode of working of DWC3,
> we can set the Port capability direction based on selected mode.
>
> Signed-off-by: Vivek Gautam <gautam.vivek@samsung.com>
> ---
> drivers/usb/dwc3/core.c | 11 ++++++++---
> 1 files changed, 8 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
> index 177f4c6..f4c47f7 100644
> --- a/drivers/usb/dwc3/core.c
> +++ b/drivers/usb/dwc3/core.c
> @@ -479,7 +479,6 @@ static int dwc3_probe(struct platform_device *pdev)
>
> switch (mode) {
> case DWC3_MODE_DEVICE:
> - dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_DEVICE);
> ret = dwc3_gadget_init(dwc);
> if (ret) {
> dev_err(dev, "failed to initialize gadget\n");
> @@ -487,7 +486,6 @@ static int dwc3_probe(struct platform_device *pdev)
> }
> break;
> case DWC3_MODE_HOST:
> - dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_HOST);
> ret = dwc3_host_init(dwc);
> if (ret) {
> dev_err(dev, "failed to initialize host\n");
> @@ -495,7 +493,6 @@ static int dwc3_probe(struct platform_device *pdev)
> }
> break;
> case DWC3_MODE_DRD:
> - dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_OTG);
> ret = dwc3_host_init(dwc);
> if (ret) {
> dev_err(dev, "failed to initialize host\n");
> @@ -514,6 +511,14 @@ static int dwc3_probe(struct platform_device *pdev)
> }
> dwc->mode = mode;
>
> +#if IS_ENABLED(CONFIG_USB_DWC3_HOST)
> + dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_HOST);
> +#elif IS_ENABLED(CONFIG_USB_DWC3_GADGET)
> + dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_DEVICE);
> +#else
> + dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_OTG);
> +#endif
you can actually use:
if (IS_ENABLED(CONFIG_USB_DWC3_HOST))
dwc3_set_mode(dwc...
else if (IS_ENABLED( ...
...
else
...
instead of pre-processor conditionals. In fact, I have recently written
a patch converting #if IS_ENABLED() to if (IS_ENABLED()) but I haven't
posted yet:
commit 42dbbbc272bc941ec2b0cac51342609e61e13a01
Author: Felipe Balbi <balbi@ti.com>
Date: Fri Feb 22 16:24:49 2013 +0200
usb: dwc3: debugfs: improve debugfs file creation
when commit 388e5c5 (usb: dwc3: remove dwc3
dependency on host AND gadget.) changed the
way debugfs files are created, it failed to
note that 'mode' is necessary in Dual Role
mode only while 'testmode' and 'link_state'
are valid in Dual Role and Peripheral-only
builds. Fix this while also converting pre-
processor conditional to C conditionals.
Signed-off-by: Felipe Balbi <balbi@ti.com>
diff --git a/drivers/usb/dwc3/debugfs.c b/drivers/usb/dwc3/debugfs.c
index a1bac9a..8b23d045 100644
--- a/drivers/usb/dwc3/debugfs.c
+++ b/drivers/usb/dwc3/debugfs.c
@@ -667,28 +667,31 @@ int dwc3_debugfs_init(struct dwc3 *dwc)
goto err1;
}
-#if IS_ENABLED(CONFIG_USB_DWC3_GADGET)
- file = debugfs_create_file("mode", S_IRUGO | S_IWUSR, root,
- dwc, &dwc3_mode_fops);
- if (!file) {
- ret = -ENOMEM;
- goto err1;
+ if (IS_ENABLED(CONFIG_USB_DWC3_DUAL_ROLE)) {
+ file = debugfs_create_file("mode", S_IRUGO | S_IWUSR, root,
+ dwc, &dwc3_mode_fops);
+ if (!file) {
+ ret = -ENOMEM;
+ goto err1;
+ }
}
- file = debugfs_create_file("testmode", S_IRUGO | S_IWUSR, root,
- dwc, &dwc3_testmode_fops);
- if (!file) {
- ret = -ENOMEM;
- goto err1;
- }
-
- file = debugfs_create_file("link_state", S_IRUGO | S_IWUSR, root,
- dwc, &dwc3_link_state_fops);
- if (!file) {
- ret = -ENOMEM;
- goto err1;
+ if (IS_ENABLED(CONFIG_USB_DWC3_DUAL_ROLE) ||
+ IS_ENABLED(CONFIG_USB_DWC3_GADGET)) {
+ file = debugfs_create_file("testmode", S_IRUGO | S_IWUSR, root,
+ dwc, &dwc3_testmode_fops);
+ if (!file) {
+ ret = -ENOMEM;
+ goto err1;
+ }
+
+ file = debugfs_create_file("link_state", S_IRUGO | S_IWUSR, root,
+ dwc, &dwc3_link_state_fops);
+ if (!file) {
+ ret = -ENOMEM;
+ goto err1;
+ }
}
-#endif
return 0;
--
balbi
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
next prev parent reply other threads:[~2013-02-25 8:17 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-02-05 13:45 [PATCH RFC] usb: dwc3: Set GCTL.PrtCapDir based on selected mode Vivek Gautam
2013-02-25 8:17 ` Felipe Balbi [this message]
2013-02-25 8:51 ` Vivek Gautam
2013-02-25 9:19 ` Felipe Balbi
2013-02-25 9:29 ` Vivek Gautam
[not found] ` <CAFp+6iGGAY=nMg03-bqHz=XuNP+1t9mQR=M53HGoqCXv=t+f0Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2013-03-02 13:25 ` [PATCH] usb: dwc3: Set DWC3 context's mode " Vivek Gautam
2013-03-13 9:12 ` Vivek Gautam
2013-03-13 9:14 ` Felipe Balbi
2013-03-13 9:15 ` Vivek Gautam
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=20130225081723.GD25749@arwen.pp.htv.fi \
--to=balbi@ti.com \
--cc=gautam.vivek@samsung.com \
--cc=gregkh@linuxfoundation.org \
--cc=kishon@ti.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-omap@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
/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