Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp2363197pxv; Sat, 17 Jul 2021 11:12:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyn9eJFmDjuLgR1sBb9dnP5VRM06Se0whpjBYppk4BP7HuVYhXCte6Izw8nMoq06EFW33Ob X-Received: by 2002:a05:6402:3442:: with SMTP id l2mr24121509edc.126.1626545529951; Sat, 17 Jul 2021 11:12:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626545529; cv=none; d=google.com; s=arc-20160816; b=AYye4Sxcfm5EryCc8Q+Z1WANGxWdt1Ho3Jlv6bfNnGJgQiORrufhuBjfT5uiIYxCAD CjdoiaD8TRJqVd3/0QLW5aQ4msA5rJ/Ae3i/iGxO+UyOJ48E6z2nLwGNkYaDhK+iyIbp oWHrlT/MHVgk+CANioRImUpnBAvqoDB5HMNwAyuaV060EoFoIRMaN5eGaUtM19DA/7IP nMnypH7TBSyN2ps2UpQbbv2XAWa2jgQ+6JteOjfF001p5siaahS00yJWdVN7n+Q45Byd kOpv9K8+LD9xI5Bm97GhmTdFxgxXrs98d9tVSgh8a5THSHdLFav563HOZ9Io1YTEnsHQ lmXg== 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=E/HRLrsY2oyuqIC926btpYOl6nqfWd54yrssa9xMqHY=; b=G37n913B70yzJiKsmI4MmYY3qBv0/ubDF9SpPj6OXpO4SSVlt/zmSe3zVwRNMOOuBT yECsgpYCFgL5rdreMP61EO144yRHLK2AdkQNNdplONhO9nTsQo21/EuqycCg/oxcnB37 lbSZ1AZwLxEU8bk581hFd3T5hhk2yUwpoJKrcY0CAXTig+FaqnVle1V2S8iC4xf9Xq7M 3DJg8VolFRvM/t8OmANvEXYe38O4hdWM33Nl5aZClgqhRncAPJ9bNF+2kyBvPc5YVhRm 2XVb/CRk3hHJA+Rm4caT/VMCEvv5hH2uwn7aorj6BkG0uL6PbpGPBd54aGV8zr3Y1AlX Q7Hw== 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 f4si16129153ejl.218.2021.07.17.11.11.45; Sat, 17 Jul 2021 11:12:09 -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 S234272AbhGQSNq (ORCPT + 99 others); Sat, 17 Jul 2021 14:13:46 -0400 Received: from mail.kernel.org ([198.145.29.99]:58516 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233280AbhGQSNq (ORCPT ); Sat, 17 Jul 2021 14:13:46 -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 1832B6113D; Sat, 17 Jul 2021 18:10:47 +0000 (UTC) Date: Sat, 17 Jul 2021 19:13:11 +0100 From: Jonathan Cameron To: Alexandru Ardelean Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/2] iio: accel: bma220: convert probe to device-managed functions Message-ID: <20210717191311.6e408054@jic23-huawei> In-Reply-To: <20210704180817.3160e83f@jic23-huawei> References: <20210625140137.362282-1-aardelean@deviqon.com> <20210704180817.3160e83f@jic23-huawei> 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 Sun, 4 Jul 2021 18:08:17 +0100 Jonathan Cameron wrote: > On Fri, 25 Jun 2021 17:01:36 +0300 > Alexandru Ardelean wrote: > > > This change converts the driver to use devm_iio_triggered_buffer_setup() > > and devm_iio_device_register() for initializing and registering the IIO > > device. > > > > The bma220_deinit() is converted into a callback for a > > devm_add_action_or_reset() hook, so that the device is put in stand-by when > > the driver gets uninitialized. > > The return value of the bma220_deinit() function isn't used as it does not > > add any value. On the error path of the probe function, this can just > > override the actual error with -EBUSY, or can even return 0 (no error), on > > the error path. > > > > Signed-off-by: Alexandru Ardelean > Hmm. That return on the error path issue in probe is almost worth a backported > fix, but meh, it's been there for ages so unless anyone shouts, let us assume > it never bit anyone. > > Otherwise, this looks fine. I'm not going to comment on all the similar > devm patches you have on list unless I have something I want changed. > I'll pick them all up in a week or two once we are well into the new cycle. > > thanks, > > Jonathan Both applied to the togreg branch of iio.git and pushed out as testing for 0-day to poke at them and see if we missed anything. Thanks, Jonathan > > > --- > > drivers/iio/accel/bma220_spi.c | 44 +++++++++------------------------- > > 1 file changed, 11 insertions(+), 33 deletions(-) > > > > diff --git a/drivers/iio/accel/bma220_spi.c b/drivers/iio/accel/bma220_spi.c > > index 0622c7936499..0095931a11f8 100644 > > --- a/drivers/iio/accel/bma220_spi.c > > +++ b/drivers/iio/accel/bma220_spi.c > > @@ -218,20 +218,14 @@ static int bma220_init(struct spi_device *spi) > > return 0; > > } > > > > -static int bma220_deinit(struct spi_device *spi) > > +static void bma220_deinit(void *spi) > > { > > int ret; > > > > /* Make sure the chip is powered off */ > > ret = bma220_read_reg(spi, BMA220_REG_SUSPEND); > > if (ret == BMA220_SUSPEND_SLEEP) > > - ret = bma220_read_reg(spi, BMA220_REG_SUSPEND); > > - if (ret < 0) > > - return ret; > > - if (ret == BMA220_SUSPEND_SLEEP) > > - return -EBUSY; > > - > > - return 0; > > + bma220_read_reg(spi, BMA220_REG_SUSPEND); > > } > > > > static int bma220_probe(struct spi_device *spi) > > @@ -262,34 +256,19 @@ static int bma220_probe(struct spi_device *spi) > > if (ret) > > return ret; > > > > - ret = iio_triggered_buffer_setup(indio_dev, iio_pollfunc_store_time, > > - bma220_trigger_handler, NULL); > > - if (ret < 0) { > > - dev_err(&spi->dev, "iio triggered buffer setup failed\n"); > > - goto err_suspend; > > - } > > + ret = devm_add_action_or_reset(&spi->dev, bma220_deinit, spi); > > + if (ret) > > + return ret; > > > > - ret = iio_device_register(indio_dev); > > + ret = devm_iio_triggered_buffer_setup(&spi->dev, indio_dev, > > + iio_pollfunc_store_time, > > + bma220_trigger_handler, NULL); > > if (ret < 0) { > > - dev_err(&spi->dev, "iio_device_register failed\n"); > > - iio_triggered_buffer_cleanup(indio_dev); > > - goto err_suspend; > > + dev_err(&spi->dev, "iio triggered buffer setup failed\n"); > > + return ret; > > } > > > > - return 0; > > - > > -err_suspend: > > - return bma220_deinit(spi); > > -} > > - > > -static int bma220_remove(struct spi_device *spi) > > -{ > > - struct iio_dev *indio_dev = spi_get_drvdata(spi); > > - > > - iio_device_unregister(indio_dev); > > - iio_triggered_buffer_cleanup(indio_dev); > > - > > - return bma220_deinit(spi); > > + return devm_iio_device_register(&spi->dev, indio_dev); > > } > > > > static __maybe_unused int bma220_suspend(struct device *dev) > > @@ -326,7 +305,6 @@ static struct spi_driver bma220_driver = { > > .acpi_match_table = bma220_acpi_id, > > }, > > .probe = bma220_probe, > > - .remove = bma220_remove, > > .id_table = bma220_spi_id, > > }; > > module_spi_driver(bma220_driver); >