Received: by 10.192.165.156 with SMTP id m28csp573044imm; Thu, 19 Apr 2018 04:06:36 -0700 (PDT) X-Google-Smtp-Source: AIpwx49PNIqBK57NUZeLiAULbMK2ZqTTEEAxV4lmQ+OJnPJpeq0W4Byt1nlIUAaNhKUEtBYFrxTu X-Received: by 2002:a17:902:c81:: with SMTP id 1-v6mr724954plt.126.1524135996189; Thu, 19 Apr 2018 04:06:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524135996; cv=none; d=google.com; s=arc-20160816; b=zTMmsAkNgWiYlbeMyd3kEPERKV0IlvoS8GT5ij/M3ZtN+loZRvcj3OgdRc7Sd6fslU WjyxqNiBlbv8NmvdK1AcdSASUoP+Y14I4ym4azKp/ltUuv7vZ+YrhYaPTaklnOM+ANZZ g3yQxyZj6ThQLaPvxImOEM86pTv7TG/99GkQPyJx0o/5ORmIP5vDlPNpnYjdEqvdA9eb nP/pvA03V31xVLrlzsQ+6aEFt6AjO+78AN8z6pfPtIjoxXwW3KeRwvnr6RcjVG8I4xAX +HTEyzkh6wFAzR5PKqxaBpviRPWEuPSbq3TW2W5n3fuX7hFQ1QDZ+hQv7fVQmvYN7RXa 5bMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:dkim-filter :arc-authentication-results; bh=8yyz1CKJFUbWwpZeex/M/jNOe6F+aRwY8alOpmJMigY=; b=F80d/C2arjPJGuqq6qctJUDi75R8kD0RBNKnRtEHH5GK7o/aUS41RI5jsE17Awr4Tl nP6SYEKpzRDax4dXEK6psxKK4dr0YZFWtwxkW8/K8AZVvg/o/LJyKfBli+kG4y13aLfZ 08EDtKuEDIAjyqu9fLSFqPVhWDYBRNIrj6DTuzFvnGzOs1HGhHhWLMfthNgHMiq+Iyeo p+HomMDuj2KcyS6i/FhLjcTFBKIkENJBcCzY+6Q3NFmWiGxR1QXb1RqeIvk3dO9jcI0T 0jdtZq5q/fvIDXn4m+95v1kyTJM1YLGRgZc9SWJ5kBu+dn7egRPYBqTYhv0Nh04hEWC6 JAfQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=TRkbeQA3; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 s10-v6si3396296plq.240.2018.04.19.04.06.22; Thu, 19 Apr 2018 04:06:36 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=TRkbeQA3; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752775AbeDSLFT (ORCPT + 99 others); Thu, 19 Apr 2018 07:05:19 -0400 Received: from conuserg-11.nifty.com ([210.131.2.78]:21657 "EHLO conuserg-11.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752739AbeDSLFE (ORCPT ); Thu, 19 Apr 2018 07:05:04 -0400 Received: from pug.e01.socionext.com (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-11.nifty.com with ESMTP id w3JB42ur024223; Thu, 19 Apr 2018 20:04:03 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-11.nifty.com w3JB42ur024223 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1524135844; bh=8yyz1CKJFUbWwpZeex/M/jNOe6F+aRwY8alOpmJMigY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TRkbeQA30rkUurF4mFplWnnhmZI3ELekoQFQi5Ctju9dee/KOQQfPSwUC0Mwznc3U pMfeg+KW/uRMS8t5J5EGl6kzKzEL2WWK8lp1TaxtQ2N+wjzLT/Oz5QpldWtrPDsJIM NLR3aXY2DJOMZpMY6hBwPc/IczFTd42Quo2hx5m35C3yOBJnFcnWNDRZ8pe/BfoYpZ It9RzigA0XYwvYe23kqOH+mzF0LXmJKjDUa0Tz+vuS8JslnCyes5tA1hGNZLt6L22H Fsu0oOa0fj1WaNrao/yfVsQVfbloVGuf885Mg8IUYWLg4jQdHI/s9fKPzwubI5nbr8 YOQduvbPokAwQ== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: linux-usb@vger.kernel.org, Felipe Balbi Cc: Rob Herring , Roger Quadros , Martin Blumenstingl , Masami Hiramatsu , Jassi Brar , Kunihiko Hayashi , Masahiro Yamada , Greg Kroah-Hartman , Felipe Balbi , linux-kernel@vger.kernel.org Subject: [PATCH v2 1/2] usb: dwc3: use local copy of resource to fix-up register offset Date: Thu, 19 Apr 2018 20:03:37 +0900 Message-Id: <1524135818-14825-2-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1524135818-14825-1-git-send-email-yamada.masahiro@socionext.com> References: <1524135818-14825-1-git-send-email-yamada.masahiro@socionext.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org It is not a good idea to directly modify the resource of a platform device. Modify its local copy, and 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 Reviewed-by: Masami Hiramatsu --- Changes in v2: None drivers/usb/dwc3/core.c | 32 ++++++++------------------------ 1 file changed, 8 insertions(+), 24 deletions(-) diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index a15648d..8e66edd 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -1245,7 +1245,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; @@ -1270,20 +1270,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); @@ -1350,29 +1349,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); -- 2.7.4