From patchwork Mon Jun 3 10:13:20 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 2651791 Return-Path: X-Original-To: patchwork-linux-fbdev@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 2D2EDDF24C for ; Mon, 3 Jun 2013 10:14:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756838Ab3FCKNo (ORCPT ); Mon, 3 Jun 2013 06:13:44 -0400 Received: from mail-wg0-f51.google.com ([74.125.82.51]:58411 "EHLO mail-wg0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755734Ab3FCKNm (ORCPT ); Mon, 3 Jun 2013 06:13:42 -0400 Received: by mail-wg0-f51.google.com with SMTP id b13so3034148wgh.30 for ; Mon, 03 Jun 2013 03:13:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references:in-reply-to:references:content-type:x-gm-message-state; bh=jrwE28fmhHu2JTK2b7lxsKwWnXFncBV/Xiy2A6juchY=; b=nBW8kcDj+0uVHuu1UI7HlP+C14K/JMO1id8fLvO5GN3wf9XSqwJ218g7xr1Uz9UFuN hzwpyQZE2hl/iVpvM3YXd99FSYbndrxBT2r6re94/txEV9b2F5aTbEpoh255SUnBHYei 3Kbsy1uVyVR46fKoO7GU2icmdNRU+s4LSluO2oA7EPYJFuVWTy3gsx14HwMh3kFUhwYJ jXn5FSTO2/Q3xAY7LYdPeFAOmKCKLbvGKSw8Dylo60/m9H7puYBBL6Bkt7/lRY00l6fd +lDxrVEHkAGYi4du1+MQjqRm3YHNJhfwSO9P1hZHUtiG3kAmtOKTbewqiZNHqQV3SZVx w4KA== X-Received: by 10.180.188.141 with SMTP id ga13mr12207710wic.9.1370254420800; Mon, 03 Jun 2013 03:13:40 -0700 (PDT) Received: from localhost (nat-63.starnet.cz. [178.255.168.63]) by mx.google.com with ESMTPSA id d5sm22366362wic.1.2013.06.03.03.13.38 for (version=TLSv1.1 cipher=RC4-SHA bits=128/128); Mon, 03 Jun 2013 03:13:39 -0700 (PDT) From: Michal Simek To: linux-kernel@vger.kernel.org Cc: Michal Simek , Michal Simek , Arnd Bergmann , Timur Tabi , Jean-Christophe Plagniol-Villard , Tomi Valkeinen , linux-fbdev@vger.kernel.org Subject: [PATCH v4 5/7] video: xilinxfb: Group bus initialization Date: Mon, 3 Jun 2013 12:13:20 +0200 Message-Id: <565293cecf0605bfb1e8eb9c657731ac4975e496.1370254386.git.michal.simek@xilinx.com> X-Mailer: git-send-email 1.8.2.3 In-Reply-To: References: In-Reply-To: References: X-Gm-Message-State: ALoCoQml/uHHt/d2asnLyaqgG0DPIIxE9wXMgp6g12ihjOxOChM1jp6F0IcLz5Gqo/UuOfqwRnT0 Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org Move of_address_to_resource() to xilinxfb_assign() which simplify driver probing. Signed-off-by: Michal Simek --- Changes in v4: None Changes in v3: - New patch in this patchset Changes in v2: None drivers/video/xilinxfb.c | 56 +++++++++++++----------------------------------- 1 file changed, 15 insertions(+), 41 deletions(-) -- 1.8.2.3 diff --git a/drivers/video/xilinxfb.c b/drivers/video/xilinxfb.c index 1b55f18..bd3b85d 100644 --- a/drivers/video/xilinxfb.c +++ b/drivers/video/xilinxfb.c @@ -227,33 +227,23 @@ static struct fb_ops xilinxfb_ops = * Bus independent setup/teardown */ -static int xilinxfb_assign(struct device *dev, +static int xilinxfb_assign(struct platform_device *pdev, struct xilinxfb_drvdata *drvdata, - unsigned long physaddr, struct xilinxfb_platform_data *pdata) { int rc; + struct device *dev = &pdev->dev; int fbsize = pdata->xvirt * pdata->yvirt * BYTES_PER_PIXEL; if (drvdata->flags & BUS_ACCESS_FLAG) { - /* - * Map the control registers in if the controller - * is on direct BUS interface. - */ - if (!request_mem_region(physaddr, 8, DRIVER_NAME)) { - dev_err(dev, "Couldn't lock memory region at 0x%08lX\n", - physaddr); - rc = -ENODEV; - goto err_region; - } + struct resource *res; - drvdata->regs_phys = physaddr; - drvdata->regs = ioremap(physaddr, 8); + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + drvdata->regs_phys = res->start; + drvdata->regs = devm_request_and_ioremap(&pdev->dev, res); if (!drvdata->regs) { - dev_err(dev, "Couldn't lock memory region at 0x%08lX\n", - physaddr); - rc = -ENODEV; - goto err_map; + rc = -EADDRNOTAVAIL; + goto err_region; } } @@ -349,11 +339,7 @@ err_cmap: err_fbmem: if (drvdata->flags & BUS_ACCESS_FLAG) - iounmap(drvdata->regs); - -err_map: - if (drvdata->flags & BUS_ACCESS_FLAG) - release_mem_region(drvdata->regs_phys, 8); + devm_iounmap(dev, drvdata->regs); err_region: kfree(drvdata); @@ -384,10 +370,8 @@ static int xilinxfb_release(struct device *dev) xilinx_fb_out32(drvdata, REG_CTRL, 0); /* Release the resources, as allocated based on interface */ - if (drvdata->flags & BUS_ACCESS_FLAG) { - iounmap(drvdata->regs); - release_mem_region(drvdata->regs_phys, 8); - } + if (drvdata->flags & BUS_ACCESS_FLAG) + devm_iounmap(dev, drvdata->regs); #ifdef CONFIG_PPC_DCR else dcr_unmap(drvdata->dcr_host, drvdata->dcr_len); @@ -408,8 +392,7 @@ static int xilinxfb_of_probe(struct platform_device *op) const u32 *prop; u32 tft_access = 0; struct xilinxfb_platform_data pdata; - struct resource res; - int size, rc; + int size; struct xilinxfb_drvdata *drvdata; /* Copy with the default pdata (not a ptr reference!) */ @@ -435,22 +418,17 @@ static int xilinxfb_of_probe(struct platform_device *op) */ if (tft_access) { drvdata->flags |= BUS_ACCESS_FLAG; - rc = of_address_to_resource(op->dev.of_node, 0, &res); - if (rc) { - dev_err(&op->dev, "invalid address\n"); - goto err; - } } #ifdef CONFIG_PPC_DCR else { int start; - res.start = 0; start = dcr_resource_start(op->dev.of_node, 0); drvdata->dcr_len = dcr_resource_len(op->dev.of_node, 0); drvdata->dcr_host = dcr_map(op->dev.of_node, start, drvdata->dcr_len); if (!DCR_MAP_OK(drvdata->dcr_host)) { dev_err(&op->dev, "invalid DCR address\n"); - goto err; + kfree(drvdata); + return -ENODEV; } } #endif @@ -477,11 +455,7 @@ static int xilinxfb_of_probe(struct platform_device *op) pdata.rotate_screen = 1; dev_set_drvdata(&op->dev, drvdata); - return xilinxfb_assign(&op->dev, drvdata, res.start, &pdata); - - err: - kfree(drvdata); - return -ENODEV; + return xilinxfb_assign(op, drvdata, &pdata); } static int xilinxfb_of_remove(struct platform_device *op)