Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp2996562pxv; Sun, 18 Jul 2021 07:35:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyC4OWx+motF06X5Wu97fZELtLhOrFSNMZcmEDuB9wn1YNlBsASpsc+SQucoPC1zJuZLtn0 X-Received: by 2002:a05:6402:5212:: with SMTP id s18mr28969636edd.370.1626618938069; Sun, 18 Jul 2021 07:35:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626618938; cv=none; d=google.com; s=arc-20160816; b=M6UTblqBqfmrPo4ocxt+9+OattClUz+s9NEd7YRNbRCf6diNCuggrpzw2k0gR6pioI AROP7bQQnOvyaQK2exaNq5+ISexo4+KNAh+no6G1MhRA6mmUp4frqvt1bZ6S+TFlAxK3 Rvz04w7ta/ev1WSVgQ4UW6ddV6TsqBhlc20IwqJCp9OQ990GNzi6WGd+ftRySJ0CLH4C 4Bg5WPEnJm1ie9B0jJYrR1t8+TvzLMJRwNmXb3DR475nTkf9E2LpOWNbhdy0s/WWl43j TOCtYHPa+6WRp64n012LvhwKiK53DYixs5AfcvcLQ1QaFdB6C9une23AWouS9aFAsaoF Pdrw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date; bh=ocXbgwc2oVTVsjQkuHoX4V+SfLC7wGkVDyPrjvpB3Uc=; b=FdD6Ddzn8tF8sQBqlDc2nxyMzV6ef/i8jIFZNuL8hAMJ8fqJfoJMtGLqkRxLcj9OBh zvtxV3/hwrhJFLlS5XbNl1ASMv4C7uc6WXrS7QQ/uVtW3jZKIVT0NLvCgSlqLEPDX4/z b34aV+3bue7dJpOZUI9F0IpASG1je1vckHgbh8Vt9yBZd1nPYYpdeOhWYBmQhqzWv70w M818QjA+K5xUJA/asDuLeFt+uJwyn+y+1ywZD9+Tp9WTemhuPWH8OyCstGZI91O/jHGm fS8EbfbP3gLL/YswG15BLCxm3/j9E5W2JiGI63rMBFhoIxHhU0M5W819aOMsnqEqvgHl BXBQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y14si5967698eda.265.2021.07.18.07.35.14; Sun, 18 Jul 2021 07:35:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233919AbhGROfX (ORCPT + 99 others); Sun, 18 Jul 2021 10:35:23 -0400 Received: from mail.kernel.org ([198.145.29.99]:46836 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232973AbhGROfU (ORCPT ); Sun, 18 Jul 2021 10:35:20 -0400 Received: from jic23-huawei (cpc108967-cmbg20-2-0-cust86.5-4.cable.virginm.net [81.101.6.87]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 5927A611AB; Sun, 18 Jul 2021 14:32:21 +0000 (UTC) Date: Sun, 18 Jul 2021 15:34:45 +0100 From: Jonathan Cameron To: Alexandru Ardelean Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] iio: accel: adxl345: convert probe to device-managed functions Message-ID: <20210718153445.5e4570ba@jic23-huawei> In-Reply-To: <20210624080441.8710-1-aardelean@deviqon.com> References: <20210624080441.8710-1-aardelean@deviqon.com> X-Mailer: Claws Mail 3.18.0 (GTK+ 2.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 24 Jun 2021 11:04:40 +0300 Alexandru Ardelean wrote: > This driver has two parts, one for i2c and one for spi, since the chip can > operate with both wire protocols. > > The core file has a common adxl345_core_remove() function which puts the > chip into a powerdown state. This can be implemented with a > devm_add_action_or_reset() hook. > > Doing that means we can register the IIO device with > devm_iio_device_register() and get rid of the adxl345_core_remove() > function. > > The dev_set_drvdata() call can be removed as there is no other user of this > private data anymore. > > Signed-off-by: Alexandru Ardelean Applied to the togreg branch of iio.git and pushed out as testing for all the normal reasons. Thanks, Jonathan > --- > drivers/iio/accel/adxl345.h | 1 - > drivers/iio/accel/adxl345_core.c | 29 +++++++++-------------------- > drivers/iio/accel/adxl345_i2c.c | 6 ------ > drivers/iio/accel/adxl345_spi.c | 6 ------ > 4 files changed, 9 insertions(+), 33 deletions(-) > > diff --git a/drivers/iio/accel/adxl345.h b/drivers/iio/accel/adxl345.h > index 384497776b67..af0fdd02c4f2 100644 > --- a/drivers/iio/accel/adxl345.h > +++ b/drivers/iio/accel/adxl345.h > @@ -15,6 +15,5 @@ enum adxl345_device_type { > > int adxl345_core_probe(struct device *dev, struct regmap *regmap, > enum adxl345_device_type type, const char *name); > -int adxl345_core_remove(struct device *dev); > > #endif /* _ADXL345_H_ */ > diff --git a/drivers/iio/accel/adxl345_core.c b/drivers/iio/accel/adxl345_core.c > index 312866530065..4b275051ef61 100644 > --- a/drivers/iio/accel/adxl345_core.c > +++ b/drivers/iio/accel/adxl345_core.c > @@ -208,6 +208,11 @@ static const struct iio_info adxl345_info = { > .write_raw_get_fmt = adxl345_write_raw_get_fmt, > }; > > +static void adxl345_powerdown(void *regmap) > +{ > + regmap_write(regmap, ADXL345_REG_POWER_CTL, ADXL345_POWER_CTL_STANDBY); > +} > + > int adxl345_core_probe(struct device *dev, struct regmap *regmap, > enum adxl345_device_type type, const char *name) > { > @@ -233,7 +238,6 @@ int adxl345_core_probe(struct device *dev, struct regmap *regmap, > return -ENOMEM; > > data = iio_priv(indio_dev); > - dev_set_drvdata(dev, indio_dev); > data->regmap = regmap; > data->type = type; > /* Enable full-resolution mode */ > @@ -260,29 +264,14 @@ int adxl345_core_probe(struct device *dev, struct regmap *regmap, > return ret; > } > > - ret = iio_device_register(indio_dev); > - if (ret < 0) { > - dev_err(dev, "iio_device_register failed: %d\n", ret); > - regmap_write(data->regmap, ADXL345_REG_POWER_CTL, > - ADXL345_POWER_CTL_STANDBY); > - } > + ret = devm_add_action_or_reset(dev, adxl345_powerdown, data->regmap); > + if (ret < 0) > + return ret; > > - return ret; > + return devm_iio_device_register(dev, indio_dev); > } > EXPORT_SYMBOL_GPL(adxl345_core_probe); > > -int adxl345_core_remove(struct device *dev) > -{ > - struct iio_dev *indio_dev = dev_get_drvdata(dev); > - struct adxl345_data *data = iio_priv(indio_dev); > - > - iio_device_unregister(indio_dev); > - > - return regmap_write(data->regmap, ADXL345_REG_POWER_CTL, > - ADXL345_POWER_CTL_STANDBY); > -} > -EXPORT_SYMBOL_GPL(adxl345_core_remove); > - > MODULE_AUTHOR("Eva Rachel Retuya "); > MODULE_DESCRIPTION("ADXL345 3-Axis Digital Accelerometer core driver"); > MODULE_LICENSE("GPL v2"); > diff --git a/drivers/iio/accel/adxl345_i2c.c b/drivers/iio/accel/adxl345_i2c.c > index 1561364ae296..a431cba216e6 100644 > --- a/drivers/iio/accel/adxl345_i2c.c > +++ b/drivers/iio/accel/adxl345_i2c.c > @@ -38,11 +38,6 @@ static int adxl345_i2c_probe(struct i2c_client *client, > id->name); > } > > -static int adxl345_i2c_remove(struct i2c_client *client) > -{ > - return adxl345_core_remove(&client->dev); > -} > - > static const struct i2c_device_id adxl345_i2c_id[] = { > { "adxl345", ADXL345 }, > { "adxl375", ADXL375 }, > @@ -65,7 +60,6 @@ static struct i2c_driver adxl345_i2c_driver = { > .of_match_table = adxl345_of_match, > }, > .probe = adxl345_i2c_probe, > - .remove = adxl345_i2c_remove, > .id_table = adxl345_i2c_id, > }; > > diff --git a/drivers/iio/accel/adxl345_spi.c b/drivers/iio/accel/adxl345_spi.c > index da4591c7ef23..ea559ac2e87d 100644 > --- a/drivers/iio/accel/adxl345_spi.c > +++ b/drivers/iio/accel/adxl345_spi.c > @@ -42,11 +42,6 @@ static int adxl345_spi_probe(struct spi_device *spi) > return adxl345_core_probe(&spi->dev, regmap, id->driver_data, id->name); > } > > -static int adxl345_spi_remove(struct spi_device *spi) > -{ > - return adxl345_core_remove(&spi->dev); > -} > - > static const struct spi_device_id adxl345_spi_id[] = { > { "adxl345", ADXL345 }, > { "adxl375", ADXL375 }, > @@ -69,7 +64,6 @@ static struct spi_driver adxl345_spi_driver = { > .of_match_table = adxl345_of_match, > }, > .probe = adxl345_spi_probe, > - .remove = adxl345_spi_remove, > .id_table = adxl345_spi_id, > }; >