Skip to content

Commit

Permalink
usb: chipidea: allow multiple instances to use default ci_default_pdata
Browse files Browse the repository at this point in the history
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
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Rob Herring authored and Greg Kroah-Hartman committed Jun 9, 2015
1 parent 9d062b9 commit d95699b
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions drivers/usb/chipidea/ci_hdrc_usb2.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand All @@ -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)
Expand Down

0 comments on commit d95699b

Please sign in to comment.