Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3666166ybi; Mon, 29 Jul 2019 10:23:36 -0700 (PDT) X-Google-Smtp-Source: APXvYqyPYfe4VLeTaEzWQle2NMoQNi56syjbjDSwNiOJb4XpCFr2R9EvlJoo/E/kR+xah5VHLxOe X-Received: by 2002:a62:187:: with SMTP id 129mr38034650pfb.128.1564421016538; Mon, 29 Jul 2019 10:23:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564421016; cv=none; d=google.com; s=arc-20160816; b=Cn9gV/WBVMhYjxPC8tWg48GzplpRSVEhuC7vaNdEjZ/A5s05zwfMywNdwmGLopQB+c PEFBuqRMujOEr1g5efx59TijFe81p7Ap3aDB6ZRkum1jF+g4WbDGfaNggq8YkEh+STK1 qD3NfbjmDfz+T6BMawNALFosO6ww9NVSmUq5k2cJBqHnjkySs461QFm5inej9V+OjrBx hMEtZiC2/QkA0DGWD+3CnzPgUhnWkmIprLr1QHZKumke5lD5BcUVEeB27Yi4eO16uyln XhYjRG1wyCJd6B+5xiWiTbZJpFs7kJeeo6j66pOYvZyNTYUe2wHqDfKRWNj0Z6QkXtD4 nlZg== 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=tt8+c7Qc6AbuRWIfhDVP2GsR6IhoFI9cbqdXPL+msrE=; b=jwQzbLAsuJm7srISZbElPZKOr2faMfP2cIoioFP7G23kkeAnnTyIQU8dXmJif5DSWf 45XqBVjkT6/gVBvGyBjG1ukEpFaIbn22Qck3IqHX576HoDAHRM6/N6wxOGYi9Dw6r9rZ Y9xjlX3j4baVFNFSDUr0lKXpUPj5SMJFjAAwnmdHLyNNdh7b7wwzVgxzpdK4GulI/RoU O2yajzwiWoSic25uxLZeK3tactPLJySLSEaCPr0TZcnceVFBM+AjG4TDOjTAtQCej8hU H/oir74RlAVUixP9GlvnjeKxhpC/TmuIYV4Gttc4CHVI3fwyNAUIZwM9wwEuKGM01/ao YXhg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=iN1oOiDK; 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 e23si27517828pgn.595.2019.07.29.10.23.19; Mon, 29 Jul 2019 10:23:36 -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=iN1oOiDK; 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 S1728438AbfG2NCV (ORCPT + 99 others); Mon, 29 Jul 2019 09:02:21 -0400 Received: from mail-ed1-f66.google.com ([209.85.208.66]:46573 "EHLO mail-ed1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728378AbfG2NCV (ORCPT ); Mon, 29 Jul 2019 09:02:21 -0400 Received: by mail-ed1-f66.google.com with SMTP id d4so59279228edr.13; Mon, 29 Jul 2019 06:02:20 -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=tt8+c7Qc6AbuRWIfhDVP2GsR6IhoFI9cbqdXPL+msrE=; b=iN1oOiDKJr1UPZKyfaQkFB3Tptf5t39BmoTz4Ohsna/AXtU62D5zdT1z+iW1R19aRN uM4C4DqJzyOTPya3o2D2baJpFk7uchbkR3ODkjBvL3oYlRARnftFcjlfzQHRv+UQplkM s6kuR7d0jHcyzJFzUCSvmaN03Aw/EZXrGpGX4Qc4co+xg3W3kSojm9AUw9js0sBz/mbr 3X+bxm4k4MQ31qc7J6wrIpYI6Xi5buUO0R7rgyrP2ChZl5SLPD13X0kmNb36513bD/Gg nM96BvJ+4OVMRgcyLACG3f5taSG/18kBP17KCR1SPjNv4o2r5GxnWf184im6SLd2z62d moNg== 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=tt8+c7Qc6AbuRWIfhDVP2GsR6IhoFI9cbqdXPL+msrE=; b=HNNyCOPX7BsyAHq+7RTKBmkT/6PP2nCrCqJdKQRAtzSGXjD+0cXetk1MSrr2oEslPd 3wDbGZ2TqISOuidq32zKlYzNbVXRF7SAU1TUbAsSzol7u5yVOQDz8AYxsgDcuVvPlWS3 40h5HfDWLx/47HMUIbSpsTEN7QF/c7Zq5iccBAg6mMIniEKfnZ2tz4xJF8YPxc7IWRGM kGEyy4ykTp62CJC07aOeKqj7IegvjJv3egnw6xfNZ/nS8sYrCM2P7b7iBftEr8HoXds2 fghBSuPgp6z08KB/JdJXQ5Gve5OwnpWIfbHWN7+FGYPWy8+9KcqZAc8kcLYbeQDVFwQs k7wQ== X-Gm-Message-State: APjAAAWKVcEk9jfX1AhKZ1XaTZ6sJq6qtWXwzEb+Ci01/c5i6UuNOonK clzscuTuXXlAbWvw2x3mJ519eTI0wcSmlFTk6kk= X-Received: by 2002:a05:6402:896:: with SMTP id e22mr92099589edy.202.1564405339822; Mon, 29 Jul 2019 06:02:19 -0700 (PDT) MIME-Version: 1.0 References: <20190726123058.22915-1-hslester96@gmail.com> <20190727125749.63297c28@archlinux> <20190728083141.GA14194@onstation.org> <20190729080307.GA360@onstation.org> <20190729120802.000025e8@huawei.com> In-Reply-To: <20190729120802.000025e8@huawei.com> From: Chuhong Yuan Date: Mon, 29 Jul 2019 21:02:09 +0800 Message-ID: Subject: Re: [PATCH] iio: tsl2772: Use device-managed API To: Jonathan Cameron Cc: Brian Masney , 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 Jonathan Cameron =E4=BA=8E2019=E5=B9=B47=E6= =9C=8829=E6=97=A5=E5=91=A8=E4=B8=80 =E4=B8=8B=E5=8D=887:09=E5=86=99=E9=81= =93=EF=BC=9A > > On Mon, 29 Jul 2019 04:03:07 -0400 > Brian Masney wrote: > > > On Mon, Jul 29, 2019 at 11:03:00AM +0800, Chuhong Yuan wrote: > > > Brian Masney =E4=BA=8E2019=E5=B9=B47=E6=9C=88= 28=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 > > > > devm_add_action() could be used in the probe function to schedule t= he call > > > > to tsl2772_chip_off(). That would eliminate the need for > > > > tsl2772_remove(). See tsl2772_disable_regulators_action() for an ex= ample in > > > > that driver. > > > > > > > > > > I find that we can use devm_add_action_or_reset() for > > > tsl2772_disable_regulators_action() to eliminate the fault handling c= ode. > > > > > > 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. > > > > I would add a wrapper function (tsl2772_chip_off_action?) with the > > expected declaration that calls tsl2772_chip_off(). > > > > > > Chuhong: Another potential cleanup to shrink the size of this drive= r 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 chan= ges > > > > 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? > > > > Yes. > > > > > I have an additional question that I find regulator_disable() is used= in the > > > end of many .remove functions of drivers, which hinders us to use dev= m > > > functions. > > > One example is drivers/iio/light/gp2ap020a00f.c. > > > Is there any solution to this problem? > > > > There are devm_regulator_*() variants of the regulator API available > > that you can use. Lots of other APIs in the kernel have devm variants > > to simply drivers. > I don't think there are any devm_ versions of regulator disable. > > IIRC the argument made when this last came up was that it was rarely corr= ect > to be as course grained as a lot of IIO drivers are. We should probably > do runtime pm and turn these regulators off a lot more frequently. > > The reality is that it is an optimization that doesn't get done in > IIO drivers that often as we mostly just want them to work and many > usecases aren't actually power constrained, > > So we end up doing a lot of devm_add_action_or_reset to power down the > regulators. > I think I can add devm_ versions of regulator_enable and disable. Chuhong > Jonathan > > > > Brian > >