All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jisheng Zhang <jszhang-eYqpPyKDWXRBDgjK7y7TUQ@public.gmane.org>
To: Chunfeng Yun <chunfeng.yun-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org>
Cc: linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	Kishon Vijay Abraham I <kishon-l0cyMroinI0@public.gmane.org>,
	Alan Stern
	<stern-nwvwT67g6+6dFdvTe/nMLpVzexx5G7lz@public.gmane.org>,
	linux-mediatek-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
	Arun Ramamurthy
	<arun.ramamurthy-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org
Subject: Re: [RESEND] phy: core: Get a refcount to phy in devm_of_phy_get_by_index()
Date: Tue, 17 Nov 2015 14:00:26 +0800	[thread overview]
Message-ID: <20151117140026.270a408e@xhacker> (raw)
In-Reply-To: <1447739808-29472-1-git-send-email-chunfeng.yun-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org>

Hi,

On Tue, 17 Nov 2015 13:56:48 +0800
Chunfeng Yun <chunfeng.yun-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org> wrote:

> On driver detach, devm_phy_release() will put a refcount to
> the phy, so gets a refconut to it before return.
> 
> Change-Id: I56fe428bf945f19c38d56245978c8ca17340eb2c

This line need to be removed



> Signed-off-by: Chunfeng Yun <chunfeng.yun-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org>
> ---
>  drivers/phy/phy-core.c | 21 +++++++++++++++------
>  1 file changed, 15 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c
> index fc48fac..8c7f27d 100644
> --- a/drivers/phy/phy-core.c
> +++ b/drivers/phy/phy-core.c
> @@ -636,8 +636,9 @@ EXPORT_SYMBOL_GPL(devm_of_phy_get);
>   * @np: node containing the phy
>   * @index: index of the phy
>   *
> - * Gets the phy using _of_phy_get(), and associates a device with it using
> - * devres. On driver detach, release function is invoked on the devres data,
> + * Gets the phy using _of_phy_get(), then gets a refcount to it,
> + * and associates a device with it using devres. On driver detach,
> + * release function is invoked on the devres data,
>   * then, devres data is freed.
>   *
>   */
> @@ -651,13 +652,21 @@ struct phy *devm_of_phy_get_by_index(struct device *dev, struct device_node *np,
>  		return ERR_PTR(-ENOMEM);
>  
>  	phy = _of_phy_get(np, index);
> -	if (!IS_ERR(phy)) {
> -		*ptr = phy;
> -		devres_add(dev, ptr);
> -	} else {
> +	if (IS_ERR(phy)) {
>  		devres_free(ptr);
> +		return phy;
>  	}
>  
> +	if (!try_module_get(phy->ops->owner)) {
> +		devres_free(ptr);
> +		return ERR_PTR(-EPROBE_DEFER);
> +	}
> +
> +	get_device(&phy->dev);
> +
> +	*ptr = phy;
> +	devres_add(dev, ptr);
> +
>  	return phy;
>  }
>  EXPORT_SYMBOL_GPL(devm_of_phy_get_by_index);

WARNING: multiple messages have this Message-ID (diff)
From: jszhang@marvell.com (Jisheng Zhang)
To: linux-arm-kernel@lists.infradead.org
Subject: [RESEND] phy: core: Get a refcount to phy in devm_of_phy_get_by_index()
Date: Tue, 17 Nov 2015 14:00:26 +0800	[thread overview]
Message-ID: <20151117140026.270a408e@xhacker> (raw)
In-Reply-To: <1447739808-29472-1-git-send-email-chunfeng.yun@mediatek.com>

Hi,

On Tue, 17 Nov 2015 13:56:48 +0800
Chunfeng Yun <chunfeng.yun@mediatek.com> wrote:

> On driver detach, devm_phy_release() will put a refcount to
> the phy, so gets a refconut to it before return.
> 
> Change-Id: I56fe428bf945f19c38d56245978c8ca17340eb2c

This line need to be removed



> Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
> ---
>  drivers/phy/phy-core.c | 21 +++++++++++++++------
>  1 file changed, 15 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c
> index fc48fac..8c7f27d 100644
> --- a/drivers/phy/phy-core.c
> +++ b/drivers/phy/phy-core.c
> @@ -636,8 +636,9 @@ EXPORT_SYMBOL_GPL(devm_of_phy_get);
>   * @np: node containing the phy
>   * @index: index of the phy
>   *
> - * Gets the phy using _of_phy_get(), and associates a device with it using
> - * devres. On driver detach, release function is invoked on the devres data,
> + * Gets the phy using _of_phy_get(), then gets a refcount to it,
> + * and associates a device with it using devres. On driver detach,
> + * release function is invoked on the devres data,
>   * then, devres data is freed.
>   *
>   */
> @@ -651,13 +652,21 @@ struct phy *devm_of_phy_get_by_index(struct device *dev, struct device_node *np,
>  		return ERR_PTR(-ENOMEM);
>  
>  	phy = _of_phy_get(np, index);
> -	if (!IS_ERR(phy)) {
> -		*ptr = phy;
> -		devres_add(dev, ptr);
> -	} else {
> +	if (IS_ERR(phy)) {
>  		devres_free(ptr);
> +		return phy;
>  	}
>  
> +	if (!try_module_get(phy->ops->owner)) {
> +		devres_free(ptr);
> +		return ERR_PTR(-EPROBE_DEFER);
> +	}
> +
> +	get_device(&phy->dev);
> +
> +	*ptr = phy;
> +	devres_add(dev, ptr);
> +
>  	return phy;
>  }
>  EXPORT_SYMBOL_GPL(devm_of_phy_get_by_index);

WARNING: multiple messages have this Message-ID (diff)
From: Jisheng Zhang <jszhang@marvell.com>
To: Chunfeng Yun <chunfeng.yun@mediatek.com>
Cc: Kishon Vijay Abraham I <kishon@ti.com>,
	<linux-usb@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	Daniel Kurtz <djkurtz@chromium.org>,
	<linux-mediatek@lists.infradead.org>,
	Alan Stern <stern@rowland.harvard.edu>,
	Arun Ramamurthy <arun.ramamurthy@broadcom.com>,
	<linux-arm-kernel@lists.infradead.org>
Subject: Re: [RESEND] phy: core: Get a refcount to phy in devm_of_phy_get_by_index()
Date: Tue, 17 Nov 2015 14:00:26 +0800	[thread overview]
Message-ID: <20151117140026.270a408e@xhacker> (raw)
In-Reply-To: <1447739808-29472-1-git-send-email-chunfeng.yun@mediatek.com>

Hi,

On Tue, 17 Nov 2015 13:56:48 +0800
Chunfeng Yun <chunfeng.yun@mediatek.com> wrote:

> On driver detach, devm_phy_release() will put a refcount to
> the phy, so gets a refconut to it before return.
> 
> Change-Id: I56fe428bf945f19c38d56245978c8ca17340eb2c

This line need to be removed



> Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
> ---
>  drivers/phy/phy-core.c | 21 +++++++++++++++------
>  1 file changed, 15 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c
> index fc48fac..8c7f27d 100644
> --- a/drivers/phy/phy-core.c
> +++ b/drivers/phy/phy-core.c
> @@ -636,8 +636,9 @@ EXPORT_SYMBOL_GPL(devm_of_phy_get);
>   * @np: node containing the phy
>   * @index: index of the phy
>   *
> - * Gets the phy using _of_phy_get(), and associates a device with it using
> - * devres. On driver detach, release function is invoked on the devres data,
> + * Gets the phy using _of_phy_get(), then gets a refcount to it,
> + * and associates a device with it using devres. On driver detach,
> + * release function is invoked on the devres data,
>   * then, devres data is freed.
>   *
>   */
> @@ -651,13 +652,21 @@ struct phy *devm_of_phy_get_by_index(struct device *dev, struct device_node *np,
>  		return ERR_PTR(-ENOMEM);
>  
>  	phy = _of_phy_get(np, index);
> -	if (!IS_ERR(phy)) {
> -		*ptr = phy;
> -		devres_add(dev, ptr);
> -	} else {
> +	if (IS_ERR(phy)) {
>  		devres_free(ptr);
> +		return phy;
>  	}
>  
> +	if (!try_module_get(phy->ops->owner)) {
> +		devres_free(ptr);
> +		return ERR_PTR(-EPROBE_DEFER);
> +	}
> +
> +	get_device(&phy->dev);
> +
> +	*ptr = phy;
> +	devres_add(dev, ptr);
> +
>  	return phy;
>  }
>  EXPORT_SYMBOL_GPL(devm_of_phy_get_by_index);


  parent reply	other threads:[~2015-11-17  6:00 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-17  5:56 [RESEND] phy: core: Get a refcount to phy in devm_of_phy_get_by_index() Chunfeng Yun
2015-11-17  5:56 ` Chunfeng Yun
2015-11-17  5:56 ` Chunfeng Yun
     [not found] ` <1447739808-29472-1-git-send-email-chunfeng.yun-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org>
2015-11-17  6:00   ` Jisheng Zhang [this message]
2015-11-17  6:00     ` Jisheng Zhang
2015-11-17  6:00     ` Jisheng Zhang

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=20151117140026.270a408e@xhacker \
    --to=jszhang-eyqppykdwxrbdgjk7y7tuq@public.gmane.org \
    --cc=arun.ramamurthy-dY08KVG/lbpWk0Htik3J/w@public.gmane.org \
    --cc=chunfeng.yun-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org \
    --cc=kishon-l0cyMroinI0@public.gmane.org \
    --cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-mediatek-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
    --cc=linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=stern-nwvwT67g6+6dFdvTe/nMLpVzexx5G7lz@public.gmane.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.