Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp2189204pxb; Sat, 2 Oct 2021 09:09:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyEKUd/5cJNH+S8OqsR6RFa/8aSu2LYXKG/7X3EYvlY/Qv3cZsZscX5rEPEhV3ja2GvHl/L X-Received: by 2002:a50:8145:: with SMTP id 63mr4886499edc.190.1633190942293; Sat, 02 Oct 2021 09:09:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633190942; cv=none; d=google.com; s=arc-20160816; b=W7M1UjNoaKQF11ndIs92k0MkVpRZw4AZZnaz9hcH/3hbXsDReR5X7t0La8DRF/Ck08 oYAk9t6jixlTvtCtFZq5a0ft4bCVwklX+mDt00hhxmELBbkrfiSV2pLPNVivPEPCeIC8 o7k4/kUv/jyYHLMPifShajigZbmDXDVDtxoC2WxXelKNczI/d1uD5yhpke6Wv91jAdmD G6Mbies1eocCcjkNJJBpQE8IEpSpPVokAsd8Kh/HPykzgKPQQH7TflOSLmu2zHFOAmdd McjVPMqePYlLC7J6PMVZwHIqNiU4lA+bWAy1/Jo/r+zCAGJrQZQnbPJ/TirNVgRFysVg S9zw== 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=CBzF73a/MnpTZdxNGA9BiwpZDh0cDZ1Td4cQJG0Y908=; b=psPHJgqiOw+U1jLYSD+7qXvJuxtja8lmR+q5S+w1G3q+PWo4bpBFfyTP2pa8dfwVcY KhBIY8GcazT8ibuTX300mHUBldafZlI+InHeY0OzgFTCFrW7w2VS+QIszXTxOKOEdHrj AbDL3TqSj3APk8782jlHC0L62y5hDuiYG8keGSs1uFfzTMOeQ0ilBfDqXvrR1vbF4Uhn mn5lElcki05usFjzqr4uBk19MUd+yfXndl0Cann+7toUrtYEUb9OTas7j87xCn5/An3G a1QfvgGxBPZZWZRr5wJjpbsl29SU1+RAIYY6pJbQuk5fxk7jW7oMf+szt3iiQxj74CiL VFqw== 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 e12si10441026ejk.703.2021.10.02.09.08.37; Sat, 02 Oct 2021 09:09:02 -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 S233456AbhJBQDw (ORCPT + 99 others); Sat, 2 Oct 2021 12:03:52 -0400 Received: from mail.kernel.org ([198.145.29.99]:33618 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232575AbhJBQDv (ORCPT ); Sat, 2 Oct 2021 12:03:51 -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 C0C5861A3A; Sat, 2 Oct 2021 16:02:04 +0000 (UTC) Date: Sat, 2 Oct 2021 17:06:01 +0100 From: Jonathan Cameron To: Alexandre Belloni Cc: Alexandru Ardelean , linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org, Maxime Ripard Subject: Re: [PATCH] iio: adc: nau7802: convert probe to full device-managed Message-ID: <20211002170601.2a37a8a0@jic23-huawei> In-Reply-To: References: <20210926154932.3287590-1-aardelean@deviqon.com> <20210930171023.2bf5a414@jic23-huawei> X-Mailer: Claws Mail 4.0.0 (GTK+ 3.24.30; 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 Fri, 1 Oct 2021 00:02:34 +0200 Alexandre Belloni wrote: > On 30/09/2021 17:10:23+0100, Jonathan Cameron wrote: > > On Sun, 26 Sep 2021 18:49:32 +0300 > > Alexandru Ardelean wrote: > > > > > This is a trivial conversion to device-managed functions. > > > The mutex_destroy() calls are redundant, as the data will be free'd anyway. > > > > > > And the IRQ and IIO register functions both have device-managed > > > equivalents. > > > > > > Signed-off-by: Alexandru Ardelean > > > > +CC Maxime and Alexandre. > > > > Looks simple enough to me that I won't wait on their replies to queue it up. > > Obviously feedback welcome though! > > > > Applied to the togreg branch of iio.git and pushed out as testing for 0-day > > to see if it can find stuff we missed. > > > > This seems good to me too > Reviewed-by: Alexandre Belloni Great. Added tag. Thanks, Jonathan > > > Thanks, > > > > Jonathan > > > > > > > --- > > > drivers/iio/adc/nau7802.c | 50 +++++++-------------------------------- > > > 1 file changed, 9 insertions(+), 41 deletions(-) > > > > > > diff --git a/drivers/iio/adc/nau7802.c b/drivers/iio/adc/nau7802.c > > > index bb70b51d25b1..976c235f3079 100644 > > > --- a/drivers/iio/adc/nau7802.c > > > +++ b/drivers/iio/adc/nau7802.c > > > @@ -428,8 +428,6 @@ static int nau7802_probe(struct i2c_client *client, > > > > > > st = iio_priv(indio_dev); > > > > > > - i2c_set_clientdata(client, indio_dev); > > > - > > > indio_dev->name = dev_name(&client->dev); > > > indio_dev->modes = INDIO_DIRECT_MODE; > > > indio_dev->info = &nau7802_info; > > > @@ -495,13 +493,13 @@ static int nau7802_probe(struct i2c_client *client, > > > * will enable them back when we will need them.. > > > */ > > > if (client->irq) { > > > - ret = request_threaded_irq(client->irq, > > > - NULL, > > > - nau7802_eoc_trigger, > > > - IRQF_TRIGGER_HIGH | IRQF_ONESHOT | > > > - IRQF_NO_AUTOEN, > > > - client->dev.driver->name, > > > - indio_dev); > > > + ret = devm_request_threaded_irq(&client->dev, client->irq, > > > + NULL, > > > + nau7802_eoc_trigger, > > > + IRQF_TRIGGER_HIGH | IRQF_ONESHOT | > > > + IRQF_NO_AUTOEN, > > > + client->dev.driver->name, > > > + indio_dev); > > > if (ret) { > > > /* > > > * What may happen here is that our IRQ controller is > > > @@ -526,7 +524,7 @@ static int nau7802_probe(struct i2c_client *client, > > > ret = i2c_smbus_write_byte_data(st->client, NAU7802_REG_CTRL2, > > > NAU7802_CTRL2_CRS(st->sample_rate)); > > > if (ret) > > > - goto error_free_irq; > > > + return ret; > > > } > > > > > > /* Setup the ADC channels available on the board */ > > > @@ -536,36 +534,7 @@ static int nau7802_probe(struct i2c_client *client, > > > mutex_init(&st->lock); > > > mutex_init(&st->data_lock); > > > > > > - ret = iio_device_register(indio_dev); > > > - if (ret < 0) { > > > - dev_err(&client->dev, "Couldn't register the device.\n"); > > > - goto error_device_register; > > > - } > > > - > > > - return 0; > > > - > > > -error_device_register: > > > - mutex_destroy(&st->lock); > > > - mutex_destroy(&st->data_lock); > > > -error_free_irq: > > > - if (client->irq) > > > - free_irq(client->irq, indio_dev); > > > - > > > - return ret; > > > -} > > > - > > > -static int nau7802_remove(struct i2c_client *client) > > > -{ > > > - struct iio_dev *indio_dev = i2c_get_clientdata(client); > > > - struct nau7802_state *st = iio_priv(indio_dev); > > > - > > > - iio_device_unregister(indio_dev); > > > - mutex_destroy(&st->lock); > > > - mutex_destroy(&st->data_lock); > > > - if (client->irq) > > > - free_irq(client->irq, indio_dev); > > > - > > > - return 0; > > > + return devm_iio_device_register(&client->dev, indio_dev); > > > } > > > > > > static const struct i2c_device_id nau7802_i2c_id[] = { > > > @@ -582,7 +551,6 @@ MODULE_DEVICE_TABLE(of, nau7802_dt_ids); > > > > > > static struct i2c_driver nau7802_driver = { > > > .probe = nau7802_probe, > > > - .remove = nau7802_remove, > > > .id_table = nau7802_i2c_id, > > > .driver = { > > > .name = "nau7802", > > >