From: Krishna Kurapati <krishna.kurapati@oss.qualcomm.com>
To: zhangsenchuan@eswincomputing.com
Cc: ningyu@eswincomputing.com, robh@kernel.org,
p.zabel@pengutronix.de, Thinh.Nguyen@synopsys.com,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-usb@vger.kernel.org, conor+dt@kernel.org,
krzk+dt@kernel.org, linmin@eswincomputing.com,
yangwei1@eswincomputing.com, gregkh@linuxfoundation.org
Subject: Re: [PATCH v1 2/2] usb: dwc3: eic7700: Add EIC7700 usb driver
Date: Tue, 20 May 2025 11:50:43 +0530 [thread overview]
Message-ID: <a6382f2d-2b66-45d6-b903-da8822f9f883@oss.qualcomm.com> (raw)
In-Reply-To: <20250516095408.704-1-zhangsenchuan@eswincomputing.com>
On 5/16/2025 3:24 PM, zhangsenchuan@eswincomputing.com wrote:
> From: Senchuan Zhang <zhangsenchuan@eswincomputing.com>
>
> Add the eic7700 usb driver, which is responsible for
> identifying,configuring and connecting usb devices,and
> provides interfaces for accessing these devices.
>
> Co-developed-by: Wei Yang <yangwei1@eswincomputing.com>
> Signed-off-by: Wei Yang <yangwei1@eswincomputing.com>
> Signed-off-by: Senchuan Zhang <zhangsenchuan@eswincomputing.com>
> ---
[...]
> +static ssize_t dwc3_mode_show(struct device *device,
> + struct device_attribute *attr, char *buf)
> +{
> + struct dwc3_eswin *eswin = dev_get_drvdata(device);
> + struct dwc3 *dwc = eswin->dwc;
> + int ret;
> +
> + switch (dwc->current_dr_role) {
> + case USB_DR_MODE_HOST:
> + ret = sprintf(buf, "host\n");
> + break;
> + case USB_DR_MODE_PERIPHERAL:
> + ret = sprintf(buf, "peripheral\n");
> + break;
> + case USB_DR_MODE_OTG:
> + ret = sprintf(buf, "otg\n");
> + break;
> + default:
> + ret = sprintf(buf, "UNKNOWN\n");
> + }
> +
Use sysfs_emit instead [1].
> + return ret;
> +}
> +
> +static ssize_t dwc3_mode_store(struct device *device,
> + struct device_attribute *attr, const char *buf,
> + size_t count)
> +{
> + struct dwc3_eswin *eswin = dev_get_drvdata(device);
> + struct dwc3 *dwc = eswin->dwc;
> + enum usb_role new_role;
> + struct usb_role_switch *role_sw = dwc->role_sw;
> +
> + if (!strncmp(buf, "1", 1) || !strncmp(buf, "host", 4)) {
> + new_role = USB_ROLE_HOST;
> + } else if (!strncmp(buf, "0", 1) || !strncmp(buf, "peripheral", 10)) {
> + new_role = USB_ROLE_DEVICE;
> + } else {
> + dev_info(eswin->dev, "illegal dr_mode\n");
> + return count;
> + }
> + eswin->force_mode = true;
> +
> + mutex_lock(&eswin->lock);
> + usb_role_switch_set_role(role_sw, new_role);
> + mutex_unlock(&eswin->lock);
> +
> + return count;
> +}
> +
> +static DEVICE_ATTR_RW(dwc3_mode);
> +
> +static ssize_t dwc3_hub_rst_show(struct device *device,
> + struct device_attribute *attr, char *buf)
> +{
> + struct dwc3_eswin *eswin = dev_get_drvdata(device);
> +
> + if (!IS_ERR(eswin->hub_gpio))
> + return sprintf(buf, "%d", gpiod_get_raw_value(eswin->hub_gpio));
> +
> + return sprintf(buf, "UNKONWN");
Here too, Use sysfs_emit instead [1].
> +}
> +
> +static ssize_t dwc3_hub_rst_store(struct device *device,
> + struct device_attribute *attr,
> + const char *buf, size_t count)
> +{
> + struct dwc3_eswin *eswin = dev_get_drvdata(device);
> +
> + if (!IS_ERR(eswin->hub_gpio)) {
> + if (!strncmp(buf, "0", 1))
> + gpiod_set_raw_value(eswin->hub_gpio, 0);
> + else
> + gpiod_set_raw_value(eswin->hub_gpio, 1);
> + }
> +
> + return count;
> +}
> +
> +static DEVICE_ATTR_RW(dwc3_hub_rst);
> +
> +static struct attribute *dwc3_eswin_attrs[] = {
> + &dev_attr_dwc3_mode.attr,
> + &dev_attr_dwc3_hub_rst.attr,
> + NULL,
> +};
> +
> +static struct attribute_group dwc3_eswin_attr_group = {
> + .name = NULL, /* we want them in the same directory */
> + .attrs = dwc3_eswin_attrs,
> +};
> +
[...]
> +static int dwc3_eswin_probe(struct platform_device *pdev)
> +{
> + struct dwc3_eswin *eswin;
> + struct device *dev = &pdev->dev;
> + struct device_node *np = dev->of_node, *child;
> + struct platform_device *child_pdev;
> + unsigned int count;
> + int ret;
> + int i;
> + int err_desc = 0;
> +
[...]
> + child = of_get_child_by_name(np, "dwc3");
> + if (!child) {
> + dev_err(dev, "failed to find dwc3 core node\n");
> + ret = -ENODEV;
> + goto err1;
> + }
> + /* Allocate and initialize the core */
> + ret = of_platform_populate(np, NULL, NULL, dev);
> + if (ret) {
> + dev_err(dev, "failed to create dwc3 core\n");
> + goto err1;
> + }
> +
> + INIT_WORK(&eswin->otg_work, dwc3_eswin_otg_extcon_evt_work);
> + child_pdev = of_find_device_by_node(child);
> + if (!child_pdev) {
> + dev_err(dev, "failed to find dwc3 core device\n");
> + ret = -ENODEV;
> + goto err2;
> + }
> + eswin->dwc = platform_get_drvdata(child_pdev);
> + if (!eswin->dwc) {
> + dev_err(dev, "failed to get drvdata dwc3\n");
> + ret = -EPROBE_DEFER;
> + goto err2;
> + }
Try using falttened implementation if possible.
Regards,
Krishna,
prev parent reply other threads:[~2025-05-20 6:20 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-16 9:52 [PATCH v1 0/2] Add driver support for Eswin eic7700 SoC Usb controller zhangsenchuan
2025-05-16 9:53 ` [PATCH v1 1/2] dt-bindings: usb: Add Eswin EIC7700 " zhangsenchuan
2025-05-16 11:26 ` Rob Herring (Arm)
2025-05-19 6:24 ` Krzysztof Kozlowski
2025-05-16 9:54 ` [PATCH v1 2/2] usb: dwc3: eic7700: Add EIC7700 usb driver zhangsenchuan
2025-05-16 12:50 ` Krzysztof Kozlowski
2025-05-17 1:15 ` kernel test robot
2025-05-17 23:28 ` kernel test robot
2025-05-20 6:20 ` Krishna Kurapati [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=a6382f2d-2b66-45d6-b903-da8822f9f883@oss.qualcomm.com \
--to=krishna.kurapati@oss.qualcomm.com \
--cc=Thinh.Nguyen@synopsys.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=krzk+dt@kernel.org \
--cc=linmin@eswincomputing.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=ningyu@eswincomputing.com \
--cc=p.zabel@pengutronix.de \
--cc=robh@kernel.org \
--cc=yangwei1@eswincomputing.com \
--cc=zhangsenchuan@eswincomputing.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.