All of lore.kernel.org
 help / color / mirror / Atom feed
From: arnd@arndb.de (Arnd Bergmann)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 1/2] ohci-platform: Add support for devicetree instantiation
Date: Mon, 6 Jan 2014 08:16:02 +0100	[thread overview]
Message-ID: <201401060816.02998.arnd@arndb.de> (raw)
In-Reply-To: <1388963080-12544-1-git-send-email-hdegoede@redhat.com>

On Monday 06 January 2014, Hans de Goede wrote:
> +Required properties:
> + - compatible: Should be "platform-ohci"
> + - reg: Address range of the ohci registers.
> + - interrupts: Should contain the ohci interrupt.
> +
> +Optional properties:
> + - clocks: array of clocks
> + - clock-names: clock names "ahb" and/or "ohci"
> + - phys: phy
> + - phy-names: "usb_phy"

Maybe just "usb"? It obviously is a phy, so that part of the name
is a bit redundant. Actually, the "usb" part of the name also seems
redundant. Is it possible to make it an anonymous phy reference
without a phy-names property as we often do for clocks?

> +static int ohci_platform_power_on(struct platform_device *dev)
> +{
> +	struct usb_hcd *hcd = platform_get_drvdata(dev);
> +	struct ohci_platform_priv *priv =
> +		(struct ohci_platform_priv *)hcd_to_ohci(hcd)->priv;
> +	int ret;
> +
> +	if (!IS_ERR(priv->ohci_clk)) {
> +		ret = clk_prepare_enable(priv->ohci_clk);
> +		if (ret)
> +			return ret;
> +	}
> +
> +	if (!IS_ERR(priv->ahb_clk)) {
> +		ret = clk_prepare_enable(priv->ahb_clk);
> +		if (ret)
> +			goto err_disable_ohci_clk;
> +	}
> +
> +	if (!IS_ERR(priv->phy)) {
> +		ret = phy_init(priv->phy);
> +		if (ret)
> +			goto err_disable_ahb_clk;
> +
> +		ret = phy_power_on(priv->phy);
> +		if (ret)
> +			goto err_exit_phy;
> +	}

Style-wise, I think I'd prefer not storing error values in the
ohci_platform_priv struct, but rather using NULL pointers for
when the clocks or phy references are unused.

> @@ -83,17 +171,30 @@ static int ohci_platform_probe(struct platform_device *dev)
>  		return -ENXIO;
>  	}
>  
> +	hcd = usb_create_hcd(&ohci_platform_hc_driver, &dev->dev,
> +			dev_name(&dev->dev));
> +	if (!hcd)
> +		return -ENOMEM;
> +
> +	if (pdata == &ohci_platform_defaults) {
> +		struct ohci_platform_priv *priv = (struct ohci_platform_priv *)
> +						  hcd_to_ohci(hcd)->priv;
> +
> +		priv->phy = devm_phy_get(&dev->dev, "usb_phy");
> +		if (IS_ERR(priv->phy) && PTR_ERR(priv->phy) == -EPROBE_DEFER) {
> +			err = -EPROBE_DEFER;
> +			goto err_put_hcd;
> +		}
> +
> +		priv->ohci_clk = devm_clk_get(&dev->dev, "ohci");
> +		priv->ahb_clk = devm_clk_get(&dev->dev, "ahb");
> +	}

I think you have to check the clocks for -EPROBE_DEFER as well here, not
just the PHY. Otherwise you don't know the difference between "no clock
provided", "error getting the clock reference" and "clock controller not
initialized yet, try again".

> @@ -178,6 +277,12 @@ static int ohci_platform_resume(struct device *dev)
>  #define ohci_platform_resume	NULL
>  #endif /* CONFIG_PM */
>  
> +static const struct of_device_id ohci_platform_ids[] = {
> +	{ .compatible = "platform-ohci", },
> +	{ }
> +};
> +MODULE_DEVICE_TABLE(of, ohci_platform_ids);

I never liked the "platform-*" naming for compatible properties, the
name of the driver is just based on a linux implementation detail
(the platform bus), which could change. How about just calling the
generic one "ohci" or "usb-ohci"?

	Arnd

WARNING: multiple messages have this Message-ID (diff)
From: Arnd Bergmann <arnd@arndb.de>
To: linux-arm-kernel@lists.infradead.org
Cc: devicetree@vger.kernel.org, linux-usb@vger.kernel.org,
	Hans de Goede <hdegoede@redhat.com>,
	linux-sunxi@googlegroups.com,
	Alan Stern <stern@rowland.harvard.edu>,
	Maxime Ripard <maxime.ripard@free-electrons.com>
Subject: Re: [PATCH 1/2] ohci-platform: Add support for devicetree instantiation
Date: Mon, 6 Jan 2014 08:16:02 +0100	[thread overview]
Message-ID: <201401060816.02998.arnd@arndb.de> (raw)
In-Reply-To: <1388963080-12544-1-git-send-email-hdegoede@redhat.com>

On Monday 06 January 2014, Hans de Goede wrote:
> +Required properties:
> + - compatible: Should be "platform-ohci"
> + - reg: Address range of the ohci registers.
> + - interrupts: Should contain the ohci interrupt.
> +
> +Optional properties:
> + - clocks: array of clocks
> + - clock-names: clock names "ahb" and/or "ohci"
> + - phys: phy
> + - phy-names: "usb_phy"

