Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2351995imm; Thu, 20 Sep 2018 11:42:51 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZpMO8fS3r6/Ofi6H80sRjaIEFQRrrHO0raIOHsQMz2UkU5PzlDPdMXAPPsgvphb2BLYDxy X-Received: by 2002:a62:6602:: with SMTP id a2-v6mr42934128pfc.159.1537468971708; Thu, 20 Sep 2018 11:42:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537468971; cv=none; d=google.com; s=arc-20160816; b=kzAHDPNbkBgGJCA4y6TPNVIj6gCvO2LfCtRmOhqWMJHKa1oHepBPtgN+tR0D56WD1a BFOyaOw6bLloi6lBCr3DMjyks4s+eR2W/Rf7r2tzp67RddI/qSWXLMv8wQ2O8KZZgriN D9xsfPd4A8291GFsXT+TXyvFx3bfSeIyZmxcxdUrm7b6PbD9LpkZlNLebNBSTqO5PiNh aEI/+ptcj7u2TZ9XtczkhY/BrXsUW0DITqQEJF7It8h1RYdgjGXepJFyq7uPktpfPJaY sPh3rA9/zfShIPEdU3vZyFL51oKipcawhOJLHg07IpRkdoUZfxTJzqmvumIBJMltJrr8 LGxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=9fAE/a+wdidvCBvvXtahNWfBSju+KPh6J+fd+W+nThU=; b=mgi06RhGXq3E9rG2fNqcrqehPVYd+Xwc0+NiFAJGlKCXAUI9baDHhqmi0uDjjFR5wy xHDBxSrIkV/vzD+j5KTJBr92EHkRsBEUxV/krxvUw2s1HSCDxNPuC9+dUnSiRmbzsNC2 pW2XEX4Q+61vDnfwEaw1gL9x8SDezHV8JXheg8iTqPQJfbpsK+qJZBCpxBGjkNOiIApM 87pAV8pI+GYfRgTuK/hvRwrFfRmsOYUJpX/ZSjU1ofEDdXPUG9EurUW+/HpBgc2VP/U+ jZ98eA6BwYhNCso0b9oSAzlDBVUJz6xy3SLMgT6Gd8ryyjx4Mw6rKA3M0cqxnGrZ7cON mW1Q== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=iki.fi Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h4-v6si24422664pgc.429.2018.09.20.11.42.32; Thu, 20 Sep 2018 11:42:51 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=iki.fi Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388014AbeIUAZq (ORCPT + 99 others); Thu, 20 Sep 2018 20:25:46 -0400 Received: from nblzone-211-213.nblnetworks.fi ([83.145.211.213]:35184 "EHLO hillosipuli.retiisi.org.uk" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2387865AbeIUAZq (ORCPT ); Thu, 20 Sep 2018 20:25:46 -0400 Received: from valkosipuli.localdomain (valkosipuli.retiisi.org.uk [IPv6:2001:1bc8:1a6:d3d5::80:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by hillosipuli.retiisi.org.uk (Postfix) with ESMTPS id 4BF6F634C7F; Thu, 20 Sep 2018 21:40:55 +0300 (EEST) Received: from sakke by valkosipuli.localdomain with local (Exim 4.89) (envelope-from ) id 1g33sl-0000T4-1B; Thu, 20 Sep 2018 21:40:55 +0300 Date: Thu, 20 Sep 2018 21:40:54 +0300 From: Sakari Ailus To: Ricardo Ribalda Delgado Cc: Pavel Machek , Mauro Carvalho Chehab , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Hans Verkuil , Laurent Pinchart Subject: Re: [PATCH 2/4] [media] ad5820: Add support for enable pin Message-ID: <20180920184054.lbd77a3w56cflfym@valkosipuli.retiisi.org.uk> References: <20180920161912.17063-1-ricardo.ribalda@gmail.com> <20180920161912.17063-2-ricardo.ribalda@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180920161912.17063-2-ricardo.ribalda@gmail.com> User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Ricardo, Thanks for the set! A few comments below... On Thu, Sep 20, 2018 at 06:19:10PM +0200, Ricardo Ribalda Delgado wrote: > This patch adds support for a programmable enable pin. It can be used in > situations where the ANA-vcc is not configurable (dummy-regulator), or > just to have a more fine control of the power saving. > > The use of the enable pin is optional Missing period at the end of the sentence. > > Signed-off-by: Ricardo Ribalda Delgado > --- > drivers/media/i2c/Kconfig | 2 +- > drivers/media/i2c/ad5820.c | 20 ++++++++++++++++++++ > 2 files changed, 21 insertions(+), 1 deletion(-) > > diff --git a/drivers/media/i2c/Kconfig b/drivers/media/i2c/Kconfig > index bfdb494686bf..1ba6eaaf58fb 100644 > --- a/drivers/media/i2c/Kconfig > +++ b/drivers/media/i2c/Kconfig > @@ -321,7 +321,7 @@ config VIDEO_ML86V7667 > > config VIDEO_AD5820 > tristate "AD5820 lens voice coil support" > - depends on I2C && VIDEO_V4L2 && MEDIA_CONTROLLER > + depends on GPIOLIB && I2C && VIDEO_V4L2 && MEDIA_CONTROLLER > ---help--- > This is a driver for the AD5820 camera lens voice coil. > It is used for example in Nokia N900 (RX-51). > diff --git a/drivers/media/i2c/ad5820.c b/drivers/media/i2c/ad5820.c > index 22759aaa2dba..20931217e3b1 100644 > --- a/drivers/media/i2c/ad5820.c > +++ b/drivers/media/i2c/ad5820.c > @@ -27,6 +27,7 @@ > #include > #include > #include > +#include > > #include > #include > @@ -55,6 +56,8 @@ struct ad5820_device { > u32 focus_ramp_time; > u32 focus_ramp_mode; > > + struct gpio_desc *enable_gpio; > + > struct mutex power_lock; > int power_count; > > @@ -122,6 +125,9 @@ static int ad5820_power_off(struct ad5820_device *coil, bool standby) > ret = ad5820_update_hw(coil); > } > > + if (coil->enable_gpio) > + gpiod_set_value_cansleep(coil->enable_gpio, 0); gpiod_set_value_cansleep(), as I think most (or all?) similar functions, are happy with NULL gpio descriptor. You can thus drop the NULL check here and below. > + > ret2 = regulator_disable(coil->vana); > if (ret) > return ret; > @@ -136,6 +142,9 @@ static int ad5820_power_on(struct ad5820_device *coil, bool restore) > if (ret < 0) > return ret; > > + if (coil->enable_gpio) > + gpiod_set_value_cansleep(coil->enable_gpio, 1); > + > if (restore) { > /* Restore the hardware settings. */ > coil->standby = false; > @@ -146,6 +155,8 @@ static int ad5820_power_on(struct ad5820_device *coil, bool restore) > return 0; > > fail: > + if (coil->enable_gpio) > + gpiod_set_value_cansleep(coil->enable_gpio, 0); > coil->standby = true; > regulator_disable(coil->vana); > > @@ -312,6 +323,15 @@ static int ad5820_probe(struct i2c_client *client, > return ret; > } > > + coil->enable_gpio = devm_gpiod_get_optional(&client->dev, "enable", > + GPIOD_OUT_LOW); > + if (IS_ERR(coil->enable_gpio)) { > + ret = PTR_ERR(coil->enable_gpio); > + if (ret == -EPROBE_DEFER) > + dev_err(&client->dev, "could not get enable gpio\n"); > + return ret; > + } > + > mutex_init(&coil->power_lock); > > v4l2_i2c_subdev_init(&coil->subdev, client, &ad5820_ops); -- Regards, Sakari Ailus e-mail: sakari.ailus@iki.fi