From patchwork Sat Sep 17 13:43:31 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 9337095 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 9180460839 for ; Sat, 17 Sep 2016 13:44:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 83F562968F for ; Sat, 17 Sep 2016 13:44:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 785F629698; Sat, 17 Sep 2016 13:44:47 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 241332968F for ; Sat, 17 Sep 2016 13:44:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751694AbcIQNoq (ORCPT ); Sat, 17 Sep 2016 09:44:46 -0400 Received: from mout.web.de ([212.227.15.3]:65163 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751304AbcIQNop (ORCPT ); Sat, 17 Sep 2016 09:44:45 -0400 Received: from [192.168.178.152] ([91.50.213.247]) by smtp.web.de (mrweb002) with ESMTPSA (Nemesis) id 0LcPm2-1bKU9v0efO-00judT; Sat, 17 Sep 2016 15:44:41 +0200 From: Heiner Kallweit Subject: [PATCH 3/4] spi: fsl-espi: improve return value handling in fsl_espi_probe To: Mark Brown References: <1d67ce99-42ea-c816-da35-e64575cca8ff@web.de> Cc: "linux-spi@vger.kernel.org" Message-ID: Date: Sat, 17 Sep 2016 15:43:31 +0200 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.3.0 MIME-Version: 1.0 In-Reply-To: <1d67ce99-42ea-c816-da35-e64575cca8ff@web.de> X-Provags-ID: V03:K0:cn1dTsDaKViuGBYv6ZcQ3uQf0aMopJ7U2R5AIenJwDLTeBEl8rY Mc4oF7K0ymmAsZ3mfX0h1UxzWjYDL/0DrtB2XQUzubVLoJJVCAOKLrJE0SISDzh4AMn+OMI 7jTGqVYi2Wiq6PP5SH9dV+f91SHuwjUPiiTSSCeHipBzZQkTP6cbAtGdqTmSOBpQe9EjQ/6 2VOgUEk8R5qZVlPAciiRw== X-UI-Out-Filterresults: notjunk:1; V01:K0:S1LJq9H299E=:T8SM+YyP/pPLiMmiO7HQR3 DFJETCL6i+4D3I3vwHtA6NyftTi7lp/gy0Q8V95s9MQAsaNkVa7GJF0OpxY294PncmfcoCUN8 ot5d6H1CWB2AVgRtvuUHD6WSFCQgO2Swh/UnaIhyCM5vv77kBanzs+6THb4p0WNIh/xPmrxp3 YMdEzhRwchgH65KxE2h95jSWu8PaxiguTUrJIDN0cHljPvcm7hqC0BtyFNcMAx397UlT+c3cV Kmb5Ibt+9uTMOjJqWrKXZn8O98cdQcOAy1U4WXybEZOl/jb6IdiBL4LB8ehNOtfSq9Vo/Afhk 0BDgadt3+DfGwVp6aJZNbdTjEY6tQWnP8Lh4Xi3KVAXQhG8TK0/PGUfmIXE1ldMAICnmcOPGe 6tcD8wdTXJjurr1k6LUR00sDy+sCX86ouCIs2zI/1LCYSVH9u+undjRFCJ665gQH55kFTs5V3 Qc6U8XGEYJkVlyZi8xZ8gPVhJykuPDFBI3MpNWJ20mUEmlkWuq2S6p0lHdWFGp9Yqej1NiJxf 69Lky05ZV9ghlidWnO45qn//VVzcbTNFRO2Zln596m6BcN3IBmGdW7wmdiBD2x9KoDhnHhJmC peEkuMe/F9ZWLk9zZCd5/XEl/P4uKh+PfnwfOkWSQ2RDrQjEtL3xe5qCKxLZCCn3y4QGLJqAf a1VB/FkVjyTENjTJFMRHPccGjRBiXG8GJoawyiXdPU65nBGeNBvmFR+PBDIqryVOrH0Rpgm25 avSaFLAEPevHGDyiGJjn2l0JqFPKyLdbVmlNc41+fyN6q4oiLbXnZC9WNqWnY8519ifeyg7yN VJaVBA8 Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The return value of fsl_espi_probe (currently struct spi_master *) is just used for checking whether an error occurred. Change the return value type to int and simplify the code. Signed-off-by: Heiner Kallweit --- drivers/spi/spi-fsl-espi.c | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/drivers/spi/spi-fsl-espi.c b/drivers/spi/spi-fsl-espi.c index dee3f82..7451585 100644 --- a/drivers/spi/spi-fsl-espi.c +++ b/drivers/spi/spi-fsl-espi.c @@ -538,8 +538,8 @@ static size_t fsl_espi_max_message_size(struct spi_device *spi) return SPCOM_TRANLEN_MAX; } -static struct spi_master * fsl_espi_probe(struct device *dev, - struct resource *mem, unsigned int irq) +static int fsl_espi_probe(struct device *dev, struct resource *mem, + unsigned int irq) { struct fsl_spi_platform_data *pdata = dev_get_platdata(dev); struct spi_master *master; @@ -547,13 +547,11 @@ static struct spi_master * fsl_espi_probe(struct device *dev, struct device_node *nc; const __be32 *prop; u32 regval, csmode; - int i, len, ret = 0; + int i, len, ret; master = spi_alloc_master(dev, sizeof(struct mpc8xxx_spi)); - if (!master) { - ret = -ENOMEM; - goto err; - } + if (!master) + return -ENOMEM; dev_set_drvdata(dev, master); @@ -647,7 +645,7 @@ static struct spi_master * fsl_espi_probe(struct device *dev, pm_runtime_mark_last_busy(dev); pm_runtime_put_autosuspend(dev); - return master; + return 0; err_pm: pm_runtime_put_noidle(dev); @@ -655,8 +653,7 @@ err_pm: pm_runtime_set_suspended(dev); err_probe: spi_master_put(master); -err: - return ERR_PTR(ret); + return ret; } static int of_fsl_espi_get_chipselects(struct device *dev) @@ -682,7 +679,6 @@ static int of_fsl_espi_probe(struct platform_device *ofdev) { struct device *dev = &ofdev->dev; struct device_node *np = ofdev->dev.of_node; - struct spi_master *master; struct resource mem; unsigned int irq; int ret; @@ -703,11 +699,7 @@ static int of_fsl_espi_probe(struct platform_device *ofdev) if (!irq) return -EINVAL; - master = fsl_espi_probe(dev, &mem, irq); - if (IS_ERR(master)) - return PTR_ERR(master); - - return 0; + return fsl_espi_probe(dev, &mem, irq); } static int of_fsl_espi_remove(struct platform_device *dev)