Maybe just "usb"? It obviously is a phy, so that part of the name
is a bit redundant. Actually, the "usb" part of the name also seems
redundant. Is it possible to make it an anonymous phy reference
without a phy-names property as we often do for clocks?

> +static int ohci_platform_power_on(struct platform_device *dev)
> +{
> +	struct usb_hcd *hcd = platform_get_drvdata(dev);
> +	struct ohci_platform_priv *priv =
> +		(struct ohci_platform_priv *)hcd_to_ohci(hcd)->priv;
> +	int ret;
> +
> +	if (!IS_ERR(priv->ohci_clk)) {
> +		ret = clk_prepare_enable(priv->ohci_clk);
> +		if (ret)
> +			return ret;
> +	}
> +
> +	if (!IS_ERR(priv->ahb_clk)) {
> +		ret = clk_prepare_enable(priv->ahb_clk);
> +		if (ret)
> +			goto err_disable_ohci_clk;
> +	}
> +
> +	if (!IS_ERR(priv->phy)) {
> +		ret = phy_init(priv->phy);
> +		if (ret)
> +			goto err_disable_ahb_clk;
> +
> +		ret = phy_power_on(priv->phy);
> +		if (ret)
> +			goto err_exit_phy;
> +	}

Style-wise, I think I'd prefer not storing error values in the
ohci_platform_priv struct, but rather using NULL pointers for
when the clocks or phy references are unused.

> @@ -83,17 +171,30 @@ static int ohci_platform_probe(struct platform_device *dev)
>  		return -ENXIO;
>  	}
>  
> +	hcd = usb_create_hcd(&ohci_platform_hc_driver, &dev->dev,
> +			dev_name(&dev->dev));
> +	if (!hcd)
> +		return -ENOMEM;
> +
> +	if (pdata == &ohci_platform_defaults) {
> +		struct ohci_platform_priv *priv = (struct ohci_platform_priv *)
> +						  hcd_to_ohci(hcd)->priv;
> +
> +		priv->phy = devm_phy_get(&dev->dev, "usb_phy");
> +		if (IS_ERR(priv->phy) && PTR_ERR(priv->phy) == -EPROBE_DEFER) {
> +			err = -EPROBE_DEFER;
> +			goto err_put_hcd;
> +		}
> +
> +		priv->ohci_clk = devm_clk_get(&dev->dev, "ohci");
> +		priv->ahb_clk = devm_clk_get(&dev->dev, "ahb");
> +	}

I think you have to check the clocks for -EPROBE_DEFER as well here, not
just the PHY. Otherwise you don't know the difference between "no clock
provided", "error getting the clock reference" and "clock controller not
initialized yet, try again".

> @@ -178,6 +277,12 @@ static int ohci_platform_resume(struct device *dev)
>  #define ohci_platform_resume	NULL
>  #endif /* CONFIG_PM */
>  
> +static const struct of_device_id ohci_platform_ids[] = {
> +	{ .compatible = "platform-ohci", },
> +	{ }
> +};
> +MODULE_DEVICE_TABLE(of, ohci_platform_ids);

I never liked the "platform-*" naming for compatible properties, the
name of the driver is just based on a linux implementation detail
(the platform bus), which could change. How about just calling the
generic one "ohci" or "usb-ohci"?

	Arnd

  parent reply	other threads:[~2014-01-06  7:16 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-05 23:04 [PATCH 1/2] ohci-platform: Add support for devicetree instantiation Hans de Goede
2014-01-05 23:04 ` Hans de Goede
2014-01-05 23:04 ` [PATCH 2/2] ehci-platform: Add support for clks and phy passed through devicetree Hans de Goede
2014-01-05 23:04   ` Hans de Goede
2014-01-06 15:52   ` Mark Rutland
2014-01-06 15:52     ` Mark Rutland
2014-01-06  7:16 ` Arnd Bergmann [this message]
2014-01-06  7:16   ` [PATCH 1/2] ohci-platform: Add support for devicetree instantiation Arnd Bergmann
2014-01-06  7:50   ` Hans de Goede
2014-01-06  7:50     ` Hans de Goede
2014-01-06 16:03     ` Arnd Bergmann
2014-01-06 16:03       ` Arnd Bergmann
2014-01-08 16:00     ` Hans de Goede
2014-01-08 16:00       ` Hans de Goede
2014-01-06 15:45 ` Mark Rutland
2014-01-06 15:45   ` Mark Rutland
2014-01-07 21:01   ` Hans de Goede
2014-01-07 21:01     ` Hans de Goede
2014-01-06 15:49 ` Alan Stern
2014-01-06 15:49   ` Alan Stern
2014-01-07 21:03   ` Hans de Goede
2014-01-07 21:03     ` Hans de Goede
2014-01-07 21:16     ` Arnd Bergmann
2014-01-07 21:16       ` Arnd Bergmann
2014-01-07 21:26       ` Hans de Goede
2014-01-07 21:26         ` Hans de Goede
2014-01-08 16:59         ` Alan Stern
2014-01-08 16:59           ` Alan Stern

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=201401060816.02998.arnd@arndb.de \
    --to=arnd@arndb.de \
    --cc=linux-arm-kernel@lists.infradead.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 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.