From patchwork Thu Sep 1 00:40:31 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Boyd X-Patchwork-Id: 9308079 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A077A60487 for ; Thu, 1 Sep 2016 00:42:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 902FB28C53 for ; Thu, 1 Sep 2016 00:42:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8459A2910A; Thu, 1 Sep 2016 00:42:03 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4F72929150 for ; Thu, 1 Sep 2016 00:42:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934021AbcIAAmA (ORCPT ); Wed, 31 Aug 2016 20:42:00 -0400 Received: from mail-pf0-f181.google.com ([209.85.192.181]:36534 "EHLO mail-pf0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933969AbcIAAk4 (ORCPT ); Wed, 31 Aug 2016 20:40:56 -0400 Received: by mail-pf0-f181.google.com with SMTP id h186so24733166pfg.3 for ; Wed, 31 Aug 2016 17:40:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=HtGY81R9B+CAYwGqD1YE0fAAX8S9XThfnbY9wu0SvFs=; b=MFee9b3jqYAqk+QwIoIzMdGetOsEaSYif0FJ+FZQU8qi3AjqvzvH+J/WwB6zJnQcZ3 Or219QFXR1l94UmtkyRcpqCvNowniV9yRZxDPaYxHKvtHLaEoeeViZsu2g2pGy3W5nCZ MBInCA2WGrtwYyh5kBC7GRSaaLbHkibVWwRhk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=HtGY81R9B+CAYwGqD1YE0fAAX8S9XThfnbY9wu0SvFs=; b=g9yZwiQgAqIGrOGRcv+CBKVmhG9YUSaHfkrs2Z9RwOTi3WpNu4d8l5ndvhTbcKrtoL JgnZiSQtD5hemGk9kMag5tgb6zPccM3JZFhPfmJhoFAy8OqNbaRKC98caBtTOoZ1gZ4U NIn1xJZpJzBJMeERryoX/yawM7fJS72KXdG4rsYz2z1NqJdZss7ezpE6NOZ7aG9nx9hQ HDTH9kFeNY8bm4bVB7jVc79Kzw9e87DMfSBtM3lo2GcPqXskb3YLD9VOPDPIW+9ReYdg 4ZJZPelEY/Wg7Zznk+HJq8WLzb6zNemEbA0LNB5vdiX4rLPYLkGVuLxB4tbcMNeGDZSc XO1g== X-Gm-Message-State: AE9vXwMW19oOy6uDpHxd6OeWZXOigRuISHgUlX0kGEU9dyo0wShXYp7XwcRYgPVGJdkaQG0r X-Received: by 10.98.34.151 with SMTP id p23mr22138741pfj.102.1472690455877; Wed, 31 Aug 2016 17:40:55 -0700 (PDT) Received: from localhost.localdomain (i-global254.qualcomm.com. [199.106.103.254]) by smtp.gmail.com with ESMTPSA id m5sm2292303paw.40.2016.08.31.17.40.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 31 Aug 2016 17:40:55 -0700 (PDT) From: Stephen Boyd To: linux-usb@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, Andy Gross , Bjorn Andersson , Neil Armstrong , Arnd Bergmann , Felipe Balbi , Peter Chen , Greg Kroah-Hartman Subject: [PATCH v3 17/22] usb: chipidea: msm: Make platform data driver local instead of global Date: Wed, 31 Aug 2016 17:40:31 -0700 Message-Id: <20160901004036.23936-18-stephen.boyd@linaro.org> X-Mailer: git-send-email 2.9.0.rc2.8.ga28705d In-Reply-To: <20160901004036.23936-1-stephen.boyd@linaro.org> References: <20160901004036.23936-1-stephen.boyd@linaro.org> Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP If two devices are probed with this same driver, they'll share the same platform data structure, while the chipidea core layer writes and modifies it. This can lead to interesting results especially if one device is an OTG type chipidea controller and another is a host. Let's create a copy of this structure per each device instance so that odd things don't happen. Acked-by: Peter Chen Cc: Greg Kroah-Hartman Signed-off-by: Stephen Boyd --- drivers/usb/chipidea/ci_hdrc_msm.c | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/drivers/usb/chipidea/ci_hdrc_msm.c b/drivers/usb/chipidea/ci_hdrc_msm.c index 333817291798..2489a63d3e75 100644 --- a/drivers/usb/chipidea/ci_hdrc_msm.c +++ b/drivers/usb/chipidea/ci_hdrc_msm.c @@ -39,6 +39,7 @@ struct ci_hdrc_msm { struct clk *core_clk; struct clk *iface_clk; struct clk *fs_clk; + struct ci_hdrc_platform_data pdata; bool secondary_phy; bool hsic; void __iomem *base; @@ -94,16 +95,6 @@ static void ci_hdrc_msm_notify_event(struct ci_hdrc *ci, unsigned event) } } -static struct ci_hdrc_platform_data ci_hdrc_msm_platdata = { - .name = "ci_hdrc_msm", - .capoffset = DEF_CAPOFFSET, - .flags = CI_HDRC_REGS_SHARED | - CI_HDRC_DISABLE_STREAMING | - CI_HDRC_OVERRIDE_AHB_BURST, - - .notify_event = ci_hdrc_msm_notify_event, -}; - static int ci_hdrc_msm_mux_phy(struct ci_hdrc_msm *ci, struct platform_device *pdev) { @@ -164,7 +155,12 @@ static int ci_hdrc_msm_probe(struct platform_device *pdev) if (IS_ERR(phy)) return PTR_ERR(phy); - ci_hdrc_msm_platdata.usb_phy = phy; + ci->pdata.name = "ci_hdrc_msm"; + ci->pdata.capoffset = DEF_CAPOFFSET; + ci->pdata.flags = CI_HDRC_REGS_SHARED | CI_HDRC_DISABLE_STREAMING | + CI_HDRC_OVERRIDE_AHB_BURST; + ci->pdata.notify_event = ci_hdrc_msm_notify_event; + ci->pdata.usb_phy = phy; reset = devm_reset_control_get(&pdev->dev, "core"); if (IS_ERR(reset)) @@ -220,9 +216,8 @@ static int ci_hdrc_msm_probe(struct platform_device *pdev) } of_node_put(ulpi_node); - plat_ci = ci_hdrc_add_device(&pdev->dev, - pdev->resource, pdev->num_resources, - &ci_hdrc_msm_platdata); + plat_ci = ci_hdrc_add_device(&pdev->dev, pdev->resource, + pdev->num_resources, &ci->pdata); if (IS_ERR(plat_ci)) { dev_err(&pdev->dev, "ci_hdrc_add_device failed!\n"); ret = PTR_ERR(plat_ci);