All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Chen <peter.chen@freescale.com>
To: Rob Herring <robh@kernel.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Kishon Vijay Abraham I <kishon@ti.com>,
	linux-usb@vger.kernel.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org, Arnd Bergmann <arnd@arndb.de>
Subject: Re: [PATCH v3 5/6] usb: chipidea: allow multiple instances to use default ci_default_pdata
Date: Fri, 5 Jun 2015 14:32:27 +0800	[thread overview]
Message-ID: <20150605063226.GH15169@shlinux2> (raw)
In-Reply-To: <1432917526-9688-6-git-send-email-robh@kernel.org>

On Fri, May 29, 2015 at 11:38:45AM -0500, Rob Herring wrote:
> Currently, ci_default_pdata is common to all instances of the driver and
> gets modified by the core driver code. This is bad if there are multiple
> instances of the device with different settings such as the phy type. Fix
> this by making a copy of the default platform_data.
> 
> Signed-off-by: Rob Herring <robh@kernel.org>
> Cc: Peter Chen <Peter.Chen@freescale.com>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Cc: linux-usb@vger.kernel.org
> ---
>  drivers/usb/chipidea/ci_hdrc_usb2.c | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/usb/chipidea/ci_hdrc_usb2.c b/drivers/usb/chipidea/ci_hdrc_usb2.c
> index 45844c9..9eae1a1 100644
> --- a/drivers/usb/chipidea/ci_hdrc_usb2.c
> +++ b/drivers/usb/chipidea/ci_hdrc_usb2.c
> @@ -25,7 +25,7 @@ struct ci_hdrc_usb2_priv {
>  	struct clk		*clk;
>  };
>  
> -static struct ci_hdrc_platform_data ci_default_pdata = {
> +static const struct ci_hdrc_platform_data ci_default_pdata = {
>  	.capoffset	= DEF_CAPOFFSET,
>  	.flags		= CI_HDRC_DISABLE_STREAMING,
>  };
> @@ -37,8 +37,10 @@ static int ci_hdrc_usb2_probe(struct platform_device *pdev)
>  	struct ci_hdrc_platform_data *ci_pdata = dev_get_platdata(dev);
>  	int ret;
>  
> -	if (!ci_pdata)
> -		ci_pdata = &ci_default_pdata;
> +	if (!ci_pdata) {
> +		ci_pdata = devm_kmalloc(dev, sizeof(*ci_pdata), GFP_KERNEL);
> +		*ci_pdata = ci_default_pdata;	/* struct copy */
> +	}
>  
>  	priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
>  	if (!priv)
> -- 
> 2.1.0
> 

Acked-by: Peter Chen <peter.chen@freescale.com>

-- 

Best Regards,
Peter Chen

WARNING: multiple messages have this Message-ID (diff)
From: Peter Chen <peter.chen@freescale.com>
To: Rob Herring <robh@kernel.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Kishon Vijay Abraham I <kishon@ti.com>,
	<linux-usb@vger.kernel.org>, <devicetree@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>, Arnd Bergmann <arnd@arndb.de>
Subject: Re: [PATCH v3 5/6] usb: chipidea: allow multiple instances to use default ci_default_pdata
Date: Fri, 5 Jun 2015 14:32:27 +0800	[thread overview]
Message-ID: <20150605063226.GH15169@shlinux2> (raw)
In-Reply-To: <1432917526-9688-6-git-send-email-robh@kernel.org>

On Fri, May 29, 2015 at 11:38:45AM -0500, Rob Herring wrote:
> Currently, ci_default_pdata is common to all instances of the driver and
> gets modified by the core driver code. This is bad if there are multiple
> instances of the device with different settings such as the phy type. Fix
> this by making a copy of the default platform_data.
> 
> Signed-off-by: Rob Herring <robh@kernel.org>
> Cc: Peter Chen <Peter.Chen@freescale.com>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Cc: linux-usb@vger.kernel.org
> ---
>  drivers/usb/chipidea/ci_hdrc_usb2.c | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/usb/chipidea/ci_hdrc_usb2.c b/drivers/usb/chipidea/ci_hdrc_usb2.c
> index 45844c9..9eae1a1 100644
> --- a/drivers/usb/chipidea/ci_hdrc_usb2.c
> +++ b/drivers/usb/chipidea/ci_hdrc_usb2.c
> @@ -25,7 +25,7 @@ struct ci_hdrc_usb2_priv {
>  	struct clk		*clk;
>  };
>  
> -static struct ci_hdrc_platform_data ci_default_pdata = {
> +static const struct ci_hdrc_platform_data ci_default_pdata = {
>  	.capoffset	= DEF_CAPOFFSET,
>  	.flags		= CI_HDRC_DISABLE_STREAMING,
>  };
> @@ -37,8 +37,10 @@ static int ci_hdrc_usb2_probe(struct platform_device *pdev)
>  	struct ci_hdrc_platform_data *ci_pdata = dev_get_platdata(dev);
>  	int ret;
>  
> -	if (!ci_pdata)
> -		ci_pdata = &ci_default_pdata;
> +	if (!ci_pdata) {
> +		ci_pdata = devm_kmalloc(dev, sizeof(*ci_pdata), GFP_KERNEL);
> +		*ci_pdata = ci_default_pdata;	/* struct copy */
> +	}
>  
>  	priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
>  	if (!priv)
> -- 
> 2.1.0
> 

Acked-by: Peter Chen <peter.chen@freescale.com>

-- 

Best Regards,
Peter Chen

  reply	other threads:[~2015-06-05  6:32 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-29 16:38 [PATCH v3 0/6] Marvell PXA1928 USB support Rob Herring
2015-05-29 16:38 ` Rob Herring
2015-05-29 16:38 ` [PATCH v3 1/6] dt-bindings: Add Marvell PXA1928 USB and HSIC PHY bindings Rob Herring
2015-05-29 16:38 ` [PATCH v3 4/6] dt-bindings: Consolidate ChipIdea USB ci13xxx bindings Rob Herring
     [not found]   ` <1432917526-9688-5-git-send-email-robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2015-06-01  7:09     ` Ivan T. Ivanov
2015-06-01  7:09       ` Ivan T. Ivanov
2015-06-05  6:22   ` Peter Chen
2015-06-05  6:22     ` Peter Chen
2015-05-29 16:38 ` [PATCH v3 5/6] usb: chipidea: allow multiple instances to use default ci_default_pdata Rob Herring
2015-06-05  6:32   ` Peter Chen [this message]
2015-06-05  6:32     ` Peter Chen
     [not found] ` <1432917526-9688-1-git-send-email-robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2015-05-29 16:38   ` [PATCH v3 2/6] phy: Add Marvell USB 2.0 OTG 28nm PHY Rob Herring
2015-05-29 16:38     ` Rob Herring
2015-05-29 16:38   ` [PATCH v3 3/6] phy: add Marvell HSIC " Rob Herring
2015-05-29 16:38     ` Rob Herring
2015-05-29 16:38   ` [PATCH v3 6/6] usb: chipidea: add work-around for Marvell HSIC PHY startup Rob Herring
2015-05-29 16:38     ` Rob Herring
2015-06-05  6:32     ` Peter Chen
2015-06-05  6:32       ` Peter Chen
2015-06-09 19:22   ` [PATCH v3 0/6] Marvell PXA1928 USB support Greg Kroah-Hartman
2015-06-09 19:22     ` Greg Kroah-Hartman

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=20150605063226.GH15169@shlinux2 \
    --to=peter.chen@freescale.com \
    --cc=arnd@arndb.de \
    --cc=devicetree@vger.kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=kishon@ti.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=robh@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 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.