linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alexandre Torgue <alexandre.torgue@st.com>
To: Kishon Vijay Abraham I <kishon@ti.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>,
	<linux-kernel@vger.kernel.org>, <linux-usb@vger.kernel.org>,
	<linux-stm32@st-md-mailman.stormreply.com>
Subject: Re: [PATCH] phy: core: Add consumer device link support
Date: Wed, 4 Dec 2019 16:33:14 +0100	[thread overview]
Message-ID: <faff6224-11b6-b055-1a80-fda0ff7c1724@st.com> (raw)
In-Reply-To: <20191104143713.11137-1-alexandre.torgue@st.com>

Hi,

Gentle ping, in case you missed this.

Regards
Alex

On 11/4/19 3:37 PM, Alexandre Torgue wrote:
> In order to enforce suspend/resume ordering, this commit creates link
> between phy consumers and phy devices. This link avoids to suspend phy
> before phy consumers.
> 
> Signed-off-by: Alexandre Torgue <alexandre.torgue@st.com>
> 
> ---
> 
> Hi,
> 
> To manage device_link in phy-core I had to "balance" get and put APIs a bit
> more. Fot this reason, you'll find updates in Renesas usbhs rcar and rza drivers
> as phy API changes.
> 
> Regards
> Alex
> 
> diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c
> index b04f4fe85ac2..8dfb4868c8c3 100644
> --- a/drivers/phy/phy-core.c
> +++ b/drivers/phy/phy-core.c
> @@ -29,7 +29,7 @@ static void devm_phy_release(struct device *dev, void *res)
>   {
>   	struct phy *phy = *(struct phy **)res;
>   
> -	phy_put(phy);
> +	phy_put(dev, phy);
>   }
>   
>   static void devm_phy_provider_release(struct device *dev, void *res)
> @@ -566,12 +566,12 @@ struct phy *of_phy_get(struct device_node *np, const char *con_id)
>   EXPORT_SYMBOL_GPL(of_phy_get);
>   
>   /**
> - * phy_put() - release the PHY
> - * @phy: the phy returned by phy_get()
> + * of_phy_put() - release the PHY
> + * @phy: the phy returned by of_phy_get()
>    *
> - * Releases a refcount the caller received from phy_get().
> + * Releases a refcount the caller received from of_phy_get().
>    */
> -void phy_put(struct phy *phy)
> +void of_phy_put(struct phy *phy)
>   {
>   	if (!phy || IS_ERR(phy))
>   		return;
> @@ -584,6 +584,20 @@ void phy_put(struct phy *phy)
>   	module_put(phy->ops->owner);
>   	put_device(&phy->dev);
>   }
> +EXPORT_SYMBOL_GPL(of_phy_put);
> +
> +/**
> + * phy_put() - release the PHY
> + * @dev: device that wants to release this phy
> + * @phy: the phy returned by phy_get()
> + *
> + * Releases a refcount the caller received from phy_get().
> + */
> +void phy_put(struct device *dev, struct phy *phy)
> +{
> +	device_link_remove(dev, &phy->dev);
> +	of_phy_put(phy);
> +}
>   EXPORT_SYMBOL_GPL(phy_put);
>   
>   /**
> @@ -651,6 +665,7 @@ struct phy *phy_get(struct device *dev, const char *string)
>   {
>   	int index = 0;
>   	struct phy *phy;
> +	struct device_link *link;
>   
>   	if (string == NULL) {
>   		dev_WARN(dev, "missing string\n");
> @@ -672,6 +687,13 @@ struct phy *phy_get(struct device *dev, const char *string)
>   
>   	get_device(&phy->dev);
>   
> +	link = device_link_add(dev, &phy->dev, DL_FLAG_STATELESS);
> +	if (!link) {
> +		dev_err(dev, "failed to create device link to %s\n",
> +			dev_name(phy->dev.parent));
> +		return ERR_PTR(-EINVAL);
> +	}
> +
>   	return phy;
>   }
>   EXPORT_SYMBOL_GPL(phy_get);
> @@ -765,6 +787,7 @@ struct phy *devm_of_phy_get(struct device *dev, struct device_node *np,
>   			    const char *con_id)
>   {
>   	struct phy **ptr, *phy;
> +	struct device_link *link;
>   
>   	ptr = devres_alloc(devm_phy_release, sizeof(*ptr), GFP_KERNEL);
>   	if (!ptr)
> @@ -778,6 +801,13 @@ struct phy *devm_of_phy_get(struct device *dev, struct device_node *np,
>   		devres_free(ptr);
>   	}
>   
> +	link = device_link_add(dev, &phy->dev, DL_FLAG_STATELESS);
> +	if (!link) {
> +		dev_err(dev, "failed to create device link to %s\n",
> +			dev_name(phy->dev.parent));
> +		return ERR_PTR(-EINVAL);
> +	}
> +
>   	return phy;
>   }
>   EXPORT_SYMBOL_GPL(devm_of_phy_get);
> @@ -798,6 +828,7 @@ struct phy *devm_of_phy_get_by_index(struct device *dev, struct device_node *np,
>   				     int index)
>   {
>   	struct phy **ptr, *phy;
> +	struct device_link *link;
>   
>   	ptr = devres_alloc(devm_phy_release, sizeof(*ptr), GFP_KERNEL);
>   	if (!ptr)
> @@ -819,6 +850,13 @@ struct phy *devm_of_phy_get_by_index(struct device *dev, struct device_node *np,
>   	*ptr = phy;
>   	devres_add(dev, ptr);
>   
> +	link = device_link_add(dev, &phy->dev, DL_FLAG_STATELESS);
> +	if (!link) {
> +		dev_err(dev, "failed to create device link to %s\n",
> +			dev_name(phy->dev.parent));
> +		return ERR_PTR(-EINVAL);
> +	}
> +
>   	return phy;
>   }
>   EXPORT_SYMBOL_GPL(devm_of_phy_get_by_index);
> diff --git a/drivers/usb/renesas_usbhs/rcar2.c b/drivers/usb/renesas_usbhs/rcar2.c
> index 440d213e1749..791908f8cf73 100644
> --- a/drivers/usb/renesas_usbhs/rcar2.c
> +++ b/drivers/usb/renesas_usbhs/rcar2.c
> @@ -34,7 +34,7 @@ static int usbhs_rcar2_hardware_exit(struct platform_device *pdev)
>   	struct usbhs_priv *priv = usbhs_pdev_to_priv(pdev);
>   
>   	if (priv->phy) {
> -		phy_put(priv->phy);
> +		phy_put(&pdev->dev, priv->phy);
>   		priv->phy = NULL;
>   	}
>   
> diff --git a/drivers/usb/renesas_usbhs/rza2.c b/drivers/usb/renesas_usbhs/rza2.c
> index 021749594389..3eed3334a17f 100644
> --- a/drivers/usb/renesas_usbhs/rza2.c
> +++ b/drivers/usb/renesas_usbhs/rza2.c
> @@ -29,7 +29,7 @@ static int usbhs_rza2_hardware_exit(struct platform_device *pdev)
>   {
>   	struct usbhs_priv *priv = usbhs_pdev_to_priv(pdev);
>   
> -	phy_put(priv->phy);
> +	phy_put(&pdev->dev, priv->phy);
>   	priv->phy = NULL;
>   
>   	return 0;
> diff --git a/include/linux/phy/phy.h b/include/linux/phy/phy.h
> index 56d3a100006a..19eddd64c8f6 100644
> --- a/include/linux/phy/phy.h
> +++ b/include/linux/phy/phy.h
> @@ -234,7 +234,8 @@ struct phy *devm_of_phy_get(struct device *dev, struct device_node *np,
>   			    const char *con_id);
>   struct phy *devm_of_phy_get_by_index(struct device *dev, struct device_node *np,
>   				     int index);
> -void phy_put(struct phy *phy);
> +void of_phy_put(struct phy *phy);
> +void phy_put(struct device *dev, struct phy *phy);
>   void devm_phy_put(struct device *dev, struct phy *phy);
>   struct phy *of_phy_get(struct device_node *np, const char *con_id);
>   struct phy *of_phy_simple_xlate(struct device *dev,
> @@ -419,7 +420,11 @@ static inline struct phy *devm_of_phy_get_by_index(struct device *dev,
>   	return ERR_PTR(-ENOSYS);
>   }
>   
> -static inline void phy_put(struct phy *phy)
> +static inline void of_phy_put(struct phy *phy)
> +{
> +}
> +
> +static inline void phy_put(struct device *dev, struct phy *phy)
>   {
>   }
>   
> 

  reply	other threads:[~2019-12-04 15:33 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-04 14:37 [PATCH] phy: core: Add consumer device link support Alexandre Torgue
2019-12-04 15:33 ` Alexandre Torgue [this message]
2019-12-04 17:19   ` Greg Kroah-Hartman
2020-01-07 11:51 ` Jon Hunter
2020-01-08  7:29   ` Kishon Vijay Abraham I
2020-01-08  8:37     ` Alexandre Torgue
2020-02-06 13:39 ` youling257
2020-02-07  5:16   ` Kishon Vijay Abraham I
2020-02-07  6:57     ` youling 257
2020-02-10  8:08       ` Kishon Vijay Abraham I
2020-02-10 11:30         ` Alexandre Torgue
2020-02-10 12:18           ` Kishon Vijay Abraham I
2020-02-11  6:17             ` Saravana Kannan
2020-02-14 18:46           ` Andy Shevchenko
2020-02-17  8:35             ` Alexandre Torgue
2020-02-17  8:40               ` Kishon Vijay Abraham I

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=faff6224-11b6-b055-1a80-fda0ff7c1724@st.com \
    --to=alexandre.torgue@st.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=kishon@ti.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-stm32@st-md-mailman.stormreply.com \
    --cc=linux-usb@vger.kernel.org \
    --cc=yoshihiro.shimoda.uh@renesas.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 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).