Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp2877399ybi; Sun, 28 Jul 2019 20:04:26 -0700 (PDT) X-Google-Smtp-Source: APXvYqzS0EQUwJmf8Ct2LwqJGIoN2FRRrL/4YXlufGVl5B3j9q/sUllVrNLeabqcAwq9LuAV3qNI X-Received: by 2002:a17:902:b20d:: with SMTP id t13mr102833638plr.229.1564369466421; Sun, 28 Jul 2019 20:04:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564369466; cv=none; d=google.com; s=arc-20160816; b=Jn+DF7QuG3osN1ASfWlgtPTNqRDjdOSLojAw9TLOzuai0FDjOB5+fkiqy1vDoimqin oLxEu8LnJy/MpeM53P5e8OWoX8o2YFbLiOHA+/WDVNMvT+kt8J1yPPu91XXBVusMA/dZ OXa6Pn1GFTJLp/rawFnL73TN5ZnE2+y0sTCfT6lIziFJTK3vxjLhi11rIYG3ALQeTIum RrTsiVNdZZfXqdk4KW8dcw4m7myc2sKxGBD1VhJqrILCQwAljI6FG1E9SIzB1mpUk4kI mGf2XwP5xalnzH8rFFvgfVkemglGy2YqJBoNTf9mJbUI/R/YqJIVbo2iwK574WFVkSry EzUw== 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:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=fXVvE8jAIC1NNZIfikHDR/1QE5dXSm7MFMLRP9/brXQ=; b=cqRAVrJk87PDNqvwO/9iunTbWLeNUNotGu9FDKwRxydQcdXrNURWSzHXwzxQSDTCa4 Ek7Mz9ecW2i4sz3IvA5+MXETTcXSvhDq59UccEbVMhGSqO1rpD46LFno+ZhZyBwB4Tox vr6R2Ey73Bw3mO8CXR+fQaFfU7+8i4kL53tSWKKHap2L4rL5p4SNLpX7QkPEqG7W4RDU n94oZCa01DzXVA4w0rTsKrMLd086d3vN+mVMj4ThcHx+UBMlIChj4O3SimfRU7bUbGDB jl921BYC9+QmaYh3XRxI+o9OUAV3vSMWEXvLPt+wdbezPLQ+39H3OtOKKHVo4eGPvUcO E+EQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=P1CWbXcB; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w9si22855915pjv.67.2019.07.28.20.04.10; Sun, 28 Jul 2019 20:04:26 -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=@gmail.com header.s=20161025 header.b=P1CWbXcB; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726617AbfG2DDQ (ORCPT + 99 others); Sun, 28 Jul 2019 23:03:16 -0400 Received: from mail-ed1-f67.google.com ([209.85.208.67]:40247 "EHLO mail-ed1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725681AbfG2DDN (ORCPT ); Sun, 28 Jul 2019 23:03:13 -0400 Received: by mail-ed1-f67.google.com with SMTP id k8so57934494eds.7; Sun, 28 Jul 2019 20:03:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=fXVvE8jAIC1NNZIfikHDR/1QE5dXSm7MFMLRP9/brXQ=; b=P1CWbXcBwor5hFfN6eM0+AZeIpRuigARlpWFs0jelf9IA36v5ICoIlMCwgXaWmDvR3 /QiTkrYUa1MEMIP8Q0hsBw9fZDe5/zr1BkIhoMXo+tLCEBSgTPqlT9jRmInlLb1z4RZ/ slc8QwWFz4/T7l4QyY9jTsP19d/g7cRQ+Eh9aT8PsEEQYIKyXAEZKJ8KBlSCUOdkfryn FpxQ+HkX/qhvxC67cK9Z6n8LC7ebtmVP9ZxHcra2IziDVfBLEit6D+hPX9KmGOA7VeCQ rxKfQQIAyhmHk8S1iR7dSCNhUkCemuGkg0f3njn5YR0+7yUTPZ4nVRRsxNCZNjt6v445 FDaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=fXVvE8jAIC1NNZIfikHDR/1QE5dXSm7MFMLRP9/brXQ=; b=HK26qDV1Vjikk3M8Cjokwf5tLFwyQJt9EFhWAcv5bXjJ+aW96fZXpdZyrCke1tN0Gu wNx3gBWiT6NL6tp5TzwdSTQPFGdOXpP7gMZbzEO8EfjyJQTZO5bwikJL/MBmrpCRti43 obK6p6bTDUiEds0IeKj3AahQhftjiw/+oT80r8f9c1nTH4gXV1e77tmtJzRW6lPKLg3y nErSYQBOL2oLDpNis65h5CCQY7rQoKe+4EUTPQYYb+fKFLYRfeHi1bxxh9FP/9mfUYaT efQAGiQWCITpFG3foiouHU2lj0Nmrfd2i4Ss8xs97GbyA+hounfP1V1rqiRlVDLcnoy6 n5dw== X-Gm-Message-State: APjAAAXCTCeOsSLzd9xcqgj+spVH73R0emIBemHgudT28XcSBkS7K81s ZzwyD+V0S+cEMLpVzEv9LfponBdnU9ByguMuGfE= X-Received: by 2002:a17:906:8317:: with SMTP id j23mr69799975ejx.51.1564369391203; Sun, 28 Jul 2019 20:03:11 -0700 (PDT) MIME-Version: 1.0 References: <20190726123058.22915-1-hslester96@gmail.com> <20190727125749.63297c28@archlinux> <20190728083141.GA14194@onstation.org> In-Reply-To: <20190728083141.GA14194@onstation.org> From: Chuhong Yuan Date: Mon, 29 Jul 2019 11:03:00 +0800 Message-ID: Subject: Re: [PATCH] iio: tsl2772: Use device-managed API To: Brian Masney Cc: Jonathan Cameron , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Brian Masney =E4=BA=8E2019=E5=B9=B47=E6=9C=8828=E6= =97=A5=E5=91=A8=E6=97=A5 =E4=B8=8B=E5=8D=884:31=E5=86=99=E9=81=93=EF=BC=9A > > On Sat, Jul 27, 2019 at 12:57:49PM +0100, Jonathan Cameron wrote: > > On Fri, 26 Jul 2019 20:30:58 +0800 > > Chuhong Yuan wrote: > > > > > Use devm_iio_device_register to simplify > > > the code. > > > > > > Signed-off-by: Chuhong Yuan > > > > Please try to pick up on likely reviewers in your cc list. In this cas= e > > Brian did a lot of work cleaning these drivers up so I've added him. > > Not everyone keeps up with the linux-iio list for some reason ;) > > > > Immediate thought was that you had broken the ordering but turns out > > it is already buggy. > > > > As things stand, we remove the userspace interfaces (iio_device_unregis= ter) > > after turning off the power. This is obviously a bad idea and also > > form a purely "obviously correct" stand point, we aren't doing the reve= rse > > of probe. > > > > So, I 'think' the right option is to reorder remove so that the power l= eft > > on until after the iio_device_unregister call. At that point, we can't > > use devm_iio_device_register as we'll have the same incorrect ordering > > we currently have. > > > > Brian, you looked at this driver most recently. Thoughts? > > devm_add_action() could be used in the probe function to schedule the cal= l > to tsl2772_chip_off(). That would eliminate the need for > tsl2772_remove(). See tsl2772_disable_regulators_action() for an example = in > that driver. > I find that we can use devm_add_action_or_reset() for tsl2772_disable_regulators_action() to eliminate the fault handling code. I am not sure whether devm_add_action() can be used for tsl2772_chip_off() because it returns an integer, not void. And the return value is used in several functions. > Chuhong: Another potential cleanup to shrink the size of this driver is > to move it over to the regulator_bulk_() API. I didn't realize that API > existed at the time I introduced the regulator support. If you're > interested in taking on that cleanup as well, I can test those changes > for you if you don't have the hardware. > > Brian > Does that mean merging vdd_supply and vddio_supply to an array of regulator_bulk_data and utilize regulator_bulk_() API to operate them together? If so, I can do that cleanup in next version. I have an additional question that I find regulator_disable() is used in th= e end of many .remove functions of drivers, which hinders us to use devm functions. One example is drivers/iio/light/gp2ap020a00f.c. Is there any solution to this problem? Regards, Chuhong > > > > --- > > > drivers/iio/light/tsl2772.c | 4 +--- > > > 1 file changed, 1 insertion(+), 3 deletions(-) > > > > > > diff --git a/drivers/iio/light/tsl2772.c b/drivers/iio/light/tsl2772.= c > > > index 83cece921843..aa5891d105e8 100644 > > > --- a/drivers/iio/light/tsl2772.c > > > +++ b/drivers/iio/light/tsl2772.c > > > @@ -1877,7 +1877,7 @@ static int tsl2772_probe(struct i2c_client *cli= entp, > > > if (ret < 0) > > > return ret; > > > > > > - ret =3D iio_device_register(indio_dev); > > > + ret =3D devm_iio_device_register(&clientp->dev, indio_dev); > > > if (ret) { > > > tsl2772_chip_off(indio_dev); > > > dev_err(&clientp->dev, > > > @@ -1928,8 +1928,6 @@ static int tsl2772_remove(struct i2c_client *cl= ient) > > > > > > tsl2772_chip_off(indio_dev); > > > > > > - iio_device_unregister(indio_dev); > > > - > > > return 0; > > > } > > >