Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2391912iof; Wed, 8 Jun 2022 04:07:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzkAZc3OT5B26N7uE0f2BU099Fj6RY0FGk2l62jH4sYSCEmw1EK+6ifUbI8CfK6tFtwzzox X-Received: by 2002:a17:90b:4c4a:b0:1e3:3b3:8800 with SMTP id np10-20020a17090b4c4a00b001e303b38800mr37625780pjb.6.1654686425904; Wed, 08 Jun 2022 04:07:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654686425; cv=none; d=google.com; s=arc-20160816; b=IJpxBohbDxn7LjKx04L0n+rzOWb/ht26dlgzwyXDi705LoElFhebVMRwwO7faYu5gi 04UAiPbqyfyUyn/eyfZKVBW6GASg78I/BqJGqDOwP23snGIYE/wLdcQfycG0Kym7kxhy 90hxOs32xYHx6HS/6vyOQPmw3DcRy/LAeAnAuIiUqd38oIc3CJ0ygzz9uiZ3HlXzOZ+a kKjGUZPtBrxNG9pT2NcS2PuT4MH0DcZyD/5esd7o9GwdY/X3XjT7QFngZHwxE2jdzs8W yZAoLOu/dkyVy5HJETsavWuwmlPdGTdtQ9ge7wcPiTPVhbxgXktjov4kyLkr6VL+zBNm c8CQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:references:to:from:subject:cc :message-id:date:content-transfer-encoding:mime-version :dkim-signature; bh=1iFwdNwk1v1dXl+OlTTXTF6c13xKzPVa4F0ip2ie7ak=; b=RxQAXNccWjIUw7v9nVvUlwuP58rZjCWzpFqYDq5EvU+7xLyCRuJo6cVQZ9KouGs+AN eT314x02H9mPJBmS3mtFcZ7ckTrabQxYIjshacP2QKaYce48UfE/vS12BEE29ZpXgIAK gqF1D7nnSmWHhZvgtSjP+QcZMHuIqqDCkgECJoTVR/tZyCPQwG0ihVXe4JVyPDrxQVxz bTiVCQV9rDyzkW1cGFl6ryG077FGPo/LuyKtmgcZqBKMTisJoCSvuKKxI2TSdyIzoGJM ROEIfzQx7Un8uEXsagqI4GA9tbzfvtWAZlKtwc+cQ/QgL6hoWJUZQPzKJ9fdSdw2ZpS8 o0hQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@fairphone.com header.s=fair header.b="R6Uj/kR8"; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=fairphone.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id kx4-20020a17090b228400b001e2d8f841f3si23284470pjb.68.2022.06.08.04.07.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jun 2022 04:07:05 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@fairphone.com header.s=fair header.b="R6Uj/kR8"; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=fairphone.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 9DA1728CE81; Wed, 8 Jun 2022 03:32:10 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237476AbiFHKbS (ORCPT + 99 others); Wed, 8 Jun 2022 06:31:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49428 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237817AbiFHK30 (ORCPT ); Wed, 8 Jun 2022 06:29:26 -0400 Received: from mail-ed1-x52e.google.com (mail-ed1-x52e.google.com [IPv6:2a00:1450:4864:20::52e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ED56B14FC95 for ; Wed, 8 Jun 2022 03:18:54 -0700 (PDT) Received: by mail-ed1-x52e.google.com with SMTP id n28so26409303edb.9 for ; Wed, 08 Jun 2022 03:18:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fairphone.com; s=fair; h=mime-version:content-transfer-encoding:date:message-id:cc:subject :from:to:references:in-reply-to; bh=1iFwdNwk1v1dXl+OlTTXTF6c13xKzPVa4F0ip2ie7ak=; b=R6Uj/kR8aNyvL0If9eAlU2L/SUtOV5vbaXXSJFGtExUlkvqNZfxVvmdTgFsQ2NrLSZ 21SvpF0O2oQsiB3ERybUBhuX+g5mUi59un0dmQmQcIXLHAjENToLjRBcMdT5c8KnwF/l OAcw77biYKlFRWFNGJNZ7g49tOP/menfHXBrYYEOkT9bUxg2ULaWA71hlUqLo6DR5N/C gVw6MbDS3N9hd+cmM0kkcGo0j41mjf+SgBTzXJEV9kD9Ym8pCwBJE6j7dN88aep9b1hG VG1OUsbuJw+ajdmB9uv7irEt3xbvfXdi4+8xdunJe2Wyz1HJe65nXgiRky1iBon5EOFc aJtA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:content-transfer-encoding:date :message-id:cc:subject:from:to:references:in-reply-to; bh=1iFwdNwk1v1dXl+OlTTXTF6c13xKzPVa4F0ip2ie7ak=; b=kVTzPz/yMolSteDBiYU3RiwnGNf9Anc2kUmFrhw3Lt5DjdcSLFL6hKrl0dW1CS77p3 OlRope5Ks+mw6TNekVhwvhgC2UFq7OCrlQ0/nZWAEL0Wgiid8gUsS8dw5Gfw7pRwUEeH cEJgfIBsievt5JH/pgzv/SLJXK4Hmt6wXSqJiqxp9vAfs7350Lw4ye6NdyMmDxf3LEnA hejUepoA3gEk5FVcDoVr2kIfkWD0WqA1OQoc/1ugLkr2Ex++SKu4S0ec6ZHUxLNn8mpu v+yYaa/zMTCbN/NuU5RLql3IH+wXGMMLykyeIZyNvZGJFUOGjt+79WrJRIm1YoDRy0UI XOgw== X-Gm-Message-State: AOAM532fB3MK1aja0mVdwp66gpEMpmANTJ1l3FzDieOW3mDyUMZAOxUz 5CzgcJVZv4xz9h0oGK8yrdSkhQ== X-Received: by 2002:a05:6402:11c7:b0:42e:c47a:ffdf with SMTP id j7-20020a05640211c700b0042ec47affdfmr29844951edw.113.1654683533557; Wed, 08 Jun 2022 03:18:53 -0700 (PDT) Received: from localhost (144-178-202-138.static.ef-service.nl. [144.178.202.138]) by smtp.gmail.com with ESMTPSA id h9-20020a1709063b4900b007043b29dfd9sm8894340ejf.89.2022.06.08.03.18.52 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 08 Jun 2022 03:18:53 -0700 (PDT) Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Wed, 08 Jun 2022 12:18:52 +0200 Message-Id: Cc: <~postmarketos/upstreaming@lists.sr.ht>, , "Konrad Dybcio" , "Marijn Suijten" , "AngeloGioacchino Del Regno" , "Song Qiang" , "Lars-Peter Clausen" , "Rob Herring" , "Krzysztof Kozlowski" , "Andy Gross" , "Bjorn Andersson" , "Liam Girdwood" , "Mark Brown" , , , Subject: Re: [PATCH 3/5] proximity: vl53l0x: Handle the VDD regulator From: "Luca Weiss" To: "Markuss Broks" , , X-Mailer: aerc 0.9.0 References: <20220523175344.5845-1-markuss.broks@gmail.com> <20220523175344.5845-4-markuss.broks@gmail.com> In-Reply-To: <20220523175344.5845-4-markuss.broks@gmail.com> X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Markuss, On Mon May 23, 2022 at 7:53 PM CEST, Markuss Broks wrote: > Handle the regulator supplying the VDD pin of VL53L0X. > > Signed-off-by: Markuss Broks > --- > drivers/iio/proximity/vl53l0x-i2c.c | 37 +++++++++++++++++++++++++++++ > 1 file changed, 37 insertions(+) > > diff --git a/drivers/iio/proximity/vl53l0x-i2c.c b/drivers/iio/proximity/= vl53l0x-i2c.c > index 12a3e2eff464..8581a873919f 100644 > --- a/drivers/iio/proximity/vl53l0x-i2c.c > +++ b/drivers/iio/proximity/vl53l0x-i2c.c > @@ -43,6 +43,7 @@ > struct vl53l0x_data { > struct i2c_client *client; > struct completion completion; > + struct regulator *vdd_supply; > }; > =20 > static irqreturn_t vl53l0x_handle_irq(int irq, void *priv) > @@ -192,10 +193,31 @@ static const struct iio_info vl53l0x_info =3D { > .read_raw =3D vl53l0x_read_raw, > }; > =20 > +static void vl53l0x_power_off(void *_data) > +{ > + struct vl53l0x_data *data =3D _data; > + > + regulator_disable(data->vdd_supply); > +} > + > +static int vl53l0x_power_on(struct vl53l0x_data *data) > +{ > + int ret; > + > + ret =3D regulator_enable(data->vdd_supply); > + if (ret) > + return ret; > + > + usleep_range(3200, 5000); > + > + return 0; > +} > + > static int vl53l0x_probe(struct i2c_client *client) > { > struct vl53l0x_data *data; > struct iio_dev *indio_dev; > + int error; > =20 > indio_dev =3D devm_iio_device_alloc(&client->dev, sizeof(*data)); > if (!indio_dev) > @@ -210,6 +232,21 @@ static int vl53l0x_probe(struct i2c_client *client) > I2C_FUNC_SMBUS_BYTE_DATA)) > return -EOPNOTSUPP; > =20 > + data->vdd_supply =3D devm_regulator_get_optional(&client->dev, "vdd"); > + if (IS_ERR(data->vdd_supply)) > + return dev_err_probe(&client->dev, PTR_ERR(data->vdd_supply), > + "Unable to get VDD regulator\n"); It looks like this optional regulator is not actually optional. [ 1.919995] vl53l0x-i2c 1-0029: error -ENODEV: Unable to get VDD regulat= or When using devm_regulator_get instead, a dummy regulator gets returned which I think is what we want here: [ 1.905518] vl53l0x-i2c 1-0029: supply vdd not found, using dummy regula= tor Can you fix this up or should I send a patch? Regards Luca > + > + error =3D vl53l0x_power_on(data); > + if (error) > + return dev_err_probe(&client->dev, error, > + "Failed to power on the chip\n"); > + > + error =3D devm_add_action_or_reset(&client->dev, vl53l0x_power_off, dat= a); > + if (error) > + return dev_err_probe(&client->dev, error, > + "Failed to install poweroff action\n"); > + > indio_dev->name =3D "vl53l0x"; > indio_dev->info =3D &vl53l0x_info; > indio_dev->channels =3D vl53l0x_channels; > --=20 > 2.36.1