linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Florian Fainelli <f.fainelli@gmail.com>
To: "Álvaro Fernández Rojas" <noltari@gmail.com>,
	simon@fire.lp0.eu, jonas.gorski@gmail.com, kishon@ti.com,
	vkoul@kernel.org, robh+dt@kernel.org, f.fainelli@gmail.com,
	bcm-kernel-feedback-list@broadcom.com, p.zabel@pengutronix.de,
	krzk@kernel.org, gregkh@linuxfoundation.org, alcooperx@gmail.com,
	linux-kernel@vger.kernel.org, devicetree@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH 2/2] phy: bcm63xx-usbh: Add BCM63xx USBH driver
Date: Tue, 16 Jun 2020 10:22:35 -0700	[thread overview]
Message-ID: <338262f0-bfe6-759c-c7f9-af7b62f5144d@gmail.com> (raw)
In-Reply-To: <20200616083408.3426435-3-noltari@gmail.com>



On 6/16/2020 1:34 AM, Álvaro Fernández Rojas wrote:
> Add BCM63xx USBH PHY driver for BMIPS.
> 
> Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>

This looks good to me at first glance, just a few comments below.

> ---
>  drivers/phy/broadcom/Kconfig            |  10 +
>  drivers/phy/broadcom/Makefile           |   1 +
>  drivers/phy/broadcom/phy-bcm63xx-usbh.c | 463 ++++++++++++++++++++++++
>  3 files changed, 474 insertions(+)
>  create mode 100644 drivers/phy/broadcom/phy-bcm63xx-usbh.c
> 
> diff --git a/drivers/phy/broadcom/Kconfig b/drivers/phy/broadcom/Kconfig
> index b29f11c19155..896506c7b1f8 100644
> --- a/drivers/phy/broadcom/Kconfig
> +++ b/drivers/phy/broadcom/Kconfig
> @@ -2,6 +2,16 @@
>  #
>  # Phy drivers for Broadcom platforms
>  #
> +config PHY_BCM63XX_USBH
> +	tristate "BCM63xx USBH PHY driver"
> +	depends on BMIPS_GENERIC || COMPILE_TEST
> +	depends on OF

I do not think you need to add the depends on OF here if you use
device_get_match_data() instead of of_device_get_match_data() and
devm_of_phy_provider_register() has an inline stub provided when
CONFIG_OF=n.

[snip]

> +static int __init bcm63xx_usbh_phy_probe(struct platform_device *pdev)
> +{
> +	struct device *dev = &pdev->dev;
> +	struct bcm63xx_usbh_phy	*usbh;
> +	const struct bcm63xx_usbh_phy_variant *variant;
> +	struct resource *res;
> +	struct phy *phy;
> +	struct phy_provider *phy_provider;
> +
> +	usbh = devm_kzalloc(dev, sizeof(*usbh), GFP_KERNEL);
> +	if (!usbh)
> +		return -ENOMEM;
> +
> +	variant = of_device_get_match_data(dev);

We can use device_get_match_data() to be OF independent.

> +	if (!variant)
> +		return -EINVAL;
> +	memcpy(&usbh->variant, variant, sizeof(*variant));

I would just avoid marking the variant tables with __initconst, and just
reference them directly here.

> +
> +	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> +	usbh->base = devm_ioremap_resource(dev, res);
> +	if (IS_ERR(usbh->base))
> +		return PTR_ERR(usbh->base);
> +
> +	usbh->reset = devm_reset_control_get(dev, NULL);
> +	if (IS_ERR(usbh->reset)) {
> +		if (PTR_ERR(usbh->reset) != -EPROBE_DEFER)
> +			dev_err(dev, "failed to get reset\n");
> +		return PTR_ERR(usbh->reset);
> +	}
> +
> +	if (variant->has_usb_clk) {
> +		usbh->usbh_clk = devm_clk_get(dev, "usbh");

You can use devm_clk_get_optional() which would save you from having to
record whether the clock is needed or not.

> +		if (IS_ERR(usbh->usbh_clk)) {
> +			if (PTR_ERR(usbh->usbh_clk) != -EPROBE_DEFER)
> +				dev_err(dev, "failed to get usbh clock\n");
> +			return PTR_ERR(usbh->usbh_clk);
> +		}
> +	} else {
> +		usbh->usbh_clk = NULL;
> +	}
> +
> +	if (variant->has_usb_ref_clk) {
> +		usbh->usb_ref_clk = devm_clk_get(dev, "usb_ref");

Likewise.
-- 
Florian

      reply	other threads:[~2020-06-16 17:22 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-16  8:34 [PATCH 0/2] phy: bcm63xx-usbh: Add BCM63xx USBH driver Álvaro Fernández Rojas
2020-06-16  8:34 ` [PATCH 1/2] dt-bindings: phy: add bcm63xx-usbh bindings Álvaro Fernández Rojas
2020-06-16 17:17   ` Florian Fainelli
2020-06-16 18:10     ` Álvaro Fernández Rojas
2020-06-16 18:21       ` Florian Fainelli
2020-06-17 11:16     ` Álvaro Fernández Rojas
2020-06-17 21:35       ` Florian Fainelli
2020-06-17 17:00   ` Rob Herring
2020-06-16  8:34 ` [PATCH 2/2] phy: bcm63xx-usbh: Add BCM63xx USBH driver Álvaro Fernández Rojas
2020-06-16 17:22   ` Florian Fainelli [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=338262f0-bfe6-759c-c7f9-af7b62f5144d@gmail.com \
    --to=f.fainelli@gmail.com \
    --cc=alcooperx@gmail.com \
    --cc=bcm-kernel-feedback-list@broadcom.com \
    --cc=devicetree@vger.kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=jonas.gorski@gmail.com \
    --cc=kishon@ti.com \
    --cc=krzk@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=noltari@gmail.com \
    --cc=p.zabel@pengutronix.de \
    --cc=robh+dt@kernel.org \
    --cc=simon@fire.lp0.eu \
    --cc=vkoul@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;
as well as URLs for NNTP newsgroup(s).