From patchwork Thu Mar 15 11:39:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 131765 Delivered-To: patch@linaro.org Received: by 10.46.84.17 with SMTP id i17csp997334ljb; Thu, 15 Mar 2018 04:40:51 -0700 (PDT) X-Google-Smtp-Source: AG47ELubgny4P5FCHrJKYrXLxoJMu6BvziEmCa09FimZm6gmk9LUmIbxBMHUMcIH7al3dLM2ZXsc X-Received: by 10.99.38.135 with SMTP id m129mr6504938pgm.2.1521114051236; Thu, 15 Mar 2018 04:40:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521114051; cv=none; d=google.com; s=arc-20160816; b=YZfCOC6AS2aFx8A3ip/tPySEzMZXMPwYenmzzD14hzBKXPuQteGYESrNLbFDNS57/e QWMAEXe11d1P+EVO6XvYZJzOusrimp1LLppliNHAiAdIy7G4fK0XOmbgbFcUaUBB8Awo 4D6hzCjKYHiJM8wd9xAvHk5ty3MmKQLpFBPSIkRTG4hxNQH63qOtlYQNwQokLTLfpVKW uimYcMVgLeKU7ZXk3/xhscxF/8Xddf5MGviviavJwS0csA5u5PBDPlCiRuPaC5VpuD4A vChD3yQJ4MZ3OXWGqFQh3+YGSj2r+MHl+ljMYluHDZJvieklUwZ/5kyw7riAgwEusmLv QZWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:dkim-filter:arc-authentication-results; bh=hQETnEo5ocIisFwc9kl/Bh6VXZIWar7fgFcCehqeW9E=; b=cU702PQeMiteUPVq/ZIpxMA9u7th/l953FoD5EO/vOwVOdhshcHjwVW4WjzhypaGl+ P+4hb1f1uH6Kr4DM3oJaGDpZ3kkXpPJ28oNg8zrBuHBlLSN9+b6fZ0KTEBS+4/EF5YHH yp3ZGxb6MPHP9kwLvwPRXVlA/clbH504qLpHqB8T1RMSjKuWHQpc8qvROr+G6D43MkJL nveWW9I4Pd/L4ffrc67+lpH+n2fVTgB0zVEnuQnxraYM+jTzJlv7nGKD5o96QjRPTQgO JUIJo9WJXSh8q62uQFS45KoC8h6re9Qdx4otRiJL/o/+oG7Z+VSM2V8ZCpvhSAJd+tKX C1yw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@nifty.com header.s=dec2015msa header.b=UVOi7nQe; spf=pass (google.com: best guess record for domain of linux-usb-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-usb-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id az8-v6si3782466plb.485.2018.03.15.04.40.51; Thu, 15 Mar 2018 04:40:51 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-usb-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@nifty.com header.s=dec2015msa header.b=UVOi7nQe; spf=pass (google.com: best guess record for domain of linux-usb-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-usb-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751619AbeCOLks (ORCPT + 3 others); Thu, 15 Mar 2018 07:40:48 -0400 Received: from conuserg-10.nifty.com ([210.131.2.77]:32444 "EHLO conuserg-10.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751467AbeCOLkr (ORCPT ); Thu, 15 Mar 2018 07:40:47 -0400 Received: from pug.e01.socionext.com (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-10.nifty.com with ESMTP id w2FBe0AU027015; Thu, 15 Mar 2018 20:40:02 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-10.nifty.com w2FBe0AU027015 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1521114003; bh=E8TuGCzk7zi5PDZIxC1ius5xX3qdc3/UVQPCHCBU6/o=; h=From:To:Cc:Subject:Date:From; b=UVOi7nQeWYyiKHLYEm+LNQ8Oy4DNXtCRg1CHr6CqmJg+dWlFLBsGBtRgZzwQjRRdP YZg5vzS6UFYO3P2bhiBmqgEvvGztU86CdCudNtoHIGZnEWRZGp7vh1PrGrXzIub5cE TjCqP0arD1qNkkdZzZnhRdnDo76FBHOnvMvo6GOnP1QKomhEjG0Qwojv9ZhAgleujA mWMms7dib8QnEp943jvs30kv6hKGQVpoHaEWwsSkVvUxdfFj4OsPmRgRNzB7uvOn9m RBKrcBXm7mR8Eb2U4+MLbuIHrs0NiExQheWcgUfW/27SMmyoZhcHqKp5nDNJEHwDuV R82KQERBnOW8Q== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: Felipe Balbi , linux-usb@vger.kernel.org Cc: Masami Hiramatsu , Jassi Brar , Kunihiko Hayashi , Masahiro Yamada , Greg Kroah-Hartman , Felipe Balbi , linux-kernel@vger.kernel.org Subject: [PATCH 1/2] usb: dwc3: use local copy of resource to fix-up register offset Date: Thu, 15 Mar 2018 20:39:57 +0900 Message-Id: <1521113998-25052-1-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org It is not a good idea to modify the resource from the platform device. Modify its local copy to pass it to devm_ioremap_resource() so that we do not need to restore it in the failure path and the remove hook. Signed-off-by: Masahiro Yamada --- drivers/usb/dwc3/core.c | 32 ++++++++------------------------ 1 file changed, 8 insertions(+), 24 deletions(-) -- 2.7.4 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index f1d838a..e9083a3 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -1164,7 +1164,7 @@ static void dwc3_check_params(struct dwc3 *dwc) static int dwc3_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; - struct resource *res; + struct resource *res, dwc_res; struct dwc3 *dwc; int ret; @@ -1189,20 +1189,19 @@ static int dwc3_probe(struct platform_device *pdev) dwc->xhci_resources[0].flags = res->flags; dwc->xhci_resources[0].name = res->name; - res->start += DWC3_GLOBALS_REGS_START; - /* * Request memory region but exclude xHCI regs, * since it will be requested by the xhci-plat driver. */ - regs = devm_ioremap_resource(dev, res); - if (IS_ERR(regs)) { - ret = PTR_ERR(regs); - goto err0; - } + dwc_res = *res; + dwc_res.start += DWC3_GLOBALS_REGS_START; + + regs = devm_ioremap_resource(dev, &dwc_res); + if (IS_ERR(regs)) + return PTR_ERR(regs); dwc->regs = regs; - dwc->regs_size = resource_size(res); + dwc->regs_size = resource_size(&dwc_res); dwc3_get_properties(dwc); @@ -1269,29 +1268,14 @@ static int dwc3_probe(struct platform_device *pdev) pm_runtime_put_sync(&pdev->dev); pm_runtime_disable(&pdev->dev); -err0: - /* - * restore res->start back to its original value so that, in case the - * probe is deferred, we don't end up getting error in request the - * memory region the next time probe is called. - */ - res->start -= DWC3_GLOBALS_REGS_START; - return ret; } static int dwc3_remove(struct platform_device *pdev) { struct dwc3 *dwc = platform_get_drvdata(pdev); - struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0); pm_runtime_get_sync(&pdev->dev); - /* - * restore res->start back to its original value so that, in case the - * probe is deferred, we don't end up getting error in request the - * memory region the next time probe is called. - */ - res->start -= DWC3_GLOBALS_REGS_START; dwc3_debugfs_exit(dwc); dwc3_core_exit_mode(dwc);