devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Russell King - ARM Linux <linux@arm.linux.org.uk>
To: Vivek Gautam <gautam.vivek@samsung.com>
Cc: linux-usb@vger.kernel.org, l.majewski@samsung.com,
	linux-samsung-soc@vger.kernel.org, heiko@sntech.de,
	p.paneri@samsung.com, gregkh@linuxfoundation.org,
	devicetree-discuss@lists.ozlabs.org,
	broonie@opensource.wolfsonmicro.com,
	linux-kernel@vger.kernel.org, balbi@ti.com,
	dianders@chromium.org, grant.likely@secretlab.ca,
	kyungmin.park@samsung.com, kgene.kim@samsung.com,
	thomas.abraham@linaro.org, ben-linux@fluff.org,
	sylvester.nawrocki@gmail.com, t.figa@samsung.com,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v4] usb: phy: samsung: Add support to set pmu isolation
Date: Thu, 27 Dec 2012 00:26:46 +0000	[thread overview]
Message-ID: <20121227002646.GC24604@n2100.arm.linux.org.uk> (raw)
In-Reply-To: <1356524912-4736-2-git-send-email-gautam.vivek@samsung.com>

On Wed, Dec 26, 2012 at 05:58:32PM +0530, Vivek Gautam wrote:
> +	if (!ret)
> +		sphy->phyctrl_pmureg = ioremap(reg[0], reg[1]);
> +
> +	of_node_put(usbphy_pmu);
> +
> +	if (IS_ERR_OR_NULL(sphy->phyctrl_pmureg)) {

No.  Learn what the error return values are from functions.  Using the
wrong ones is buggy.  ioremap() only ever returns NULL on error.  You
must check against NULL, and not use the IS_ERR stuff.

> +/*
> + * Set isolation here for phy.
> + * SOCs control this by controlling corresponding PMU registers
> + */
> +static void samsung_usbphy_set_isolation(struct samsung_usbphy *sphy, int on)
> +{
> +	u32 reg;
> +	int en_mask;
> +
> +	if (!sphy->phyctrl_pmureg) {
> +		dev_warn(sphy->dev, "Can't set pmu isolation\n");
> +		return;
> +	}
> +
> +	reg = readl(sphy->phyctrl_pmureg);
> +
> +	en_mask = sphy->drv_data->devphy_en_mask;
> +
> +	if (on)
> +		writel(reg & ~en_mask, sphy->phyctrl_pmureg);
> +	else
> +		writel(reg | en_mask, sphy->phyctrl_pmureg);

What guarantees that this read-modify-write sequence of this register safe?
And, btw, this can't be optimised very well because of the barrier inside
writel().  This would be better:

	if (on)
		reg &= ~en_mask;
	else
		reg |= en_mask;

	writel(reg, sphy->phyctrl_pmureg);

> +static inline struct samsung_usbphy_drvdata
> +*samsung_usbphy_get_driver_data(struct platform_device *pdev)
>  {
>  	if (pdev->dev.of_node) {
>  		const struct of_device_id *match;
>  		match = of_match_node(samsung_usbphy_dt_match,
>  							pdev->dev.of_node);
> -		return (int) match->data;
> +		return (struct samsung_usbphy_drvdata *) match->data;

match->data is a const void pointer.  Is there a reason you need this
cast here?  What if you made the returned pointer from this function
also const and fixed up all its users (no user should modify this
data.)

>  #ifdef CONFIG_OF
>  static const struct of_device_id samsung_usbphy_dt_match[] = {
>  	{
>  		.compatible = "samsung,s3c64xx-usbphy",
> -		.data = (void *)TYPE_S3C64XX,
> +		.data = (void *)&usbphy_s3c64xx,

Why do you need this cast?

>  	}, {
>  		.compatible = "samsung,exynos4210-usbphy",
> -		.data = (void *)TYPE_EXYNOS4210,
> +		.data = (void *)&usbphy_exynos4,

Ditto.

  parent reply	other threads:[~2012-12-27  0:26 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-26 12:28 [PATCH v4] usb: phy: samsung: Add support to set pmu isolation Vivek Gautam
2012-12-26 12:28 ` Vivek Gautam
     [not found]   ` <1356524912-4736-2-git-send-email-gautam.vivek-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
2012-12-26 13:56     ` Vivek Gautam
     [not found]       ` <CAFp+6iEoy-d6gHBMAiNi0n+tE8iS7Hk=k92w8EWfT_r3eeN_UA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-12-26 23:05         ` Sylwester Nawrocki
2012-12-26 22:30   ` Sylwester Nawrocki
2012-12-27 12:01     ` Vivek Gautam
2012-12-28  9:13       ` [PATCH v5] " Vivek Gautam
     [not found]         ` <1356686018-18586-1-git-send-email-gautam.vivek-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
2013-01-04  6:29           ` Vivek Gautam
2013-01-09 21:42         ` Sylwester Nawrocki
2013-01-10  8:48           ` Vivek Gautam
2012-12-27  0:26   ` Russell King - ARM Linux [this message]
2012-12-27  9:20     ` [PATCH v4] " Vivek Gautam

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=20121227002646.GC24604@n2100.arm.linux.org.uk \
    --to=linux@arm.linux.org.uk \
    --cc=balbi@ti.com \
    --cc=ben-linux@fluff.org \
    --cc=broonie@opensource.wolfsonmicro.com \
    --cc=devicetree-discuss@lists.ozlabs.org \
    --cc=dianders@chromium.org \
    --cc=gautam.vivek@samsung.com \
    --cc=grant.likely@secretlab.ca \
    --cc=gregkh@linuxfoundation.org \
    --cc=heiko@sntech.de \
    --cc=kgene.kim@samsung.com \
    --cc=kyungmin.park@samsung.com \
    --cc=l.majewski@samsung.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-samsung-soc@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=p.paneri@samsung.com \
    --cc=sylvester.nawrocki@gmail.com \
    --cc=t.figa@samsung.com \
    --cc=thomas.abraham@linaro.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).