Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp5822533ybi; Wed, 31 Jul 2019 03:58:10 -0700 (PDT) X-Google-Smtp-Source: APXvYqxpvxKOoWGPP91ctZO4P6t0MTMNikcTgLWR8SEE8GRr+/lPPGzSKdlshcjMssxic2G3uMH8 X-Received: by 2002:a63:7205:: with SMTP id n5mr58577650pgc.443.1564570690145; Wed, 31 Jul 2019 03:58:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564570690; cv=none; d=google.com; s=arc-20160816; b=mXGXrvtoQ4UyfvSNmlhBw8iK+/i5Wf9yK3ibDGeRZWlcjEUkwrIQ8s2Cndf0fra59C bTyMLjkl9aT6z6e4RbM2+NTM6rFXqrzTMae1bSJg20smf0SqYAuAMR7E9svP6vee/lLg URYmYLGoBln/5xGsdPV80C6P+iQhz/hNrW2b66Su120OqOZinIyxs9GzIc2rRphvcEBg 70u5Un0S4+F3PYMwmEMLkME+uQSdt14gB7Yyh5sLzNfRXVruElu4/wtCNCE2sv5u8rts YBZFUjo+K/i0xB5WnSQ2o1dghsWfNXQ7A8X8niXdivWKaSyoTjhjdQeUamEzwJDs06n4 XgUQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=ICjsSbT2KxhkzWAprhMdWgDVqqpycTfdWwANTC6uxIU=; b=kjSTExEAcEMOTODBz8PUh4148Vj+9rHI6ddjBDwBhP4B7O9BvNVZTzN4Uf4TFo7Sq5 MA8dmjkbsbvHQA4v4fsSb1q9bXWeYQ0KlAXDIsUhyr5VfJ6uDAc8sSb7+WichHi/a5Lb riBvdFaSTxBAqHDA33d/7loT/OAXaF3WKZurbwOkNc5QxwzDVSbKS2mSvg7H45USYkwj OBndyn5ZBCj1bSo3xfYnR7GB/oYsBJUdffcjXgVHSO+PxrW1GtsvAUTRiLCcTkPOdBIr IKC9kkhC79BPWjO/v0/0EbWabjR2BeTVWi8ixLMQippKhuuA6TbjKiKuqwTOAMisjkv/ F/mg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@onstation.org header.s=default header.b=dUl9aY28; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s7si29753122plr.95.2019.07.31.03.57.55; Wed, 31 Jul 2019 03:58:10 -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 (test mode) header.i=@onstation.org header.s=default header.b=dUl9aY28; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727463AbfGaJkT (ORCPT + 99 others); Wed, 31 Jul 2019 05:40:19 -0400 Received: from onstation.org ([52.200.56.107]:45282 "EHLO onstation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726331AbfGaJkT (ORCPT ); Wed, 31 Jul 2019 05:40:19 -0400 Received: from localhost (c-98-239-145-235.hsd1.wv.comcast.net [98.239.145.235]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: masneyb) by onstation.org (Postfix) with ESMTPSA id D0C2C3E910; Wed, 31 Jul 2019 09:40:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=onstation.org; s=default; t=1564566017; bh=I0papPTksij9ii1sn+NgdR9xpTJbqm6k5gNZvoHczdY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=dUl9aY28ETvQkgZrciA7TcMsvicTu9VKRc6zFseB2fSDnV6+7goKfnZWASFQmzMJZ HN2CnYMCnhsbvEZ6ONsTDqkwNx4/CzFNywIotkKdgpURJNYR0su/WIG/ZfaYBLhq7w vFelqLPnDP8Nks6FRnaL0mrbe0vLotk35XR8/qcQ= Date: Wed, 31 Jul 2019 05:40:16 -0400 From: Brian Masney To: Chuhong Yuan Cc: Jonathan Cameron , Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 2/2] iio: tsl2772: Use regulator_bulk_() APIs Message-ID: <20190731094016.GB19501@onstation.org> References: <20190731030423.8116-1-hslester96@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190731030423.8116-1-hslester96@gmail.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Chuhong, On Wed, Jul 31, 2019 at 11:04:23AM +0800, Chuhong Yuan wrote: > Use regulator_bulk_() APIs to shrink driver size. > > Signed-off-by: Chuhong Yuan Just a few minor nitpicks below. Overall, this is looking nice. > --- > Changes in v3: > - Split v2 into two patches. > - Add dev_err to log error messages. > - Add a check for EPROBE_DEFER. > > drivers/iio/light/tsl2772.c | 82 +++++++++++-------------------------- > 1 file changed, 24 insertions(+), 58 deletions(-) > > diff --git a/drivers/iio/light/tsl2772.c b/drivers/iio/light/tsl2772.c > index f1134f183be7..fd6d44297dba 100644 > --- a/drivers/iio/light/tsl2772.c > +++ b/drivers/iio/light/tsl2772.c > @@ -134,6 +134,12 @@ enum { > TSL2772_CHIP_SUSPENDED = 2 > }; > > +enum { > + TSL2772_SUPPLY_VDD = 0, > + TSL2772_SUPPLY_VDDIO = 1, > + TSL2772_NUM_SUPPLIES = 2 > +}; > + > /* Per-device data */ > struct tsl2772_als_info { > u16 als_ch0; > @@ -161,8 +167,7 @@ struct tsl2772_chip { > struct mutex prox_mutex; > struct mutex als_mutex; > struct i2c_client *client; > - struct regulator *vdd_supply; > - struct regulator *vddio_supply; > + struct regulator_bulk_data reg[TSL2772_NUM_SUPPLIES]; I prefer that this was named something other than 'reg'. Maybe 'supplies'? I know that there are a few other drivers in IIO that use this name. > u16 prox_data; > struct tsl2772_als_info als_cur_info; > struct tsl2772_settings settings; > @@ -697,46 +702,7 @@ static void tsl2772_disable_regulators_action(void *_data) > { > struct tsl2772_chip *chip = _data; > > - regulator_disable(chip->vdd_supply); > - regulator_disable(chip->vddio_supply); > -} > - > -static int tsl2772_enable_regulator(struct tsl2772_chip *chip, > - struct regulator *regulator) > -{ > - int ret; > - > - ret = regulator_enable(regulator); > - if (ret < 0) { > - dev_err(&chip->client->dev, "Failed to enable regulator: %d\n", > - ret); > - return ret; > - } > - > - return 0; > -} > - > -static struct regulator *tsl2772_get_regulator(struct tsl2772_chip *chip, > - char *name) > -{ > - struct regulator *regulator; > - int ret; > - > - regulator = devm_regulator_get(&chip->client->dev, name); > - if (IS_ERR(regulator)) { > - if (PTR_ERR(regulator) != -EPROBE_DEFER) > - dev_err(&chip->client->dev, > - "Failed to get %s regulator %d\n", > - name, (int)PTR_ERR(regulator)); > - > - return regulator; > - } > - > - ret = tsl2772_enable_regulator(chip, regulator); > - if (ret < 0) > - return ERR_PTR(ret); > - > - return regulator; > + regulator_bulk_disable(ARRAY_SIZE(chip->reg), chip->reg); > } > > static int tsl2772_chip_on(struct iio_dev *indio_dev) > @@ -1804,14 +1770,21 @@ static int tsl2772_probe(struct i2c_client *clientp, > chip->client = clientp; > i2c_set_clientdata(clientp, indio_dev); > > - chip->vddio_supply = tsl2772_get_regulator(chip, "vddio"); > - if (IS_ERR(chip->vddio_supply)) > - return PTR_ERR(chip->vddio_supply); > + chip->reg[TSL2772_SUPPLY_VDD].supply = "vdd"; > + chip->reg[TSL2772_SUPPLY_VDDIO].supply = "vddio"; > > - chip->vdd_supply = tsl2772_get_regulator(chip, "vdd"); > - if (IS_ERR(chip->vdd_supply)) { > - regulator_disable(chip->vddio_supply); > - return PTR_ERR(chip->vdd_supply); > + ret = devm_regulator_bulk_get(&clientp->dev, ARRAY_SIZE(chip->reg), > + chip->reg); This needs to be aligned with devm_regulator_bulk_get, not ARRAY_SIZE. > + if (ret < 0) { > + if (ret != -EPROBE_DEFER) > + dev_err(&clientp->dev, "Failed to get regulators: %d\n", ret); Add newline. Brian