From patchwork Tue Jul 21 13:50:56 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomeu Vizoso X-Patchwork-Id: 6836591 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 3170A9F38B for ; Tue, 21 Jul 2015 14:14:37 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 51A41205E1 for ; Tue, 21 Jul 2015 14:14:36 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4EB6C20678 for ; Tue, 21 Jul 2015 14:14:35 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZHYJK-0003iB-Rx; Tue, 21 Jul 2015 14:14:22 +0000 Received: from casper.infradead.org ([2001:770:15f::2]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZHXyG-0004rj-KQ for linux-arm-kernel@bombadil.infradead.org; Tue, 21 Jul 2015 13:52:36 +0000 Received: from mail-wi0-f173.google.com ([209.85.212.173]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZHXyE-00074Z-Cg for linux-arm-kernel@lists.infradead.org; Tue, 21 Jul 2015 13:52:35 +0000 Received: by wicgb10 with SMTP id gb10so56397509wic.1 for ; Tue, 21 Jul 2015 06:52:09 -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=/NfCKjdR2r/xI7b0ywonKGi1PGgH8SD0cXAyU4DJnsU=; b=AD00phgQNjoBlwmeTN0226axqyzZU+wkioZVdWh+cKKMxfANCIOzshCS69BNWjiTO2 P+HJY3k4/N0vraaHOckFYtREMDhhNk51kE5aBMPrVYfJbRTvBvxlhLW79harPqTWkzpn 7BQSFvgf5x5wYcF42GQkqjh97TDTNvkzRghQdu8GA8SOmcD8ug+tBmOO5dWXRR3rgmo9 +7BMpbUW8SK1DfYA35E4YyGLqRGQEQgYgZALIcCA8Xy278tYMo4LIENjcyCwPTQu/WNZ 7zVsSwtCI5EiituZH5XLJAdkt5hC6BEzf7qtcoCkiRTrJ+fPRBKSkPGKrVs8UatYMbm6 8ThQ== X-Received: by 10.194.11.7 with SMTP id m7mr68609573wjb.56.1437486729198; Tue, 21 Jul 2015 06:52:09 -0700 (PDT) Received: from cizrna.lan ([109.72.12.178]) by smtp.gmail.com with ESMTPSA id pf4sm37172056wjb.23.2015.07.21.06.52.07 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 21 Jul 2015 06:52:08 -0700 (PDT) From: Tomeu Vizoso To: linux-kernel@vger.kernel.org Subject: [RFC PATCH 14/16] tegra-dpaux: Use devm_resource Date: Tue, 21 Jul 2015 15:50:56 +0200 Message-Id: <1437486658-28365-15-git-send-email-tomeu.vizoso@collabora.com> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1437486658-28365-1-git-send-email-tomeu.vizoso@collabora.com> References: <1437486658-28365-1-git-send-email-tomeu.vizoso@collabora.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150721_145234_443849_E03D0010 X-CRM114-Status: GOOD ( 16.70 ) X-Spam-Score: -2.4 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Arnd Bergmann , Tomeu Vizoso , Stephen Warren , "Rafael J. Wysocki" , Mark Brown , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-5.3 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable 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 Signed-off-by: Tomeu Vizoso --- drivers/gpu/drm/tegra/dpaux.c | 57 ++++++++++++------------------------------- 1 file changed, 15 insertions(+), 42 deletions(-) diff --git a/drivers/gpu/drm/tegra/dpaux.c b/drivers/gpu/drm/tegra/dpaux.c index 512322c58c43..e82e57ca3dde 100644 --- a/drivers/gpu/drm/tegra/dpaux.c +++ b/drivers/gpu/drm/tegra/dpaux.c @@ -245,7 +245,8 @@ static void tegra_dpaux_hotplug(struct work_struct *work) static irqreturn_t tegra_dpaux_irq(int irq, void *data) { - struct tegra_dpaux *dpaux = data; + struct platform_device *pdev = to_platform_device(data); + struct tegra_dpaux *dpaux = platform_get_drvdata(pdev); irqreturn_t ret = IRQ_HANDLED; u32 value; @@ -269,48 +270,22 @@ static irqreturn_t tegra_dpaux_irq(int irq, void *data) static int tegra_dpaux_probe(struct platform_device *pdev) { struct tegra_dpaux *dpaux; - struct resource *regs; u32 value; int err; - dpaux = devm_kzalloc(&pdev->dev, sizeof(*dpaux), GFP_KERNEL); - if (!dpaux) - return -ENOMEM; + dpaux = platform_get_drvdata(pdev); INIT_WORK(&dpaux->work, tegra_dpaux_hotplug); init_completion(&dpaux->complete); INIT_LIST_HEAD(&dpaux->list); dpaux->dev = &pdev->dev; - regs = platform_get_resource(pdev, IORESOURCE_MEM, 0); - dpaux->regs = devm_ioremap_resource(&pdev->dev, regs); - if (IS_ERR(dpaux->regs)) - return PTR_ERR(dpaux->regs); - - dpaux->irq = platform_get_irq(pdev, 0); - if (dpaux->irq < 0) { - dev_err(&pdev->dev, "failed to get IRQ\n"); - return -ENXIO; - } - - dpaux->rst = devm_reset_control_get(&pdev->dev, "dpaux"); - if (IS_ERR(dpaux->rst)) - return PTR_ERR(dpaux->rst); - - dpaux->clk = devm_clk_get(&pdev->dev, NULL); - if (IS_ERR(dpaux->clk)) - return PTR_ERR(dpaux->clk); - err = clk_prepare_enable(dpaux->clk); if (err < 0) return err; reset_control_deassert(dpaux->rst); - dpaux->clk_parent = devm_clk_get(&pdev->dev, "parent"); - if (IS_ERR(dpaux->clk_parent)) - return PTR_ERR(dpaux->clk_parent); - err = clk_prepare_enable(dpaux->clk_parent); if (err < 0) return err; @@ -322,18 +297,6 @@ static int tegra_dpaux_probe(struct platform_device *pdev) return err; } - dpaux->vdd = devm_regulator_get(&pdev->dev, "vdd"); - if (IS_ERR(dpaux->vdd)) - return PTR_ERR(dpaux->vdd); - - err = devm_request_irq(dpaux->dev, dpaux->irq, tegra_dpaux_irq, 0, - dev_name(dpaux->dev), dpaux); - if (err < 0) { - dev_err(dpaux->dev, "failed to request IRQ#%u: %d\n", - dpaux->irq, err); - return err; - } - dpaux->aux.transfer = tegra_dpaux_transfer; dpaux->aux.dev = &pdev->dev; @@ -351,8 +314,6 @@ static int tegra_dpaux_probe(struct platform_device *pdev) list_add_tail(&dpaux->list, &dpaux_list); mutex_unlock(&dpaux_lock); - platform_set_drvdata(pdev, dpaux); - return 0; } @@ -381,10 +342,22 @@ static const struct of_device_id tegra_dpaux_of_match[] = { }; MODULE_DEVICE_TABLE(of, tegra_dpaux_of_match); +static const struct devm_resource tegra_dpaux_resources[] = { + DEVM_ALLOC(tegra_dpaux), + DEVM_IOMAP(tegra_dpaux, regs, 0, 0), + DEVM_RESET(tegra_dpaux, rst, "dpaux"), + DEVM_CLOCK(tegra_dpaux, clk, NULL), + DEVM_CLOCK(tegra_dpaux, clk_parent, "parent"), + DEVM_REGULATOR(tegra_dpaux, vdd, "vdd"), + DEVM_IRQ(tegra_dpaux, irq, 0, tegra_dpaux_irq, 0), + {}, +}; + struct platform_driver tegra_dpaux_driver = { .driver = { .name = "tegra-dpaux", .of_match_table = tegra_dpaux_of_match, + .resources = tegra_dpaux_resources, }, .probe = tegra_dpaux_probe, .remove = tegra_dpaux_remove,