Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp2348622pxv; Sat, 17 Jul 2021 10:52:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxPqAYsAJISRKYAfFN3GCzdYz9ddxq1D9rB40/AK5kAe8haDr7uJZ0YcxC6U12g+gwGy3+o X-Received: by 2002:a17:906:fa95:: with SMTP id lt21mr18250643ejb.542.1626544323227; Sat, 17 Jul 2021 10:52:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626544323; cv=none; d=google.com; s=arc-20160816; b=WfiIlTs3uRDiRzXRzL44Bagm2ZGTmqBltWRY1stLmYKBLbo11Mt1aP8fWWiJKltsu7 0NeKJQ0mZLfOVJvxJmcMKG+GwHZBMM6e3N9UMCWl3ebAlOUA2/o7nXKuBGbP8q/O/+Au 8HDdmcF8U9Yu/9DD0DOfQf2Wf/2pWrumz6GV1Hvc0mRHBKFZZH68rCVyybX/EEhqvhqd 0TBDA9KTMKnqd6qZxNUWMd+KwuJx+MJnlrH4C1fybwwNSvEDCPxNWsev27GlYflOvfYe VnMiNrLKKIOFeICg/D+Gwlxs3wOkHhmIrSUGYUHnJwpVUFGvy+IQs6bOLFg7RhylyEqX VsOQ== 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=fEIgcFlNY2ubW6M7fHw5TAf9THUtEfT34+Xq/La1Th8=; b=vE5UGq5NtwJN+4NiImSR9W7BI/1HbpR4DzBkUqXPXQPdnqXlXMoxO7sxjwJ09yUgn+ lGBtENb1ySg4BKXsOilcsWlPsbC+egz2Z26W9uV++pglw5Cxfg0egvugL1RilkfAKC5X LJhEJozLCo46dIy3pKDGTQJ50f0l/SxcDx00TzD57MfoGvQ3jzgFA9r2sX2zokdxdOB8 OiddZE3CtyHj3J3PKcI33oDtjFOhn+f7qKm3Z7skClMnP1wCSU468HHe0cMPd2/th2DF myTBUp9AAZ7g0FJnkKTNSCXygeX3aZ+6SYoxNFXUYJK8eVKFwBkNm1ct4He0lj5kmBG5 fW7Q== 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 o20si15934557edv.34.2021.07.17.10.51.40; Sat, 17 Jul 2021 10:52:03 -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 S233441AbhGQRxj (ORCPT + 99 others); Sat, 17 Jul 2021 13:53:39 -0400 Received: from mail.kernel.org ([198.145.29.99]:43480 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231253AbhGQRxj (ORCPT ); Sat, 17 Jul 2021 13:53:39 -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 6F78761153; Sat, 17 Jul 2021 17:50:41 +0000 (UTC) Date: Sat, 17 Jul 2021 18:53:04 +0100 From: Jonathan Cameron To: Alexandru Ardelean Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] iio: accel: dmard10: convert probe to device-managed functions Message-ID: <20210717185304.6a8b489d@jic23-huawei> In-Reply-To: <20210630121509.653717-1-aardelean@deviqon.com> References: <20210630121509.653717-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 Wed, 30 Jun 2021 15:15:09 +0300 Alexandru Ardelean wrote: > This is another simple conversion to device-managed functions, requiring > the use of devm_iio_device_register() and moving the disabling of the > device on a devm_add_action_or_reset() hook. > > The i2c_set_clientdata() can be removed, as the PM functions can work with > just the device object, to obtain the i2c_client object. > > Signed-off-by: Alexandru Ardelean Applied, > --- > drivers/iio/accel/dmard10.c | 27 ++++++++++----------------- > 1 file changed, 10 insertions(+), 17 deletions(-) > > diff --git a/drivers/iio/accel/dmard10.c b/drivers/iio/accel/dmard10.c > index e84bf8db1e89..f9f173eec202 100644 > --- a/drivers/iio/accel/dmard10.c > +++ b/drivers/iio/accel/dmard10.c > @@ -170,6 +170,11 @@ static const struct iio_info dmard10_info = { > .read_raw = dmard10_read_raw, > }; > > +static void dmard10_shutdown_cleanup(void *client) > +{ > + dmard10_shutdown(client); > +} > + > static int dmard10_probe(struct i2c_client *client, > const struct i2c_device_id *id) > { > @@ -194,7 +199,6 @@ static int dmard10_probe(struct i2c_client *client, > > data = iio_priv(indio_dev); > data->client = client; > - i2c_set_clientdata(client, indio_dev); > > indio_dev->info = &dmard10_info; > indio_dev->name = "dmard10"; > @@ -206,22 +210,12 @@ static int dmard10_probe(struct i2c_client *client, > if (ret < 0) > return ret; > > - ret = iio_device_register(indio_dev); > - if (ret < 0) { > - dev_err(&client->dev, "device_register failed\n"); > - dmard10_shutdown(client); > - } > - > - return ret; > -} > - > -static int dmard10_remove(struct i2c_client *client) > -{ > - struct iio_dev *indio_dev = i2c_get_clientdata(client); > - > - iio_device_unregister(indio_dev); > + ret = devm_add_action_or_reset(&client->dev, dmard10_shutdown_cleanup, > + client); > + if (ret) > + return ret; > > - return dmard10_shutdown(client); > + return devm_iio_device_register(&client->dev, indio_dev); > } > > #ifdef CONFIG_PM_SLEEP > @@ -250,7 +244,6 @@ static struct i2c_driver dmard10_driver = { > .pm = &dmard10_pm_ops, > }, > .probe = dmard10_probe, > - .remove = dmard10_remove, > .id_table = dmard10_i2c_id, > }; >