[1/4] media: i2c: ov5695: use regulator_bulk_enable/regulator_bulk disable instead of for loop
| Message ID | 20220519075117.1003520-2-tommaso.merciai@amarulasolutions.com |
|---|---|
| State | New |
| Headers |
Return-Path: <linux-amarula+bncBD6ZNPUKRQLBB6XNS6KAMGQE4JBDI7Y@amarulasolutions.com> X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id ED1D53F1D5 for <linux-amarula@patchwork.amarulasolutions.com>; Thu, 19 May 2022 09:51:22 +0200 (CEST) Received: by mail-wr1-f69.google.com with SMTP id l6-20020adfe586000000b0020d0ff79cecsf1239204wrm.12 for <linux-amarula@patchwork.amarulasolutions.com>; Thu, 19 May 2022 00:51:22 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1652946682; cv=pass; d=google.com; s=arc-20160816; b=lmBg97F6NU6Ejg0jDBUYHZ+RJnlsxlXjyXCEEexFHDbOydLdophZm17TUsO0efiEGd PP6VjILEamBKd1y+iL6znDY/vBa4ryed1pAM1aTNr/Pgm/MH9IUA5tEvYn/7E1acYjbw InieHIVvJPXO3eT0wLZMPdlwGtlUlbscyHwQs6sN6F2FsOkhgNe5+sDDjFOF74OHnUp9 ne4c7M6YM8jUEb8GGAESe3+RjD1VpTtykdeB05G6fQ+IxvXOUH2DjGzIpe4XqLeZN3iS aWXZfKYi747N5A98eE1tKdjVJbRFjgBi2e47GWHusmiLsTC50l8xWSFCcG+uW8eebnfa bN0A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=fqp3RqKwqF4aKOF8nirB8osD8DgT6BwOx96Y3NqF2kw=; b=UK61ov3qWDIsoM9XwfjQZ2KwEPkDboSMMap7DdNTamLR/2BVPU2fKSMse5ypGQApay JtjcHabadQDZWEgDMZXCOB9zJSs/yhZO228oZsqsnqmQbAZmItUPml6ioBHr5Ah2QpZa naLRzUEhYv459lpdNXbVqM5AU1Flt2F8/PxwjXfexyFHjD2Q80yyToNMVt+CCCC/Nezx 8sHcFuSmTIMujI3HJwDyXZfkV+y7ourBUb5aKKH8Obbhywwu2CdyX5ZjGbleLjD5LNoF 5fYBqE0+Y3BN4smiv3HLIRsw3MS6rCpuEOatnRx1kNkam1GICfLo942E/9OHVdb7uU7B ye4w== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=dREwkqgK; spf=pass (google.com: domain of tommaso.merciai@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=tommaso.merciai@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=fqp3RqKwqF4aKOF8nirB8osD8DgT6BwOx96Y3NqF2kw=; b=r0haxF6cbI6T4yuaJkqsRONL7UcCI74ztx90r2gxygrPZks668AMXqLAcGFpYtOcAn L2ZuYl8ThyJBG5B16hd5pCOzSd0IhK5f7pp4G0muF5ynWDWMBeChc2dyq9kCbfeL19oR LqSauYkyy/XWgo+HQBNXHkNGW1HEWccfpDZxc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-spam-checked-in-group:list-post:list-help:list-archive :list-unsubscribe; bh=fqp3RqKwqF4aKOF8nirB8osD8DgT6BwOx96Y3NqF2kw=; b=wvbVH3kxlEmsJMqM4pw+5yZUUtqvp+Ce8puqGuqNY0/erroGCGqEhvWYoAqEuNlErg +ttLN7nwOfUSGFDDWnyjtIaDHbhtgKT4iSnjGu1jEpSynSgsoxYur2y3ClxWwtjWK4OE 325LASO856iDcBosafpuJVRxQjbo6OcqVvQg2dA+e6NkO7eNlFcMJxpSEQlcXbpjW9Dg BdwnbimfX1sJoAH7CSnZJbUDcocT/6p06g6qM00OGtH1SuFIU6Ic4P+lZVnC3cdgvmfn p6fx6fmmxqdZqY88fPjeQJT+bRRgnEHDkp7+n6mAzgG8o0yzxNlIRY29swMM+WjOmpPs 2mZw== X-Gm-Message-State: AOAM530ddVXc4F3m5G3DrCTjQI+Z3k0AquMGgODhBASRVys4KdVrPZb/ RYnz7ygl5BTcjo7OIhRb2WhIwmsP X-Google-Smtp-Source: ABdhPJy60PqkQkeFHQYX69PIX/L3F8X+0hXow+bt/nz7Ja9VZtSeJsfE0c+fVrdtyicUFPKO15RvHQ== X-Received: by 2002:a7b:c387:0:b0:394:81f8:f049 with SMTP id s7-20020a7bc387000000b0039481f8f049mr2605536wmj.126.1652946682276; Thu, 19 May 2022 00:51:22 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a5d:64ca:0:b0:20c:bb44:bd7 with SMTP id f10-20020a5d64ca000000b0020cbb440bd7ls2968933wri.0.gmail; Thu, 19 May 2022 00:51:21 -0700 (PDT) X-Received: by 2002:a5d:4a10:0:b0:20e:60b6:34a6 with SMTP id m16-20020a5d4a10000000b0020e60b634a6mr2835176wrq.404.1652946681245; Thu, 19 May 2022 00:51:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652946681; cv=none; d=google.com; s=arc-20160816; b=qBTfKifjx1PYB9DUeAfX05u51wG/FpwgnffWqC4ea/3uwfGZVYTN3sooEFLuYrvsHX +RwKMUmMxQqGmqu8SEgeFg4QUD5fh6hm3tFRcirQZMa2dm4dHR/uCvofA/EIWGBkbIZZ EKcF0sklSZLQg0KfB9bCnx2Bt4qztEI44TCgbOjd/yHDrLcY/KQ0WlE81SYnDQ7GDLaU InRAqex88e0/9Pf5CeFoiBjTc9q0bLHZCdtn9SXqgaJOAEHvcWj0dY4P0WqwHKtk7Peo twGcoh7Zk6u3P4Cr4DZEEHYT9S2aTah5vK0DFm4f5Gt/+Fib7rpII3ATHRYj7YxhyoI+ qMZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=y+ISkJJI9HCW17NlesxzBupNaP4V8jkoqAfbXb7t54A=; b=Rdr5EoTJeeHcPvGqknCa3rcG7luk5ovWBmYlJm87HCEko5S2+o6FbmL9LiR2QfmveC J3ld95YbonJqnUewvByWUdB/W6gzO5P25GcNohhNlr6pAcKG3TsMIUpfVIgS0LQFP5my 5rsOHevJppUplhMuRBZn4kcIcYyBYe7e+3MRO6eySHWspoXpHlX9rAJJgDjg6lp0PBIa lV0GzfoT+JhEB9JDbLCPEvuiJ3ypvBUSFyOQZePHR4/JGIGowo4N5773CbprCKS2pEDw YWfRG5tIXN8xzQUVk67HpbuJdhH47T0OMjo9LwRMIQECcmOVFpZgSraz79xgpLutNwTV qnIg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=dREwkqgK; spf=pass (google.com: domain of tommaso.merciai@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=tommaso.merciai@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id p21-20020a1c5455000000b003972dedca8csor302253wmi.43.2022.05.19.00.51.21 for <linux-amarula@amarulasolutions.com> (Google Transport Security); Thu, 19 May 2022 00:51:21 -0700 (PDT) Received-SPF: pass (google.com: domain of tommaso.merciai@amarulasolutions.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; X-Received: by 2002:a7b:c2a9:0:b0:397:9a4:f66b with SMTP id c9-20020a7bc2a9000000b0039709a4f66bmr2629692wmk.128.1652946681000; Thu, 19 May 2022 00:51:21 -0700 (PDT) Received: from tom-ThinkPad-T14s-Gen-2i.station (net-188-217-53-154.cust.vodafonedsl.it. [188.217.53.154]) by smtp.gmail.com with ESMTPSA id c6-20020a05600c4a0600b003942a244ebfsm3370254wmp.4.2022.05.19.00.51.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 May 2022 00:51:20 -0700 (PDT) From: Tommaso Merciai <tommaso.merciai@amarulasolutions.com> To: Cc: tommaso.merciai@amarulasolutions.com, linuxfancy@googlegroups.com, linux-amarula@amarulasolutions.com, michael@amarulasolutions.com, Shunqian Zheng <zhengsq@rock-chips.com>, Mauro Carvalho Chehab <mchehab@kernel.org>, linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/4] media: i2c: ov5695: use regulator_bulk_enable/regulator_bulk disable instead of for loop Date: Thu, 19 May 2022 09:51:14 +0200 Message-Id: <20220519075117.1003520-2-tommaso.merciai@amarulasolutions.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220519075117.1003520-1-tommaso.merciai@amarulasolutions.com> References: <20220519075117.1003520-1-tommaso.merciai@amarulasolutions.com> MIME-Version: 1.0 X-Original-Sender: tommaso.merciai@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=dREwkqgK; spf=pass (google.com: domain of tommaso.merciai@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=tommaso.merciai@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Content-Type: text/plain; charset="UTF-8" Precedence: list Mailing-list: list linux-amarula@amarulasolutions.com; contact linux-amarula+owners@amarulasolutions.com List-ID: <linux-amarula.amarulasolutions.com> X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com X-Google-Group-Id: 476853432473 List-Post: <https://groups.google.com/a/amarulasolutions.com/group/linux-amarula/post>, <mailto:linux-amarula@amarulasolutions.com> List-Help: <https://support.google.com/a/amarulasolutions.com/bin/topic.py?topic=25838>, <mailto:linux-amarula+help@amarulasolutions.com> List-Archive: <https://groups.google.com/a/amarulasolutions.com/group/linux-amarula/> List-Unsubscribe: <mailto:googlegroups-manage+476853432473+unsubscribe@googlegroups.com>, <https://groups.google.com/a/amarulasolutions.com/group/linux-amarula/subscribe> |
| Series |
arm64: dts: rockchip: px30: fix ov5695 camera probe
|
|
Commit Message
Tommaso Merciai
May 19, 2022, 7:51 a.m. UTC
Enable regulator using regulator_bulk_enable/regulatore_bulk_disable
function in __ov5695_power_on/__ov5695_power_off function instead of for loop.
This reduce code size and make things more clear
Signed-off-by: Tommaso Merciai <tommaso.merciai@amarulasolutions.com>
Co-Developed-by: Michael Trimarchi <michael@amarulasolutions.com>
---
drivers/media/i2c/ov5695.c | 25 +++++++------------------
1 file changed, 7 insertions(+), 18 deletions(-)
Comments
Hi All, On Thu, Jun 02, 2022 at 07:57:02AM +0200, Michael Nazzareno Trimarchi wrote: > Hi Mark > > Add Dongchun Zhu, for the patch of regulator changes and mark brown to > clarify the API for bulk regulator. > > The commit f1a64f56663e9d03e509439016dcbddd0166b2da states that the > regulator bulk api does not guarantee the order. > Can you help me with this? Just a gentle ping on this point. Thanks Regards, Tommaso > > On Wed, Jun 1, 2022 at 10:39 AM Michael Nazzareno Trimarchi > <michael@amarulasolutions.com> wrote: > > > > Hi > > > > On Wed, Jun 1, 2022 at 10:11 AM Jacopo Mondi <jacopo@jmondi.org> wrote: > > > > > > Hi Micheal, > > > > > > On Tue, May 31, 2022 at 05:50:51PM +0200, Michael Nazzareno Trimarchi wrote: > > > > Hi > > > > > > > > On Tue, May 31, 2022 at 5:40 PM Tommaso Merciai > > > > <tommaso.merciai@amarulasolutions.com> wrote: > > > > > > > > > > Hi Jacopo, > > > > > On Tue, May 31, 2022 at 03:14:09PM +0200, Jacopo Mondi wrote: > > > > > > Hi Tommaso, > > > > > > > > > > > > On Thu, May 19, 2022 at 09:51:14AM +0200, Tommaso Merciai wrote: > > > > > > > Enable regulator using regulator_bulk_enable/regulatore_bulk_disable > > > > > > > function in __ov5695_power_on/__ov5695_power_off function instead of for loop. > > > > > > > This reduce code size and make things more clear > > > > > > > > > > > > > > Signed-off-by: Tommaso Merciai <tommaso.merciai@amarulasolutions.com> > > > > > > > Co-Developed-by: Michael Trimarchi <michael@amarulasolutions.com> > > > > > > > --- > > > > > > > drivers/media/i2c/ov5695.c | 25 +++++++------------------ > > > > > > > 1 file changed, 7 insertions(+), 18 deletions(-) > > > > > > > > > > > > > > diff --git a/drivers/media/i2c/ov5695.c b/drivers/media/i2c/ov5695.c > > > > > > > index 439385938a51..880b586e55fe 100644 > > > > > > > --- a/drivers/media/i2c/ov5695.c > > > > > > > +++ b/drivers/media/i2c/ov5695.c > > > > > > > @@ -972,7 +972,7 @@ static int ov5695_s_stream(struct v4l2_subdev *sd, int on) > > > > > > > > > > > > > > static int __ov5695_power_on(struct ov5695 *ov5695) > > > > > > > { > > > > > > > - int i, ret; > > > > > > > + int ret; > > > > > > > struct device *dev = &ov5695->client->dev; > > > > > > > > > > > > > > ret = clk_prepare_enable(ov5695->xvclk); > > > > > > > @@ -987,13 +987,10 @@ static int __ov5695_power_on(struct ov5695 *ov5695) > > > > > > > * The hardware requires the regulators to be powered on in order, > > > > > > > * so enable them one by one. > > > > > > > */ > > > > > > > > > > > > The comment says that the hardware requires regulators to be enabled > > > > > > in precise order > > > > > > > > > > > > > > They are enabled on the array order. > > > > > > > > > > > - for (i = 0; i < OV5695_NUM_SUPPLIES; i++) { > > > > > > > - ret = regulator_enable(ov5695->supplies[i].consumer); > > > > > > > - if (ret) { > > > > > > > - dev_err(dev, "Failed to enable %s: %d\n", > > > > > > > - ov5695->supplies[i].supply, ret); > > > > > > > - goto disable_reg_clk; > > > > > > > - } > > > > > > > + ret = regulator_bulk_enable(ARRAY_SIZE(ov5695->supplies), ov5695->supplies); > > > > > > > > > > > > bulk_enable() uses the async API (async_schedule_domain() in > > > > > > particular) which by the name makes me think such ordering guarantee > > > > > > cannot be respected. > > > > > > > > I don't think so. Will make no sense because if it fails, revert them. > > > > Even the bulk disable disable them > > > > in reverse order > > > > > > > > > > I understand your points, but even the commit message in the patch > > > linked by Tommaso [1] (which I see in mainline as > > > f1a64f56663e ("media: i2c: ov5695: Fix power on and off sequences")) > > > reports: > > > > > > "Given the bulk API does not give any guarantee about the order of > > > regulators, change the driver to use regulator_disable() instead." > > > > > > However I would have expected the core regulator API to clearly document > > > this behaviour. > > > > > > > Yes, I agree. I see two points: > > - patch f1a64f56663e is not fully consistent > > - a patch is needed to the regulator api documentation > > > > I think that we need better documentation of the api but: > > Work-queues are SMP-safe and guarantee serialization of actual work performed. > > > > Michael > > > > > > > > > > > > > > > > > > > > > However most sensors require some kind of ordering when enabling > > > > > > regulators, and most of the use the bulk API anyhow. The fact this > > > > > > driver uses the bulk API to get an release the regulators but not for > > > > > > enabling them and the above comment, makes me think it has been done > > > > > > on purpose ? Could you check with the driver author maybe ? > > > > > > > > > > Thanks for suggestion, good question. > > > > > I see also ov5693 driver use bulk_enable/bulk_disable > > > > > on ov5693_sensor_powerdown and ov5693_sensor_powerup functions, I take > > > > > this as reference (and I'm wrong) > > > > > > > > > > In a functional test on PX30_Mini_evb_v11_20190507, after this series > > > > > I'm able to see the correct chip id during probe and do some capture. > > > > > > > > > > I think you are right Jacopo, we can drop off this [PATCH 1/4] > > > > > On the following link I found the issue that you describe: [1] > > > > > > > > > > > > > WHy drop? > > > > > > As this is a partial revert of [1]. > > > > > > I think in practice this won't make any actual difference, but if not > > > 100% sure, better leave it the way it is as the authors of [1] might > > > have actually been experiencing issues. Even more as this patch is > > > not a bugfix but a nice-to-have. Up to you :) > > > > > > > > > > > > > > Michael > > > > > > > > > > > > > > > > > + if (ret) { > > > > > > > + dev_err(dev, "Failed to enable regulators %d\n", ret); > > > > > > > + goto disable_reg_clk; > > > > > > > } > > > > > > > > > > > > > > gpiod_set_value_cansleep(ov5695->reset_gpio, 0); > > > > > > > @@ -1003,8 +1000,7 @@ static int __ov5695_power_on(struct ov5695 *ov5695) > > > > > > > return 0; > > > > > > > > > > > > > > disable_reg_clk: > > > > > > > - for (--i; i >= 0; i--) > > > > > > > - regulator_disable(ov5695->supplies[i].consumer); > > > > > > > + regulator_bulk_disable(ARRAY_SIZE(ov5695->supplies), ov5695->supplies); > > > > > > > > > > > > FYI the bulk API does this for you if enabling any of the regulators fails. > > > > > > Hence this should not be necessary. > > > > > > > > > > Thanks for sharing! This is new to me. > > > > > I'll update the series on v2 removing this patch. > > > > > > > > > > Regards, > > > > > Tommaso > > > > > > > > > > [1]: https://mailweb.openeuler.org/hyperkitty/list/kernel@openeuler.org/message/4X54QYJDRRE4K5BW4FTDZUGRAL4GRQWY/ > > > > > > > > > > > Thanks > > > > > > j > > > > > > > > > > > > > clk_disable_unprepare(ov5695->xvclk); > > > > > > > > > > > > > > return ret; > > > > > > > @@ -1012,8 +1008,6 @@ static int __ov5695_power_on(struct ov5695 *ov5695) > > > > > > > > > > > > > > static void __ov5695_power_off(struct ov5695 *ov5695) > > > > > > > { > > > > > > > - struct device *dev = &ov5695->client->dev; > > > > > > > - int i, ret; > > > > > > > > > > > > > > clk_disable_unprepare(ov5695->xvclk); > > > > > > > gpiod_set_value_cansleep(ov5695->reset_gpio, 1); > > > > > > > @@ -1022,12 +1016,7 @@ static void __ov5695_power_off(struct ov5695 *ov5695) > > > > > > > * The hardware requires the regulators to be powered off in order, > > > > > > > * so disable them one by one. > > > > > > > */ > > > > > > > - for (i = OV5695_NUM_SUPPLIES - 1; i >= 0; i--) { > > > > > > > - ret = regulator_disable(ov5695->supplies[i].consumer); > > > > > > > - if (ret) > > > > > > > - dev_err(dev, "Failed to disable %s: %d\n", > > > > > > > - ov5695->supplies[i].supply, ret); > > > > > > > - } > > > > > > > + regulator_bulk_disable(ARRAY_SIZE(ov5695->supplies), ov5695->supplies); > > > > > > > } > > > > > > > > > > > > > > static int __maybe_unused ov5695_runtime_resume(struct device *dev) > > > > > > > -- > > > > > > > 2.25.1 > > > > > > > > > > > > > > > > > -- > > > > > Tommaso Merciai > > > > > Embedded Linux Engineer > > > > > tommaso.merciai@amarulasolutions.com > > > > > __________________________________ > > > > > > > > > > Amarula Solutions SRL > > > > > Via Le Canevare 30, 31100 Treviso, Veneto, IT > > > > > T. +39 042 243 5310 > > > > > info@amarulasolutions.com > > > > > www.amarulasolutions.com > > > > > > > > > > > > > > > > -- > > > > Michael Nazzareno Trimarchi > > > > Co-Founder & Chief Executive Officer > > > > M. +39 347 913 2170 > > > > michael@amarulasolutions.com > > > > __________________________________ > > > > > > > > Amarula Solutions BV > > > > Joop Geesinkweg 125, 1114 AB, Amsterdam, NL > > > > T. +31 (0)85 111 9172 > > > > info@amarulasolutions.com > > > > www.amarulasolutions.com > > > > > > > > -- > > Michael Nazzareno Trimarchi > > Co-Founder & Chief Executive Officer > > M. +39 347 913 2170 > > michael@amarulasolutions.com > > __________________________________ > > > > Amarula Solutions BV > > Joop Geesinkweg 125, 1114 AB, Amsterdam, NL > > T. +31 (0)85 111 9172 > > info@amarulasolutions.com > > www.amarulasolutions.com > > > > -- > Michael Nazzareno Trimarchi > Co-Founder & Chief Executive Officer > M. +39 347 913 2170 > michael@amarulasolutions.com > __________________________________ > > Amarula Solutions BV > Joop Geesinkweg 125, 1114 AB, Amsterdam, NL > T. +31 (0)85 111 9172 > info@amarulasolutions.com > www.amarulasolutions.com
diff --git a/drivers/media/i2c/ov5695.c b/drivers/media/i2c/ov5695.c index 439385938a51..880b586e55fe 100644 --- a/drivers/media/i2c/ov5695.c +++ b/drivers/media/i2c/ov5695.c @@ -972,7 +972,7 @@ static int ov5695_s_stream(struct v4l2_subdev *sd, int on) static int __ov5695_power_on(struct ov5695 *ov5695) { - int i, ret; + int ret; struct device *dev = &ov5695->client->dev; ret = clk_prepare_enable(ov5695->xvclk); @@ -987,13 +987,10 @@ static int __ov5695_power_on(struct ov5695 *ov5695) * The hardware requires the regulators to be powered on in order, * so enable them one by one. */ - for (i = 0; i < OV5695_NUM_SUPPLIES; i++) { - ret = regulator_enable(ov5695->supplies[i].consumer); - if (ret) { - dev_err(dev, "Failed to enable %s: %d\n", - ov5695->supplies[i].supply, ret); - goto disable_reg_clk; - } + ret = regulator_bulk_enable(ARRAY_SIZE(ov5695->supplies), ov5695->supplies); + if (ret) { + dev_err(dev, "Failed to enable regulators %d\n", ret); + goto disable_reg_clk; } gpiod_set_value_cansleep(ov5695->reset_gpio, 0); @@ -1003,8 +1000,7 @@ static int __ov5695_power_on(struct ov5695 *ov5695) return 0; disable_reg_clk: - for (--i; i >= 0; i--) - regulator_disable(ov5695->supplies[i].consumer); + regulator_bulk_disable(ARRAY_SIZE(ov5695->supplies), ov5695->supplies); clk_disable_unprepare(ov5695->xvclk); return ret; @@ -1012,8 +1008,6 @@ static int __ov5695_power_on(struct ov5695 *ov5695) static void __ov5695_power_off(struct ov5695 *ov5695) { - struct device *dev = &ov5695->client->dev; - int i, ret; clk_disable_unprepare(ov5695->xvclk); gpiod_set_value_cansleep(ov5695->reset_gpio, 1); @@ -1022,12 +1016,7 @@ static void __ov5695_power_off(struct ov5695 *ov5695) * The hardware requires the regulators to be powered off in order, * so disable them one by one. */ - for (i = OV5695_NUM_SUPPLIES - 1; i >= 0; i--) { - ret = regulator_disable(ov5695->supplies[i].consumer); - if (ret) - dev_err(dev, "Failed to disable %s: %d\n", - ov5695->supplies[i].supply, ret); - } + regulator_bulk_disable(ARRAY_SIZE(ov5695->supplies), ov5695->supplies); } static int __maybe_unused ov5695_runtime_resume(struct device *dev)