From patchwork Wed Oct 2 08:57:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 11170637 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 636AE112B for ; Wed, 2 Oct 2019 08:58:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3788B218DE for ; Wed, 2 Oct 2019 08:58:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=bgdev-pl.20150623.gappssmtp.com header.i=@bgdev-pl.20150623.gappssmtp.com header.b="mNaI0NVF" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727452AbfJBI6L (ORCPT ); Wed, 2 Oct 2019 04:58:11 -0400 Received: from mail-wm1-f66.google.com ([209.85.128.66]:51930 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727363AbfJBI6L (ORCPT ); Wed, 2 Oct 2019 04:58:11 -0400 Received: by mail-wm1-f66.google.com with SMTP id 7so6270697wme.1 for ; Wed, 02 Oct 2019 01:58:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=toqSCbDKjKDNRGlIhRc6C/qDd5dUDz6VgJWTVy4eu6w=; b=mNaI0NVFqxeuET9HKNSQdq+4dLrjPuaOqsvskqSt8Eyts9NrwJj1cAiwiEMqkY3LuX JNb2Lzi37aKP7eef9evUvY+hlnVXMLv12DK+XbWm+5e0JN3k9+d5euPbXQ+JqBeoWRWE 4W8qHg8p8chBKrmalPnkS22AsyR7cDeYW3Q8PcPEfRELrMoByxgNeUgPk0g5KlhCiC+E LyZJR7VZjltjzgsdZlpTWMPNJb4OdT6MNOlAMVeLlZ9XqcWFxZyyhw8V8RrBk4YRypWg lqZJz/7qQPlKw2Zckn3HV+HSEp/hNXd0U7Jhpl5CQlDI8N8qLGmpwhrz6s6m0ZZducJJ Fxcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=toqSCbDKjKDNRGlIhRc6C/qDd5dUDz6VgJWTVy4eu6w=; b=VUzA/dw0Le9S098Un0YlaZWWa5hT2Eqhi38fbvpXMWnqrWyH9fVb99vxCiiMUdJ4T1 Xx+Emdu94ZTbtb6LQXQjLR50fz0AqGxmpTjUaAhFx/iGcRskVKEENUvC8VusOwKtz43O ipAeoMCd5q+xbhRmIBX4+A7Ae2NVNhg9VgKC+AXBJ63eQBi8S9T//qXOhHukO9Zzen4S S7K0wq/QHVB37ccxQNblunx1w9/7jV2R+8LU+kkUKzg+X0+5HrU3IiZdJcqz8TdUQjTc O1yvF1HGVqVO4aU/6wcG9jWYKl99nBdPkKNtTiXwAFFyx+dVLu7tcM7vd8bSu2U3mGBg Hg2Q== X-Gm-Message-State: APjAAAU6v1vNE+uUAqjqgewndKssC+/mqzKUbjXgEpw9mMNXYzDzq/jr TyOEIjZPizYmBJclJv+QAhp5zGzVDKY= X-Google-Smtp-Source: APXvYqz9OH4tpQEQYea+bSGT9Q8PNCBRt6XTtpq4N5s0l0cHZ0LJzdEOZ5ZdpjRV6BidrQ89cScjeQ== X-Received: by 2002:a7b:c4c7:: with SMTP id g7mr1880636wmk.11.1570006687787; Wed, 02 Oct 2019 01:58:07 -0700 (PDT) Received: from debian-brgl.home ([2a01:cb1d:af:5b00:6d6c:8493:1ab5:dad7]) by smtp.gmail.com with ESMTPSA id b186sm10115616wmd.16.2019.10.02.01.58.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Oct 2019 01:58:07 -0700 (PDT) From: Bartosz Golaszewski To: Jonathan Cameron , Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH 1/4] iio: pressure: bmp280: use bulk regulator ops Date: Wed, 2 Oct 2019 10:57:56 +0200 Message-Id: <20191002085759.13337-2-brgl@bgdev.pl> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191002085759.13337-1-brgl@bgdev.pl> References: <20191002085759.13337-1-brgl@bgdev.pl> MIME-Version: 1.0 Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org From: Bartosz Golaszewski The vddd and vdda supplies are always operated on together. We can shrink the code a bit by using the bulk regulator helpers. Signed-off-by: Bartosz Golaszewski --- drivers/iio/pressure/bmp280-core.c | 69 +++++++++++++----------------- 1 file changed, 30 insertions(+), 39 deletions(-) diff --git a/drivers/iio/pressure/bmp280-core.c b/drivers/iio/pressure/bmp280-core.c index 8d0f15f27dc5..c21f8ce7b09c 100644 --- a/drivers/iio/pressure/bmp280-core.c +++ b/drivers/iio/pressure/bmp280-core.c @@ -74,6 +74,12 @@ struct bmp280_calib { s8 H6; }; +static const char *const bmp280_supply_names[] = { + "vddd", "vdda" +}; + +#define BMP280_NUM_SUPPLIES ARRAY_SIZE(bmp280_supply_names) + struct bmp280_data { struct device *dev; struct mutex lock; @@ -85,8 +91,7 @@ struct bmp280_data { struct bmp180_calib bmp180; struct bmp280_calib bmp280; } calib; - struct regulator *vddd; - struct regulator *vdda; + struct regulator_bulk_data supplies[BMP280_NUM_SUPPLIES]; unsigned int start_up_time; /* in microseconds */ /* log of base 2 of oversampling rate */ @@ -1033,27 +1038,23 @@ int bmp280_common_probe(struct device *dev, } /* Bring up regulators */ - data->vddd = devm_regulator_get(dev, "vddd"); - if (IS_ERR(data->vddd)) { - dev_err(dev, "failed to get VDDD regulator\n"); - return PTR_ERR(data->vddd); - } - ret = regulator_enable(data->vddd); + regulator_bulk_set_supply_names(data->supplies, + bmp280_supply_names, + BMP280_NUM_SUPPLIES); + + ret = devm_regulator_bulk_get(dev, + BMP280_NUM_SUPPLIES, data->supplies); if (ret) { - dev_err(dev, "failed to enable VDDD regulator\n"); + dev_err(dev, "failed to get regulators\n"); return ret; } - data->vdda = devm_regulator_get(dev, "vdda"); - if (IS_ERR(data->vdda)) { - dev_err(dev, "failed to get VDDA regulator\n"); - ret = PTR_ERR(data->vdda); - goto out_disable_vddd; - } - ret = regulator_enable(data->vdda); + + ret = regulator_bulk_enable(BMP280_NUM_SUPPLIES, data->supplies); if (ret) { - dev_err(dev, "failed to enable VDDA regulator\n"); - goto out_disable_vddd; + dev_err(dev, "failed to enable regulators\n"); + return ret; } + /* Wait to make sure we started up properly */ usleep_range(data->start_up_time, data->start_up_time + 100); @@ -1068,17 +1069,17 @@ int bmp280_common_probe(struct device *dev, data->regmap = regmap; ret = regmap_read(regmap, BMP280_REG_ID, &chip_id); if (ret < 0) - goto out_disable_vdda; + goto out_disable_regulators; if (chip_id != chip) { dev_err(dev, "bad chip id: expected %x got %x\n", chip, chip_id); ret = -EINVAL; - goto out_disable_vdda; + goto out_disable_regulators; } ret = data->chip_info->chip_config(data); if (ret < 0) - goto out_disable_vdda; + goto out_disable_regulators; dev_set_drvdata(dev, indio_dev); @@ -1092,14 +1093,14 @@ int bmp280_common_probe(struct device *dev, if (ret < 0) { dev_err(data->dev, "failed to read calibration coefficients\n"); - goto out_disable_vdda; + goto out_disable_regulators; } } else if (chip_id == BMP280_CHIP_ID || chip_id == BME280_CHIP_ID) { ret = bmp280_read_calib(data, &data->calib.bmp280, chip_id); if (ret < 0) { dev_err(data->dev, "failed to read calibration coefficients\n"); - goto out_disable_vdda; + goto out_disable_regulators; } } @@ -1111,7 +1112,7 @@ int bmp280_common_probe(struct device *dev, if (irq > 0 || (chip_id == BMP180_CHIP_ID)) { ret = bmp085_fetch_eoc_irq(dev, name, irq, data); if (ret) - goto out_disable_vdda; + goto out_disable_regulators; } /* Enable runtime PM */ @@ -1137,10 +1138,8 @@ int bmp280_common_probe(struct device *dev, pm_runtime_get_sync(data->dev); pm_runtime_put_noidle(data->dev); pm_runtime_disable(data->dev); -out_disable_vdda: - regulator_disable(data->vdda); -out_disable_vddd: - regulator_disable(data->vddd); +out_disable_regulators: + regulator_bulk_disable(BMP280_NUM_SUPPLIES, data->supplies); return ret; } EXPORT_SYMBOL(bmp280_common_probe); @@ -1154,8 +1153,7 @@ int bmp280_common_remove(struct device *dev) pm_runtime_get_sync(data->dev); pm_runtime_put_noidle(data->dev); pm_runtime_disable(data->dev); - regulator_disable(data->vdda); - regulator_disable(data->vddd); + regulator_bulk_disable(BMP280_NUM_SUPPLIES, data->supplies); return 0; } EXPORT_SYMBOL(bmp280_common_remove); @@ -1165,12 +1163,8 @@ static int bmp280_runtime_suspend(struct device *dev) { struct iio_dev *indio_dev = dev_get_drvdata(dev); struct bmp280_data *data = iio_priv(indio_dev); - int ret; - ret = regulator_disable(data->vdda); - if (ret) - return ret; - return regulator_disable(data->vddd); + return regulator_bulk_disable(BMP280_NUM_SUPPLIES, data->supplies); } static int bmp280_runtime_resume(struct device *dev) @@ -1179,10 +1173,7 @@ static int bmp280_runtime_resume(struct device *dev) struct bmp280_data *data = iio_priv(indio_dev); int ret; - ret = regulator_enable(data->vddd); - if (ret) - return ret; - ret = regulator_enable(data->vdda); + ret = regulator_bulk_enable(BMP280_NUM_SUPPLIES, data->supplies); if (ret) return ret; usleep_range(data->start_up_time, data->start_up_time + 100); From patchwork Wed Oct 2 08:57:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 11170643 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7512217E1 for ; Wed, 2 Oct 2019 08:58:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 53F4C21924 for ; Wed, 2 Oct 2019 08:58:31 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=bgdev-pl.20150623.gappssmtp.com header.i=@bgdev-pl.20150623.gappssmtp.com header.b="p+4pV1fw" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726100AbfJBI6L (ORCPT ); Wed, 2 Oct 2019 04:58:11 -0400 Received: from mail-wm1-f68.google.com ([209.85.128.68]:51934 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727431AbfJBI6L (ORCPT ); Wed, 2 Oct 2019 04:58:11 -0400 Received: by mail-wm1-f68.google.com with SMTP id 7so6270760wme.1 for ; Wed, 02 Oct 2019 01:58:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=CmLXG4bPxTjZzTrvXKweoRTqZA7P9PJe9BBobCWifpI=; b=p+4pV1fwL5wiRu10JvmsXwhr/fPZowUsi2e2jE3rmHPtsQV4aj9xj+d3SjuDU7Fvj3 UeqvgHiSgPkvnTx0wdl2yvW1n9E2pxqPBspUq9UgKg/HuJa8brAGnvmMGMXlCXyzXPq2 ibhkjSJTIovbVPgpyiJLXFmIJ6BTYSt18o5PTdWsmMYXen6HcGmsu/TyeqxWI+YzWT0p 9uT8GKNqNnpMzXRgdkix+m25G0oQoQAcBqqnq9AEjykbpBSAC3v4qRRXrWXpdbgjMsk3 om9PZUq/q13ZPnfV6itub6BVD0QQRfTFlnTZiY29+okGv+Y0oGQCarzL+b0I9+NWxUEw soYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=CmLXG4bPxTjZzTrvXKweoRTqZA7P9PJe9BBobCWifpI=; b=ZBV06SBgKxgUnyNyy7LG6dj2K9+1PPC55fQ2nbE1DiWl+2VfOl+Zbaw18pq/FE4UPe LNzAHXDOyVAOHOaiJa5NAcnNkYYyrkdX+H/btxuu79NM8AEL1URq+qKk8a5+T6rZLBks HiKAtibTZSTqv5RSaERWILdjzP9AuKwlE5x3IbTl6ilX6il8a1+UFjyaMS0kN59VZk/1 4yUaZos71e0hNWg6z+BLsv9MCzrVcAiewLOPQtMjdL0ZbXqZBN+G/IUTlAjqiBo6w1e0 WOnHT4O/7Xycey+WSNXdunbU6IZwndeaWiotLJ0sv+rMze2Wc5LTOZkFvvFZj9VcdHCk nHlA== X-Gm-Message-State: APjAAAUgJ1QrVdw0kieeHp5W5+XbzinUz+RGG3a6e/B3ojKtPNQfJJOB bwz3rrCJ/JsN2th7fnVxcQCXxg== X-Google-Smtp-Source: APXvYqyvWkgBIAqgpGtCM4BIOwtAxm0wEMGIwOSwSyOyi3rWQVrxqpgizmhTk9Wt7y7cEa4onq8dmQ== X-Received: by 2002:a1c:a404:: with SMTP id n4mr1866027wme.137.1570006688761; Wed, 02 Oct 2019 01:58:08 -0700 (PDT) Received: from debian-brgl.home ([2a01:cb1d:af:5b00:6d6c:8493:1ab5:dad7]) by smtp.gmail.com with ESMTPSA id b186sm10115616wmd.16.2019.10.02.01.58.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Oct 2019 01:58:08 -0700 (PDT) From: Bartosz Golaszewski To: Jonathan Cameron , Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH 2/4] iio: pressure: bmp280: use devm_iio_device_register() Date: Wed, 2 Oct 2019 10:57:57 +0200 Message-Id: <20191002085759.13337-3-brgl@bgdev.pl> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191002085759.13337-1-brgl@bgdev.pl> References: <20191002085759.13337-1-brgl@bgdev.pl> MIME-Version: 1.0 Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org From: Bartosz Golaszewski We can use the managed variant of iio_device_register() and remove the corresponding unregister operation from the remove callback. Signed-off-by: Bartosz Golaszewski --- drivers/iio/pressure/bmp280-core.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/iio/pressure/bmp280-core.c b/drivers/iio/pressure/bmp280-core.c index c21f8ce7b09c..f22400e1e98f 100644 --- a/drivers/iio/pressure/bmp280-core.c +++ b/drivers/iio/pressure/bmp280-core.c @@ -1127,7 +1127,7 @@ int bmp280_common_probe(struct device *dev, pm_runtime_use_autosuspend(dev); pm_runtime_put(dev); - ret = iio_device_register(indio_dev); + ret = devm_iio_device_register(dev, indio_dev); if (ret) goto out_runtime_pm_disable; @@ -1149,7 +1149,6 @@ int bmp280_common_remove(struct device *dev) struct iio_dev *indio_dev = dev_get_drvdata(dev); struct bmp280_data *data = iio_priv(indio_dev); - iio_device_unregister(indio_dev); pm_runtime_get_sync(data->dev); pm_runtime_put_noidle(data->dev); pm_runtime_disable(data->dev); From patchwork Wed Oct 2 08:57:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 11170641 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 48422112B for ; Wed, 2 Oct 2019 08:58:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 26D3921920 for ; Wed, 2 Oct 2019 08:58:31 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=bgdev-pl.20150623.gappssmtp.com header.i=@bgdev-pl.20150623.gappssmtp.com header.b="zbgQRRhy" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725963AbfJBI60 (ORCPT ); Wed, 2 Oct 2019 04:58:26 -0400 Received: from mail-wm1-f66.google.com ([209.85.128.66]:50406 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727450AbfJBI6M (ORCPT ); Wed, 2 Oct 2019 04:58:12 -0400 Received: by mail-wm1-f66.google.com with SMTP id 5so6285232wmg.0 for ; Wed, 02 Oct 2019 01:58:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=sb6XXd4XVveOWoqAO2u1k+xpQz65b1SxWMC6fwbGnGA=; b=zbgQRRhyC8p8+iQ7xvNZFW0vTinqDURlrP1CWUQ0C7fm8v/YfZFZpvZdIoqFPW1dYu 0prWnjaAQYC7EyfCh7nLl6Kwj8NtkvYCCUhncleY8zy0THpyP1kIodTCugLPLLNj7j7y +aAZN0CRZEK9/eBqW/sPhgF7F4puZibPPqxf9KB8+QiKbSzTSQoi7JG/A9dUCg/zqTlb MrJPJiFmh1ityoOd8ZB7BBUdv9Lew0WDaNo1y2nOreGBznLymPzCnyEnAyqx4MA/R4hM s1uvw6p7LVb5NWf9q3LGx0xDlO60FWMuEIdqD+PxfVPOiCDp95UTDSTkcRSK1wahRfDD N2yw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=sb6XXd4XVveOWoqAO2u1k+xpQz65b1SxWMC6fwbGnGA=; b=nXi1owAiDIevekP/GSufQXDTON1bqFVamw20qXFut+P6ljPt2eJcdeMsH2DBF1rzbJ W3pZ/8RNyDZ0kq6x5NyMqDkyE4S6b1qJOqOp+gN5+KDutL1uprueQjb3gFGDBhZ0KVtS 8sVwtSV/IgiCOulhjvZcF0FmB9/3KEThTpcnybg2KUPMgVhTuqIZVst0/F7o3v36VtmQ Ye0+jpq1A8+UBe7F4Lgcz7v6h7zofN5MTfzEDPdfVf4JyksVddr+r+cHiXhpvQriT9pa T1JN7Gpp6B6g3d/hyq/1wVbrme33eDLGOWvRWA+TkT437CznbM9IMxf9w4LSyXGi58qu Ocww== X-Gm-Message-State: APjAAAUeNORQCDvfKsSKo7AP0n7PbvqmEUp4I1ACvMCHbCuSRLu/0njt XIHkaJLu+0Q0vhbNwrABrZxLtw== X-Google-Smtp-Source: APXvYqxsuNTI27IKNGHkstrfZxf44n78Md97rHT2Oac0my1+Y4r/yzcwURifHWM9QO2sJAQ3qjSOcA== X-Received: by 2002:a7b:caaa:: with SMTP id r10mr2064638wml.100.1570006689870; Wed, 02 Oct 2019 01:58:09 -0700 (PDT) Received: from debian-brgl.home ([2a01:cb1d:af:5b00:6d6c:8493:1ab5:dad7]) by smtp.gmail.com with ESMTPSA id b186sm10115616wmd.16.2019.10.02.01.58.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Oct 2019 01:58:09 -0700 (PDT) From: Bartosz Golaszewski To: Jonathan Cameron , Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH 3/4] iio: pressure: bmp280: remove stray newline Date: Wed, 2 Oct 2019 10:57:58 +0200 Message-Id: <20191002085759.13337-4-brgl@bgdev.pl> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191002085759.13337-1-brgl@bgdev.pl> References: <20191002085759.13337-1-brgl@bgdev.pl> MIME-Version: 1.0 Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org From: Bartosz Golaszewski Remove a stray newline from the probe callback. Signed-off-by: Bartosz Golaszewski --- drivers/iio/pressure/bmp280-core.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/iio/pressure/bmp280-core.c b/drivers/iio/pressure/bmp280-core.c index f22400e1e98f..fdbd3bc27921 100644 --- a/drivers/iio/pressure/bmp280-core.c +++ b/drivers/iio/pressure/bmp280-core.c @@ -1131,7 +1131,6 @@ int bmp280_common_probe(struct device *dev, if (ret) goto out_runtime_pm_disable; - return 0; out_runtime_pm_disable: From patchwork Wed Oct 2 08:57:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 11170639 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 272CE112B for ; Wed, 2 Oct 2019 08:58:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id F0489218DE for ; Wed, 2 Oct 2019 08:58:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=bgdev-pl.20150623.gappssmtp.com header.i=@bgdev-pl.20150623.gappssmtp.com header.b="0KTmOrvJ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727532AbfJBI6N (ORCPT ); Wed, 2 Oct 2019 04:58:13 -0400 Received: from mail-wr1-f46.google.com ([209.85.221.46]:44453 "EHLO mail-wr1-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727472AbfJBI6N (ORCPT ); Wed, 2 Oct 2019 04:58:13 -0400 Received: by mail-wr1-f46.google.com with SMTP id z9so5530229wrl.11 for ; Wed, 02 Oct 2019 01:58:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=TokpQlwvSqpKkJFZGdtc9HARS2+18tCQ00roLJNHSjE=; b=0KTmOrvJGb/kvJhFEHmI147y/JEhksandLOU7BETHCxeloeAoPaQ+We2xWfZpPogOd sVzS8/3pvXN/45MiOmCZt2adIFBI87jWXV7vD6cIbepg+/M199IsR2Md0MQ7Vo32Ffnm 4msE1rgqB+vQg2icDBxFRcHVvT8OfJQzqst5898uR7UMa+aEm52Do/sv582nnGM3DGOD zn3PI/4W8F6EWarlzJBKdshHi/NE/KuxHt18T353ftQqGVMrM2lwT+83tgDdxXQu2TA4 t9OcrfxV4CqsdIUqE/MqtJXlIZhixTnkYp2etY2uh/VBaZmCQBPvvWFd1Y6oLl8yMx8r ackQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=TokpQlwvSqpKkJFZGdtc9HARS2+18tCQ00roLJNHSjE=; b=aWfyCuyfVJ/vd6P4JmSKEsl8bbrdoX+zL2ZqIPTt8kvLp9qrqlX0t60P08Qc5yE/zM HUg2/WYHJ0ybNSEmbUV2ysnlyASn+l5+MDeKTDVzy+dTZ8QK78jpg9tXKLNhd2uc2V28 UVVfoPoi8gnB4aRvr9Oo4yEcJGMDaCxt7QoQyOpp9rO9xdHemodPH2s0fr+wD7OPFeoF POxDVT6M9iEGo3u1aV5jp2Beg2xbS4YaFX2ft5IQtt5EA7TD6le2N6fc0DUx0i0wBgcx 4dO0kn5uMfL4zjx5+fSpvOzodgU+SyNNaTLlFMLX450lycG8pxdmWxunH37EtkqHbIKs t9nQ== X-Gm-Message-State: APjAAAX/7WnaeYq9Hz7BGpALbiV8Iob7uJWxmoSEMoQXAwq7yoE88dkF nOvQf9zCm0UOd5D4R2VhQSFP3g== X-Google-Smtp-Source: APXvYqyOeBaGiNRxsEsHbImQj+4rli4gayNlC87TTjtS3z+QlYpiLbVQ9JvNWA5RvGn6USh6Q58xSg== X-Received: by 2002:adf:8444:: with SMTP id 62mr1738370wrf.202.1570006691012; Wed, 02 Oct 2019 01:58:11 -0700 (PDT) Received: from debian-brgl.home ([2a01:cb1d:af:5b00:6d6c:8493:1ab5:dad7]) by smtp.gmail.com with ESMTPSA id b186sm10115616wmd.16.2019.10.02.01.58.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Oct 2019 01:58:10 -0700 (PDT) From: Bartosz Golaszewski To: Jonathan Cameron , Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH 4/4] iio: pressure: bmp280: use devm action and remove labels from probe Date: Wed, 2 Oct 2019 10:57:59 +0200 Message-Id: <20191002085759.13337-5-brgl@bgdev.pl> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191002085759.13337-1-brgl@bgdev.pl> References: <20191002085759.13337-1-brgl@bgdev.pl> MIME-Version: 1.0 Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org From: Bartosz Golaszewski We can drop some duplicate code if we use devm_action for disabling regulators and pm. This allows us to completely remove all remove() callbacks from both i2c and spi code. Signed-off-by: Bartosz Golaszewski --- drivers/iio/pressure/bmp280-core.c | 61 +++++++++++++++--------------- drivers/iio/pressure/bmp280-i2c.c | 6 --- drivers/iio/pressure/bmp280-spi.c | 6 --- drivers/iio/pressure/bmp280.h | 1 - 4 files changed, 30 insertions(+), 44 deletions(-) diff --git a/drivers/iio/pressure/bmp280-core.c b/drivers/iio/pressure/bmp280-core.c index fdbd3bc27921..79254dd26dfd 100644 --- a/drivers/iio/pressure/bmp280-core.c +++ b/drivers/iio/pressure/bmp280-core.c @@ -984,6 +984,22 @@ static int bmp085_fetch_eoc_irq(struct device *dev, return 0; } +static void bmp280_pm_disable(void *data) +{ + struct device *dev = data; + + pm_runtime_get_sync(dev); + pm_runtime_put_noidle(dev); + pm_runtime_disable(dev); +} + +static void bmp280_regulators_disable(void *data) +{ + struct regulator_bulk_data *supplies = data; + + regulator_bulk_disable(BMP280_NUM_SUPPLIES, supplies); +} + int bmp280_common_probe(struct device *dev, struct regmap *regmap, unsigned int chip, @@ -1055,6 +1071,11 @@ int bmp280_common_probe(struct device *dev, return ret; } + ret = devm_add_action_or_reset(dev, bmp280_regulators_disable, + data->supplies); + if (ret) + return ret; + /* Wait to make sure we started up properly */ usleep_range(data->start_up_time, data->start_up_time + 100); @@ -1069,17 +1090,16 @@ int bmp280_common_probe(struct device *dev, data->regmap = regmap; ret = regmap_read(regmap, BMP280_REG_ID, &chip_id); if (ret < 0) - goto out_disable_regulators; + return ret; if (chip_id != chip) { dev_err(dev, "bad chip id: expected %x got %x\n", chip, chip_id); - ret = -EINVAL; - goto out_disable_regulators; + return -EINVAL; } ret = data->chip_info->chip_config(data); if (ret < 0) - goto out_disable_regulators; + return ret; dev_set_drvdata(dev, indio_dev); @@ -1093,14 +1113,14 @@ int bmp280_common_probe(struct device *dev, if (ret < 0) { dev_err(data->dev, "failed to read calibration coefficients\n"); - goto out_disable_regulators; + return ret; } } else if (chip_id == BMP280_CHIP_ID || chip_id == BME280_CHIP_ID) { ret = bmp280_read_calib(data, &data->calib.bmp280, chip_id); if (ret < 0) { dev_err(data->dev, "failed to read calibration coefficients\n"); - goto out_disable_regulators; + return ret; } } @@ -1112,7 +1132,7 @@ int bmp280_common_probe(struct device *dev, if (irq > 0 || (chip_id == BMP180_CHIP_ID)) { ret = bmp085_fetch_eoc_irq(dev, name, irq, data); if (ret) - goto out_disable_regulators; + return ret; } /* Enable runtime PM */ @@ -1127,35 +1147,14 @@ int bmp280_common_probe(struct device *dev, pm_runtime_use_autosuspend(dev); pm_runtime_put(dev); - ret = devm_iio_device_register(dev, indio_dev); + ret = devm_add_action_or_reset(dev, bmp280_pm_disable, dev); if (ret) - goto out_runtime_pm_disable; - - return 0; + return ret; -out_runtime_pm_disable: - pm_runtime_get_sync(data->dev); - pm_runtime_put_noidle(data->dev); - pm_runtime_disable(data->dev); -out_disable_regulators: - regulator_bulk_disable(BMP280_NUM_SUPPLIES, data->supplies); - return ret; + return devm_iio_device_register(dev, indio_dev); } EXPORT_SYMBOL(bmp280_common_probe); -int bmp280_common_remove(struct device *dev) -{ - struct iio_dev *indio_dev = dev_get_drvdata(dev); - struct bmp280_data *data = iio_priv(indio_dev); - - pm_runtime_get_sync(data->dev); - pm_runtime_put_noidle(data->dev); - pm_runtime_disable(data->dev); - regulator_bulk_disable(BMP280_NUM_SUPPLIES, data->supplies); - return 0; -} -EXPORT_SYMBOL(bmp280_common_remove); - #ifdef CONFIG_PM static int bmp280_runtime_suspend(struct device *dev) { diff --git a/drivers/iio/pressure/bmp280-i2c.c b/drivers/iio/pressure/bmp280-i2c.c index acd9a3784fb4..3109c8e2cc11 100644 --- a/drivers/iio/pressure/bmp280-i2c.c +++ b/drivers/iio/pressure/bmp280-i2c.c @@ -38,11 +38,6 @@ static int bmp280_i2c_probe(struct i2c_client *client, client->irq); } -static int bmp280_i2c_remove(struct i2c_client *client) -{ - return bmp280_common_remove(&client->dev); -} - static const struct acpi_device_id bmp280_acpi_i2c_match[] = { {"BMP0280", BMP280_CHIP_ID }, {"BMP0180", BMP180_CHIP_ID }, @@ -82,7 +77,6 @@ static struct i2c_driver bmp280_i2c_driver = { .pm = &bmp280_dev_pm_ops, }, .probe = bmp280_i2c_probe, - .remove = bmp280_i2c_remove, .id_table = bmp280_i2c_id, }; module_i2c_driver(bmp280_i2c_driver); diff --git a/drivers/iio/pressure/bmp280-spi.c b/drivers/iio/pressure/bmp280-spi.c index 9d57b7a3b134..625b86878ad8 100644 --- a/drivers/iio/pressure/bmp280-spi.c +++ b/drivers/iio/pressure/bmp280-spi.c @@ -86,11 +86,6 @@ static int bmp280_spi_probe(struct spi_device *spi) spi->irq); } -static int bmp280_spi_remove(struct spi_device *spi) -{ - return bmp280_common_remove(&spi->dev); -} - static const struct of_device_id bmp280_of_spi_match[] = { { .compatible = "bosch,bmp085", }, { .compatible = "bosch,bmp180", }, @@ -118,7 +113,6 @@ static struct spi_driver bmp280_spi_driver = { }, .id_table = bmp280_spi_id, .probe = bmp280_spi_probe, - .remove = bmp280_spi_remove, }; module_spi_driver(bmp280_spi_driver); diff --git a/drivers/iio/pressure/bmp280.h b/drivers/iio/pressure/bmp280.h index eda50ef65706..57ba0e85db91 100644 --- a/drivers/iio/pressure/bmp280.h +++ b/drivers/iio/pressure/bmp280.h @@ -112,7 +112,6 @@ int bmp280_common_probe(struct device *dev, unsigned int chip, const char *name, int irq); -int bmp280_common_remove(struct device *dev); /* PM ops */ extern const struct dev_pm_ops bmp280_dev_pm_ops;