From patchwork Wed Aug 26 19:21:50 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 7079661 Return-Path: X-Original-To: patchwork-linux-spi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id E59C1BEEC1 for ; Wed, 26 Aug 2015 19:23:07 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C9F6720966 for ; Wed, 26 Aug 2015 19:23:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B0EDA20967 for ; Wed, 26 Aug 2015 19:23:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752194AbbHZTXF (ORCPT ); Wed, 26 Aug 2015 15:23:05 -0400 Received: from mail-wi0-f175.google.com ([209.85.212.175]:37840 "EHLO mail-wi0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751919AbbHZTXE (ORCPT ); Wed, 26 Aug 2015 15:23:04 -0400 Received: by widdq5 with SMTP id dq5so24534737wid.0 for ; Wed, 26 Aug 2015 12:23:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:cc:subject :content-type:content-transfer-encoding; bh=oafQykJoKqTtaFf6FE+p1We8ipAdade0OTzJYxi7joU=; b=LGwGkcyxM00kgLTpPeVFfTs6G7O6X1mSOZ0pna1qWkyEwD4qsKu7Jeu9XbiUxbkm0x AAVcJvcr/QXRuv41t0nGhabY9jwpkXY0PgDDMOdQjAKFGQBZuK+9zttnFBfm5/vWmJsg iBNWMUGUMinvYQy1QXTh4UzsHRIop0jvDvEh9QDQkdgusqMjUalgKH078WFpfVwpOBLr o8yPRQ6q+1Zhs3SgnIEI6N5fpdCXKI/2Kf3i8kyCplN8AG5kY3wcPEyX7drirEsHjFyq 9AbmE5RKTmoSc+7A2sOfEh6SJrYmWw42BB/Co7dGScOQK57ZIgVOVokj2FUELqiuIfK+ 6ajQ== X-Received: by 10.194.174.201 with SMTP id bu9mr24861wjc.73.1440616982975; Wed, 26 Aug 2015 12:23:02 -0700 (PDT) Received: from ?IPv6:2003:62:5f33:d300:d9f5:3632:9aad:8006? (p200300625F33D300D9F536329AAD8006.dip0.t-ipconnect.de. [2003:62:5f33:d300:d9f5:3632:9aad:8006]) by smtp.googlemail.com with ESMTPSA id ck18sm5246627wjb.47.2015.08.26.12.23.02 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 26 Aug 2015 12:23:02 -0700 (PDT) Message-ID: <55DE11CE.7090508@gmail.com> Date: Wed, 26 Aug 2015 21:21:50 +0200 From: Heiner Kallweit User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: Mark Brown CC: "linux-spi@vger.kernel.org" Subject: [PATCH v2 1/3] spi: fsl-(e)spi: migrate to using devm_ functions to simplify cleanup Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org X-Spam-Status: No, score=-8.2 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, 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 Migrate fsl-espi and fsl-spi to using the managed devm_ functions for resource handling. This simplifies the cleanup. Signed-off-by: Heiner Kallweit --- v2: - changed devm_ioremap to devm_ioremap_resource - remove fsl_espi_remove as it would be empty afterwards drivers/spi/spi-fsl-espi.c | 20 +++++--------------- drivers/spi/spi-fsl-lib.c | 4 ---- drivers/spi/spi-fsl-spi.c | 21 ++++++++------------- 3 files changed, 13 insertions(+), 32 deletions(-) diff --git a/drivers/spi/spi-fsl-espi.c b/drivers/spi/spi-fsl-espi.c index d3f05a0..f35eb2c 100644 --- a/drivers/spi/spi-fsl-espi.c +++ b/drivers/spi/spi-fsl-espi.c @@ -604,11 +604,6 @@ static irqreturn_t fsl_espi_irq(s32 irq, void *context_data) return ret; } -static void fsl_espi_remove(struct mpc8xxx_spi *mspi) -{ - iounmap(mspi->reg_base); -} - static int fsl_espi_suspend(struct spi_master *master) { struct mpc8xxx_spi *mpc8xxx_spi; @@ -671,9 +666,8 @@ static struct spi_master * fsl_espi_probe(struct device *dev, master->unprepare_transfer_hardware = fsl_espi_suspend; mpc8xxx_spi = spi_master_get_devdata(master); - mpc8xxx_spi->spi_remove = fsl_espi_remove; - mpc8xxx_spi->reg_base = ioremap(mem->start, resource_size(mem)); + mpc8xxx_spi->reg_base = devm_ioremap_resource(dev, mem); if (!mpc8xxx_spi->reg_base) { ret = -ENOMEM; goto err_probe; @@ -682,10 +676,10 @@ static struct spi_master * fsl_espi_probe(struct device *dev, reg_base = mpc8xxx_spi->reg_base; /* Register for SPI Interrupt */ - ret = request_irq(mpc8xxx_spi->irq, fsl_espi_irq, + ret = devm_request_irq(dev, mpc8xxx_spi->irq, fsl_espi_irq, 0, "fsl_espi", mpc8xxx_spi); if (ret) - goto free_irq; + goto err_probe; if (mpc8xxx_spi->flags & SPI_QE_CPU_MODE) { mpc8xxx_spi->rx_shift = 16; @@ -731,18 +725,14 @@ static struct spi_master * fsl_espi_probe(struct device *dev, mpc8xxx_spi_write_reg(®_base->mode, regval); - ret = spi_register_master(master); + ret = devm_spi_register_master(dev, master); if (ret < 0) - goto unreg_master; + goto err_probe; dev_info(dev, "at 0x%p (irq = %d)\n", reg_base, mpc8xxx_spi->irq); return master; -unreg_master: - free_irq(mpc8xxx_spi->irq, mpc8xxx_spi); -free_irq: - iounmap(mpc8xxx_spi->reg_base); err_probe: spi_master_put(master); err: diff --git a/drivers/spi/spi-fsl-lib.c b/drivers/spi/spi-fsl-lib.c index cb35d2f..e50fd06 100644 --- a/drivers/spi/spi-fsl-lib.c +++ b/drivers/spi/spi-fsl-lib.c @@ -122,10 +122,6 @@ int mpc8xxx_spi_remove(struct device *dev) master = dev_get_drvdata(dev); mpc8xxx_spi = spi_master_get_devdata(master); - spi_unregister_master(master); - - free_irq(mpc8xxx_spi->irq, mpc8xxx_spi); - if (mpc8xxx_spi->spi_remove) mpc8xxx_spi->spi_remove(mpc8xxx_spi); diff --git a/drivers/spi/spi-fsl-spi.c b/drivers/spi/spi-fsl-spi.c index 60c5907..8bfbe9e 100644 --- a/drivers/spi/spi-fsl-spi.c +++ b/drivers/spi/spi-fsl-spi.c @@ -561,7 +561,6 @@ static irqreturn_t fsl_spi_irq(s32 irq, void *context_data) static void fsl_spi_remove(struct mpc8xxx_spi *mspi) { - iounmap(mspi->reg_base); fsl_spi_cpm_free(mspi); } @@ -639,10 +638,10 @@ static struct spi_master * fsl_spi_probe(struct device *dev, if (ret) goto err_cpm_init; - mpc8xxx_spi->reg_base = ioremap(mem->start, resource_size(mem)); + mpc8xxx_spi->reg_base = devm_ioremap_resource(dev, mem); if (mpc8xxx_spi->reg_base == NULL) { ret = -ENOMEM; - goto err_ioremap; + goto err_probe; } if (mpc8xxx_spi->type == TYPE_GRLIB) @@ -661,11 +660,11 @@ static struct spi_master * fsl_spi_probe(struct device *dev, &mpc8xxx_spi->tx_shift, 8, 1); /* Register for SPI Interrupt */ - ret = request_irq(mpc8xxx_spi->irq, fsl_spi_irq, - 0, "fsl_spi", mpc8xxx_spi); + ret = devm_request_irq(dev, mpc8xxx_spi->irq, fsl_spi_irq, + 0, "fsl_spi", mpc8xxx_spi); if (ret != 0) - goto free_irq; + goto err_probe; reg_base = mpc8xxx_spi->reg_base; @@ -686,20 +685,16 @@ static struct spi_master * fsl_spi_probe(struct device *dev, mpc8xxx_spi_write_reg(®_base->mode, regval); - ret = spi_register_master(master); + ret = devm_spi_register_master(dev, master); if (ret < 0) - goto unreg_master; + goto err_probe; dev_info(dev, "at 0x%p (irq = %d), %s mode\n", reg_base, mpc8xxx_spi->irq, mpc8xxx_spi_strmode(mpc8xxx_spi->flags)); return master; -unreg_master: - free_irq(mpc8xxx_spi->irq, mpc8xxx_spi); -free_irq: - iounmap(mpc8xxx_spi->reg_base); -err_ioremap: +err_probe: fsl_spi_cpm_free(mpc8xxx_spi); err_cpm_init: spi_master_put(master);