Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp557135ybl; Wed, 29 Jan 2020 05:37:35 -0800 (PST) X-Google-Smtp-Source: APXvYqwUvKkwpYwEcR5wutCzzx1ifgId3W0X/rB63dF/I6Qg+P2GJEbyVGGmHpINwP9/DdHmv5PZ X-Received: by 2002:a05:6808:aac:: with SMTP id r12mr6384637oij.59.1580305055304; Wed, 29 Jan 2020 05:37:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580305055; cv=none; d=google.com; s=arc-20160816; b=sB4zZ1MOXS3hPYY4AVce2VSMAWsuvunOOQLRpgn5NH5PUGbAWQ/u/qEu0gTC/R5aJz sUgBaY8xLLjfnzCO0MluhfOABuN0oMg2P6nBrVfv/zrFj4ZgHB1VwTKaWsw3Suf2aiIG 5QcYE8g/kZ7cYHCr0QTwWoHqXfO2sMq9RgzbGP1guL6zGz4qb0nJWY7K34pkGjW2M+F8 sgbcHRiTrql2BZFF3BDRGGmqUUw21JPDPfT4Ct1If4kzgLAXe2tj5bAnN9HiQl2AwbEW UucaoT/C5ldNG6lg+caakPueGg3Hz785qj1YMFpKaBSAS+H7XhhNO083uQyiZ1I9WXd9 yyJQ== 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=3V6xmU3srA+se3hcicm5DWexrikGI8dUa+mXdjGXknk=; b=z3UMp4VQXeLkMR5zPbYykU9eANDebyCSad0nA//0qUP5cawrQenTi9gY726euqzREX 0S6NZju1fa2rjxPLQ96WPacW/0JpLam47oua0oBwymjrD67SJgVScIsF7GSm2HZBg3Ah Qt+SeXuh9D54L5k2WG96+luTyw/Hvqk/Gb6brVY1sYJ0gmsJGTOk4f6+2kbk8sAxkGwD TfikPOGQjyzZmHANMS3AhC37a/pW3UG7p0j0MTlKptnxImwWfel6rwx2YnuA9jph8am/ INUqGal+2j+udrUPoBkQ5OCPAFuH0w4a6zLh1WI+/IRnzobg0fPj6KQ3jpkJZsPvN1ML JMsQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=DyOBHrHd; 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 e9si1077328otk.318.2020.01.29.05.37.22; Wed, 29 Jan 2020 05:37:35 -0800 (PST) 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=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=DyOBHrHd; 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 S1726558AbgA2Ng3 (ORCPT + 99 others); Wed, 29 Jan 2020 08:36:29 -0500 Received: from mail-qk1-f194.google.com ([209.85.222.194]:37385 "EHLO mail-qk1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726178AbgA2Ng3 (ORCPT ); Wed, 29 Jan 2020 08:36:29 -0500 Received: by mail-qk1-f194.google.com with SMTP id 21so17011118qky.4 for ; Wed, 29 Jan 2020 05:36:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=3V6xmU3srA+se3hcicm5DWexrikGI8dUa+mXdjGXknk=; b=DyOBHrHd5BqYv9mIpfnW6WvCaFIoyTvOEgcISOB4GhL5+pTjagzqJtDyYV4OMewGZ2 /pUGtZS5H5oenY9pX4V6gr2QbSvxuggpRlAuWiOkkHKlVM1+zQnHPwM3ho3X+99G1Md5 71XUsAe+Uf/jdIjjfRUaluv+2kcnKl9hLaP2XvT8ynLxvYww5N0KZgG8LhXkhkR+HCpn SUsIoVrzHW4Drw01pRZ1fWTcGuWSpnq1VFkwinajQMSqa0aaxivhMhVtbETM4z13n3cp +uI3Ew5pFrK5TvwOPFJNhwkZWx6/xa6EvnCOJTG8sa4ndrJq8dFdyLwXsO0IRFI/A0ZF Jt/g== 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=3V6xmU3srA+se3hcicm5DWexrikGI8dUa+mXdjGXknk=; b=RTCY5LbGtGdjMQTfbWEbokwiV5gsKs9bisg6vLwI2qkjvERRxH8sPN1BWtN+B4hsg7 H8btgdZcwibxndXsrXXRltMEIUxhTiyl++l1fzjYDwM9wRIS0C09nfg24sqMdMZWuxUt Haalhh4Bi2w5QMna1xrT/bYFhWMipFMpmBYgvhQTWM9BXEZni5LjSRUs4+1OpZgIAuMX zLygIgGo3peDmqNgGPo/h1KGZ29JPjBYnuL3lRWAA/oEE2Ufct6faOVqgsW+l3GK/5Es jL0rNm11ODVUB26bSe1pCPFDWCKIuH/s0GdWadzYrIh1IlZnEm25A1zllgB04pRjVrgE 1LDw== X-Gm-Message-State: APjAAAU9tj9ALZKvg2MyVvOf04Lfl+YmkHVymh77OPDWxHqLJ/7LKNgc Cr7czpSwKG8duOocEWKldw1blXwKujTxKbVDvsnO1w== X-Received: by 2002:a37:4808:: with SMTP id v8mr25569122qka.263.1580304988349; Wed, 29 Jan 2020 05:36:28 -0800 (PST) MIME-Version: 1.0 References: <20200121134157.20396-1-sakari.ailus@linux.intel.com> <20200121134157.20396-6-sakari.ailus@linux.intel.com> In-Reply-To: <20200121134157.20396-6-sakari.ailus@linux.intel.com> From: Bartosz Golaszewski Date: Wed, 29 Jan 2020 14:36:17 +0100 Message-ID: Subject: Re: [PATCH v4 5/6] at24: Support probing while off To: Sakari Ailus Cc: linux-i2c , Wolfram Sang , "Rafael J. Wysocki" , linux-acpi@vger.kernel.org, Bingbu Cao , linux-media , Chiranjeevi Rapolu , Hyungwoo Yang , Arnd Bergmann , LKML , Greg Kroah-Hartman , rajmohan.mani@intel.com, Tomasz Figa 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 wt., 21 sty 2020 o 14:41 Sakari Ailus napisa= =C5=82(a): > > In certain use cases (where the chip is part of a camera module, and the > camera module is wired together with a camera privacy LED), powering on > the device during probe is undesirable. Add support for the at24 to > execute probe while being powered off. For this to happen, a hint in form > of a device property is required from the firmware. > > Signed-off-by: Sakari Ailus > --- > drivers/misc/eeprom/at24.c | 31 +++++++++++++++++++++---------- > 1 file changed, 21 insertions(+), 10 deletions(-) > > diff --git a/drivers/misc/eeprom/at24.c b/drivers/misc/eeprom/at24.c > index 0681d5fdd538a..5fc1162b67618 100644 > --- a/drivers/misc/eeprom/at24.c > +++ b/drivers/misc/eeprom/at24.c > @@ -564,6 +564,7 @@ static int at24_probe(struct i2c_client *client) > bool i2c_fn_i2c, i2c_fn_block; > unsigned int i, num_addresses; > struct at24_data *at24; > + bool low_power; > struct regmap *regmap; > bool writable; > u8 test_byte; > @@ -701,19 +702,24 @@ static int at24_probe(struct i2c_client *client) > > i2c_set_clientdata(client, at24); > > - /* enable runtime pm */ > - pm_runtime_set_active(dev); > + low_power =3D acpi_dev_state_low_power(&client->dev); > + if (!low_power) > + pm_runtime_set_active(dev); > + > pm_runtime_enable(dev); > > /* > - * Perform a one-byte test read to verify that the > - * chip is functional. > + * Perform a one-byte test read to verify that the chip is functi= onal, > + * unless powering on the device is to be avoided during probe (i= .e. > + * it's powered off right now). > */ > - err =3D at24_read(at24, 0, &test_byte, 1); > - pm_runtime_idle(dev); > - if (err) { > - pm_runtime_disable(dev); > - return -ENODEV; > + if (!low_power) { > + err =3D at24_read(at24, 0, &test_byte, 1); > + pm_runtime_idle(dev); > + if (err) { > + pm_runtime_disable(dev); > + return -ENODEV; > + } > } > > if (writable) > @@ -728,8 +734,12 @@ static int at24_probe(struct i2c_client *client) > > static int at24_remove(struct i2c_client *client) > { > + bool low_power; > + > pm_runtime_disable(&client->dev); > - pm_runtime_set_suspended(&client->dev); > + low_power =3D acpi_dev_state_low_power(&client->dev); This is inconsistent. You define the low_power field in the context structure (BTW the name low_power is a bit vague here - without looking at its assignment it would make me think it's about something battery-related, how about 'off_at_probe'?) and instead of reusing this field here, you call acpi_dev_state_low_power() again. Either don't store the context for the life-time of the device if not necessary or don't call acpi_dev_state_low_power() at remove, although the commit message doesn't describe whether the latter is done on purpose. Bartosz > + if (!low_power) > + pm_runtime_set_suspended(&client->dev); > > return 0; > } > @@ -743,6 +753,7 @@ static struct i2c_driver at24_driver =3D { > .probe_new =3D at24_probe, > .remove =3D at24_remove, > .id_table =3D at24_ids, > + .probe_low_power =3D true, > }; > > static int __init at24_init(void) > -- > 2.20.1 >