From patchwork Sun Nov 11 15:59:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Slawomir Stepien X-Patchwork-Id: 10677729 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 259E51926 for ; Sun, 11 Nov 2018 15:58:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 13FB82A3D6 for ; Sun, 11 Nov 2018 15:58:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 085902A3DA; Sun, 11 Nov 2018 15:58:57 +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=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,FREEMAIL_FROM,MAILING_LIST_MULTI,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 482062A3D6 for ; Sun, 11 Nov 2018 15:58:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728746AbeKLBrr (ORCPT ); Sun, 11 Nov 2018 20:47:47 -0500 Received: from smtpo.poczta.interia.pl ([217.74.65.236]:55166 "EHLO smtpo.poczta.interia.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728742AbeKLBrr (ORCPT ); Sun, 11 Nov 2018 20:47:47 -0500 X-Interia-R: Interia X-Interia-R-IP: 188.121.17.172 X-Interia-R-Helo: Received: from localhost (ipv4-188-121-17-172.net.internetunion.pl [188.121.17.172]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by www.poczta.fm (INTERIA.PL) with ESMTPSA; Sun, 11 Nov 2018 16:58:48 +0100 (CET) From: Slawomir Stepien To: lars@metafoo.de, Michael.Hennerich@analog.com, jic23@kernel.org, knaack.h@gmx.de, pmeerw@pmeerw.net Cc: linux-iio@vger.kernel.org, gregkh@linuxfoundation.org Subject: [PATCH v6 1/2] staging: iio: adc: ad7280a: power down the device on error in probe Date: Sun, 11 Nov 2018 16:59:10 +0100 Message-Id: <20181111155911.3604-2-sst@poczta.fm> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181111155911.3604-1-sst@poczta.fm> References: <20181111155911.3604-1-sst@poczta.fm> MIME-Version: 1.0 X-Interia-Antivirus: OK DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=interia.pl; s=biztos; t=1541951930; bh=uPbLkIYBzcna/EuGRcHRWEqEMXIOxW4n8AAJZdWVZsQ=; h=X-Interia-R:X-Interia-R-IP:X-Interia-R-Helo:From:To:Cc:Subject: Date:Message-Id:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding:X-Interia-Antivirus; b=sVFK5mRF460DMrdQMlSp3KwNmA5Otat5ona3oSrH8J+ZqDyrviCfY7ezEc1pMVM0A 46K/EsAAPkxfhqmuABbphaLWGjAXWAineFgcy+6rUylWqSYS5KtBl1+oc+1o/nRfva pQSCbjckit8y77yRwdc63i5R7yYpCYSjaU4IPLQ8= Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Power down the device if anything goes wrong after the SPI has been setup correctly in the probe function. Existing code that toggles the AD7280A_CTRL_LB_SWRST bit inside ad7280_chain_setup function is responsible for powering up the device. Signed-off-by: Slawomir Stepien --- drivers/staging/iio/adc/ad7280a.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/staging/iio/adc/ad7280a.c b/drivers/staging/iio/adc/ad7280a.c index 58420dcb406d..3ab06fd87675 100644 --- a/drivers/staging/iio/adc/ad7280a.c +++ b/drivers/staging/iio/adc/ad7280a.c @@ -870,7 +870,7 @@ static int ad7280_probe(struct spi_device *spi) ret = ad7280_chain_setup(st); if (ret < 0) - return ret; + goto error_power_down; st->slave_num = ret; st->scan_cnt = (st->slave_num + 1) * AD7280A_NUM_CH; @@ -901,7 +901,7 @@ static int ad7280_probe(struct spi_device *spi) ret = ad7280_channel_init(st); if (ret < 0) - return ret; + goto error_power_down; indio_dev->num_channels = ret; indio_dev->channels = st->channels; @@ -950,6 +950,9 @@ static int ad7280_probe(struct spi_device *spi) error_free_channels: kfree(st->channels); +error_power_down: + ad7280_write(st, AD7280A_DEVADDR_MASTER, AD7280A_CONTROL_HB, 1, + AD7280A_CTRL_HB_PWRDN_SW | st->ctrl_hb); return ret; }