Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp2865847ybh; Mon, 5 Aug 2019 08:05:18 -0700 (PDT) X-Google-Smtp-Source: APXvYqzYHJqPmsOY8lD4YEJzHgEYhXU9i6HdRwiQgcBLByONsKPIJN/TwV3nikn1jQM6NMliQStY X-Received: by 2002:aa7:8651:: with SMTP id a17mr72838700pfo.138.1565017518334; Mon, 05 Aug 2019 08:05:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565017518; cv=none; d=google.com; s=arc-20160816; b=n3j87w3c11DHgcfjEqq5jBM3Vvoste4yV6DQe4mcOZbuA3gTJXyEHTnxzy9AB5+5X4 uJSJdvx0MoON6Y1Wge4RAs/oPEBcOJBhLsSgaLT9aS7IwcClyLSvdGq51eO8PYklU5ef tcVDhHrIYCtD8eszqFR9RoZ0yA39ken0RFhglyHqmqvqq8yVdjtUdcHVZHzHq5rb1Tkh 1pTxWWFSWvpc+EcubOmus6QO5q5gHKgdM5xXyqdUdF65rRbAwMlwnibmGoxWLVHG8Lis gCCnsZKrLm6CWkuvEZmUd6K8k+rIJiimVHdF9+sJaGS0GaVVM3bdUwidWxZJHu9yL66T /CDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=yn844plprYYsrzGtz0MQWCUXXJaVIjNnBFnrukLLtH8=; b=xAnZodGj7xdLoa9M89XFIN6GpB6OltGjvHjWc8WRJj7y9RizeNIGXRcnlTaxqD+xsU B3C3onym//en94j+jDlcv5jw98vnkuxJ+zO7xSviYf6lR+lvyISPznjpNcqCKpD5bTia /DgCvtF9k13HeREtceCntYNd5V1dDVdLABh72pnUsYl1gloilcZakychz+QNgolVg6PR E7zikIZgBZSx+fsPHOJYahzT8SSwSgAutJh91RgG46CyjkUNhwnHVF/8Gocjfxhgm3zc cHDk4ebc2sZEanm5p5n/fhYty611T4rWxsNebnXzlAka8m3BqNmFnpM/oBygphifXgor BxUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=rcxkhtDZ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id bc8si39012085plb.322.2019.08.05.08.05.01; Mon, 05 Aug 2019 08:05:18 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=rcxkhtDZ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1729317AbfHEPEQ (ORCPT + 99 others); Mon, 5 Aug 2019 11:04:16 -0400 Received: from mail.kernel.org ([198.145.29.99]:36770 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727259AbfHEPEP (ORCPT ); Mon, 5 Aug 2019 11:04:15 -0400 Received: from archlinux (cpc149474-cmbg20-2-0-cust94.5-4.cable.virginm.net [82.4.196.95]) (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 58F73206C1; Mon, 5 Aug 2019 15:04:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565017454; bh=hNtIxM9tns9/3ZnqcjZqPe0wE5g9uKJD8Xeg17jshfM=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=rcxkhtDZ2ihANUQjCoijR78KBqCnz5SmZqivach6iH1R2mSoLsvaZBG49+4lrAcnR CdcdgXYFQOzfNbmsb10q9oO1NU+J/ymhD6J8mDv2ss1qR8yWrgLZxnha6arYb8LxRJ hq6wdzsnIU5gQsH6SR8WdTRdR9U+ryy7N0PRE/CI= Date: Mon, 5 Aug 2019 16:04:10 +0100 From: Jonathan Cameron To: Chuhong Yuan Cc: Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler , Brian Masney , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 1/2] iio: tsl2772: Use device-managed API Message-ID: <20190805160356.2fbd7868@archlinux> In-Reply-To: <20190731030415.8062-1-hslester96@gmail.com> References: <20190731030415.8062-1-hslester96@gmail.com> X-Mailer: Claws Mail 3.17.4 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 31 Jul 2019 11:04:15 +0800 Chuhong Yuan wrote: > Use devm_() APIs to simplify the code. > > Signed-off-by: Chuhong Yuan > --- > Changes in v3: > - Split v2 into two patches. > > drivers/iio/light/tsl2772.c | 36 +++++++++++++++--------------------- > 1 file changed, 15 insertions(+), 21 deletions(-) > > diff --git a/drivers/iio/light/tsl2772.c b/drivers/iio/light/tsl2772.c > index 83cece921843..f1134f183be7 100644 > --- a/drivers/iio/light/tsl2772.c > +++ b/drivers/iio/light/tsl2772.c > @@ -860,6 +860,13 @@ static int tsl2772_chip_off(struct iio_dev *indio_dev) > return tsl2772_write_control_reg(chip, 0x00); > } > > +static void tsl2772_chip_off_action(void *data) > +{ > + struct iio_dev *indio_dev = data; > + > + tsl2772_chip_off(indio_dev); > +} > + > /** > * tsl2772_invoke_change - power cycle the device to implement the user > * parameters > @@ -1807,10 +1814,10 @@ static int tsl2772_probe(struct i2c_client *clientp, > return PTR_ERR(chip->vdd_supply); > } > > - ret = devm_add_action(&clientp->dev, tsl2772_disable_regulators_action, > + ret = devm_add_action_or_reset(&clientp->dev, > + tsl2772_disable_regulators_action, Please fix that alignment in here. Thanks, Jonathan > chip); > if (ret < 0) { > - tsl2772_disable_regulators_action(chip); > dev_err(&clientp->dev, "Failed to setup regulator cleanup action %d\n", > ret); > return ret; > @@ -1877,15 +1884,14 @@ static int tsl2772_probe(struct i2c_client *clientp, > if (ret < 0) > return ret; > > - ret = iio_device_register(indio_dev); > - if (ret) { > - tsl2772_chip_off(indio_dev); > - dev_err(&clientp->dev, > - "%s: iio registration failed\n", __func__); > + ret = devm_add_action_or_reset(&clientp->dev, > + tsl2772_chip_off_action, > + indio_dev); > + > + if (ret < 0) > return ret; > - } > > - return 0; > + return devm_iio_device_register(&clientp->dev, indio_dev); > } > > static int tsl2772_suspend(struct device *dev) > @@ -1922,17 +1928,6 @@ static int tsl2772_resume(struct device *dev) > return tsl2772_chip_on(indio_dev); > } > > -static int tsl2772_remove(struct i2c_client *client) > -{ > - struct iio_dev *indio_dev = i2c_get_clientdata(client); > - > - tsl2772_chip_off(indio_dev); > - > - iio_device_unregister(indio_dev); > - > - return 0; > -} > - > static const struct i2c_device_id tsl2772_idtable[] = { > { "tsl2571", tsl2571 }, > { "tsl2671", tsl2671 }, > @@ -1979,7 +1974,6 @@ static struct i2c_driver tsl2772_driver = { > }, > .id_table = tsl2772_idtable, > .probe = tsl2772_probe, > - .remove = tsl2772_remove, > }; > > module_i2c_driver(tsl2772_driver);