Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp2351819pxv; Sat, 17 Jul 2021 10:57:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy/vMN5Igzvzrvf/whWYxEZFVXJDy/g/eOgx9uI7Gz40+dO/udmf3k/z3ONp/pSs2EcPZvF X-Received: by 2002:a50:ee98:: with SMTP id f24mr23340754edr.72.1626544637647; Sat, 17 Jul 2021 10:57:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626544637; cv=none; d=google.com; s=arc-20160816; b=tBpZ4v2muDoW+jlULnY8aW2m8lFllvFgPJOBfYs0kVBTm2g99FhWYw8eLoEGbuJj9U /mI79C5ZDXdro5MXTrownnWFagxhRRrXq3dQseVP+LNIXVwqyUO0hlvQu+5sOVitMU1E 0OhB0Lwv55fhdZcL+yBdmuLzhBN9b2BdvVkvKwLK/96/PEYYQ/xm0eLiKC7XwyT0qz2Z NJg+FEICtq80QZanp0Yk2HiZMnmWlg+5Bjm5RqKBMEF7GiFVzwhFuq3ib+fGYuoTNqYe 5aPSIWhH1phv/KVcK1EKNkW7/dnLAuHgohlyQLuhjX7C/aeNyHkvGSi4GBSVInYj6Amm 4Egw== 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=vZO4ZbYFy+2PHJjL8p9xRbM3KI8aMzuvOLubxJibaJo=; b=ODXZCE0Q6LJIldYo3TPeWkwKIdoSrEDdK30vh8HRvAxM7FMo2oQfKc1ECw9qn0eZgy PZGr3GiwBv1dhk2KUT3wMFCCyL2Ovn8WZUPXgINAFsD/4p/LMe+g862ALrrot5sRwyGE EIxI7WsK6Ao8sa2HgCRQw3m6X1qOQfU1lquNMMXrHKm08YW/B0sx/w1czMWiyGT3uqbk npLoR0vgnyThLECUWaUXcCTcBXwl6GGt4mwhLdyc0klgcpYSFXzTK32zfuxSe6tFHb+J qamXMSfsnCxyXwMzeq3nS0/Mjps+slprvS7rLvYQKlZUnkdJ/rRRUOSlUg/pnBx+CcF3 nNqQ== 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 p21si15806144ejo.93.2021.07.17.10.56.54; Sat, 17 Jul 2021 10:57:17 -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 S233702AbhGQR6q (ORCPT + 99 others); Sat, 17 Jul 2021 13:58:46 -0400 Received: from mail.kernel.org ([198.145.29.99]:47932 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231253AbhGQR6p (ORCPT ); Sat, 17 Jul 2021 13:58:45 -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 0F8276113D; Sat, 17 Jul 2021 17:55:47 +0000 (UTC) Date: Sat, 17 Jul 2021 18:58:09 +0100 From: Jonathan Cameron To: Alexandru Ardelean Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] iio: accel: da280: convert probe to device-managed functions Message-ID: <20210717185809.181d38ca@jic23-huawei> In-Reply-To: <20210628141709.80534-1-aardelean@deviqon.com> References: <20210628141709.80534-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 Mon, 28 Jun 2021 17:17: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, Thanks, Jonathan > --- > drivers/iio/accel/da280.c | 26 +++++++++----------------- > 1 file changed, 9 insertions(+), 17 deletions(-) > > diff --git a/drivers/iio/accel/da280.c b/drivers/iio/accel/da280.c > index 5edff9ba72da..9633bdae5fd4 100644 > --- a/drivers/iio/accel/da280.c > +++ b/drivers/iio/accel/da280.c > @@ -100,6 +100,11 @@ static enum da280_chipset da280_match_acpi_device(struct device *dev) > return (enum da280_chipset) id->driver_data; > } > > +static void da280_disable(void *client) > +{ > + da280_enable(client, false); > +} > + > static int da280_probe(struct i2c_client *client, > const struct i2c_device_id *id) > { > @@ -118,7 +123,6 @@ static int da280_probe(struct i2c_client *client, > > data = iio_priv(indio_dev); > data->client = client; > - i2c_set_clientdata(client, indio_dev); > > indio_dev->info = &da280_info; > indio_dev->modes = INDIO_DIRECT_MODE; > @@ -142,22 +146,11 @@ static int da280_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"); > - da280_enable(client, false); > - } > - > - return ret; > -} > - > -static int da280_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, da280_disable, client); > + if (ret) > + return ret; > > - return da280_enable(client, false); > + return devm_iio_device_register(&client->dev, indio_dev); > } > > #ifdef CONFIG_PM_SLEEP > @@ -194,7 +187,6 @@ static struct i2c_driver da280_driver = { > .pm = &da280_pm_ops, > }, > .probe = da280_probe, > - .remove = da280_remove, > .id_table = da280_i2c_id, > }; >