From patchwork Wed Jun 4 09:04:52 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vivek Gautam X-Patchwork-Id: 4292621 Return-Path: X-Original-To: patchwork-linux-samsung-soc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 4C850BEEA7 for ; Wed, 4 Jun 2014 09:05:02 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 693AD20212 for ; Wed, 4 Jun 2014 09:05:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9595B201C7 for ; Wed, 4 Jun 2014 09:04:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751410AbaFDJEy (ORCPT ); Wed, 4 Jun 2014 05:04:54 -0400 Received: from mail-pb0-f46.google.com ([209.85.160.46]:50901 "EHLO mail-pb0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751240AbaFDJEw (ORCPT ); Wed, 4 Jun 2014 05:04:52 -0400 Received: by mail-pb0-f46.google.com with SMTP id rq2so6699358pbb.5 for ; Wed, 04 Jun 2014 02:04:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=fZvPzoiCELDqx3lZuR6Nmk7c6Q6d2fjb6SLz5LF0CVg=; b=GzEb0U87X11ZRwtm6olsvSMWjC5u573k/UJtsOrFG6MbTsZ1DjF/bR/Ufap2O3tVOe jZVZSnFWsMPuvNpW/5LIcayAJuK2o8RYbfB6Tqyxd0n8U1HsaOqGbGUCKH8PPcf7s7SS 9flGLLK13zqNY8iQH/FICZU3KXwO8Nq8GA78nqWDHZVJsx3iAYITwe0AXybq+FW5nEWD ryYXt6PoczW+qzV3wKraUsGK0cEt44Npy44wyFfGzRMiHr/VkdXmDYz+8HUi6HXq56pw Q9BFWESUxdq5QZ81vSIeTHp2ZVsngYeY9oPhpfe6tvvZDKrSsA9VA/Az7wyPuz0LJpUt ME3g== X-Received: by 10.69.25.105 with SMTP id ip9mr61394437pbd.145.1401872691772; Wed, 04 Jun 2014 02:04:51 -0700 (PDT) Received: from vivek-linuxpc.sisodomain.com ([14.140.216.146]) by mx.google.com with ESMTPSA id hb10sm7352429pbd.75.2014.06.04.02.04.48 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 04 Jun 2014 02:04:51 -0700 (PDT) From: Vivek Gautam To: linux-usb@vger.kernel.org, linux-samsung-soc@vger.kernel.org, balbi@ti.com Cc: linux-kernel@vger.kernel.org, linux-omap@vger.kernel.org, gregkh@linuxfoundation.org, Paul.Zimmerman@synopsys.com, kishon@ti.com, Vivek Gautam Subject: [PATCH v2] usb: dwc3: Keeping 'resource' related code together Date: Wed, 4 Jun 2014 14:34:52 +0530 Message-Id: <1401872692-7846-1-git-send-email-gautam.vivek@samsung.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: References: Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Putting together the code related to getting the 'IORESOURCE_MEM' and assigning the same to dwc->xhci_resources, for increasing the readability. Signed-off-by: Vivek Gautam --- Changes from v1: - Fixed issue with 'res->start' as pointed out by Paul Zimmerman by decrementing it back to its original value. drivers/usb/dwc3/core.c | 44 +++++++++++++++++++++++++------------------- 1 file changed, 25 insertions(+), 19 deletions(-) diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index 3f59c12..8b1acad 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -656,6 +656,31 @@ static int dwc3_probe(struct platform_device *pdev) return -ENODEV; } + dwc->xhci_resources[0].start = res->start; + dwc->xhci_resources[0].end = dwc->xhci_resources[0].start + + DWC3_XHCI_REGS_END; + 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)) + return PTR_ERR(regs); + + dwc->regs = regs; + dwc->regs_size = resource_size(res); + /* + * 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; + if (node) { dwc->maximum_speed = of_usb_get_maximum_speed(node); @@ -676,28 +701,9 @@ static int dwc3_probe(struct platform_device *pdev) if (ret) return ret; - dwc->xhci_resources[0].start = res->start; - dwc->xhci_resources[0].end = dwc->xhci_resources[0].start + - DWC3_XHCI_REGS_END; - 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)) - return PTR_ERR(regs); - spin_lock_init(&dwc->lock); platform_set_drvdata(pdev, dwc); - dwc->regs = regs; - dwc->regs_size = resource_size(res); - dev->dma_mask = dev->parent->dma_mask; dev->dma_parms = dev->parent->dma_parms; dma_set_coherent_mask(dev, dev->parent->coherent_dma_mask);