Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752552AbbETCLh (ORCPT ); Tue, 19 May 2015 22:11:37 -0400 Received: from mail-oi0-f42.google.com ([209.85.218.42]:34367 "EHLO mail-oi0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752091AbbETCKS (ORCPT ); Tue, 19 May 2015 22:10:18 -0400 From: Rob Herring To: Greg Kroah-Hartman , Peter Chen , Kishon Vijay Abraham I Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Arnd Bergmann , Alan Stern , Rob Herring , Peter Chen Subject: [PATCH v2 5/6] usb: chipidea: allow multiple instances to use default ci_default_pdata Date: Tue, 19 May 2015 21:10:04 -0500 Message-Id: <1432087805-16671-6-git-send-email-robh@kernel.org> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1432087805-16671-1-git-send-email-robh@kernel.org> References: <1432087805-16671-1-git-send-email-robh@kernel.org> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1852 Lines: 53 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 Cc: Peter Chen Cc: Greg Kroah-Hartman Cc: linux-usb@vger.kernel.org --- drivers/usb/chipidea/ci_hdrc_usb2.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/usb/chipidea/ci_hdrc_usb2.c b/drivers/usb/chipidea/ci_hdrc_usb2.c index 45844c9..73d9906 100644 --- a/drivers/usb/chipidea/ci_hdrc_usb2.c +++ b/drivers/usb/chipidea/ci_hdrc_usb2.c @@ -25,11 +25,13 @@ 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, }; +static const struct of_device_id ci_hdrc_usb2_of_match[]; + static int ci_hdrc_usb2_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; @@ -37,8 +39,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 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/