mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Andreas Klinger <ak@it-klinger.de>
Cc: "Jaakko Koivisto" <jmatko@utu.fi>,
	"David Lechner" <dlechner@baylibre.com>,
	"Nuno Sá" <nuno.sa@analog.com>,
	"Andy Shevchenko" <andy@kernel.org>,
	linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 3/3] iio: chemical: sgp40: Implement turn_heater_off-command
Date: Sun, 20 Sep 2026 18:52:01 +0100	[thread overview]
Message-ID: <20260920185201.5a25dc05@jic23-hlaptop> (raw)
In-Reply-To: <aq3LDTnLuJm6vjFt@mail.your-server.de>

On Sat, 19 Sep 2026 01:36:45 +0200
Andreas Klinger <ak@it-klinger.de> wrote:

> Hi Jaakko,
> 
> Jaakko Koivisto <jmatko@utu.fi> schrieb am Fr, 18. Sep 16:40:
> > -Turn the heating element off and enter idle mode.
> > -Present the functionality as device attribute,
> >  'echo 1 > turn_heater_off'.  
> 
> Instead of introducing a device specific attribute couldn't this be implemented
> as standard power management operations (RUNTIME_PM_OPS)?

May not apply in this case but normally the warm up time of these sorts of
heaters are in the seconds.  No one wants that latency when they want
a measurement.  As such normal runtime pm doesn't work - it needs to
be a specific userspace opt in.

We have defined ABI for this though and this isn't it
See Documentation/ABI/testing/sysfs-bus-iio (and more in -humidity)

Jonathan

> 
> Andreas
> 
> > Saves approx. 2.5 mA compared to regular operation. The heating element
> > is automatically turned back on when measurement is performed.
> > 
> > Signed-off-by: Jaakko Koivisto <jmatko@utu.fi>
> > ---
> >  drivers/iio/chemical/sgp40.c | 28 ++++++++++++++++++++++++++++
> >  1 file changed, 28 insertions(+)
> > 
> > diff --git a/drivers/iio/chemical/sgp40.c b/drivers/iio/chemical/sgp40.c
> > index 28d5e737d1dc..a4fc5c778303 100644
> > --- a/drivers/iio/chemical/sgp40.c
> > +++ b/drivers/iio/chemical/sgp40.c
> > @@ -29,6 +29,7 @@
> >   * by writing to the out values of temp and humidityrelative.
> >   */
> >  
> > +#include "linux/device.h"
> >  #include <linux/delay.h>
> >  #include <linux/crc8.h>
> >  #include <linux/module.h>
> > @@ -259,6 +260,21 @@ static int sgp40_execute_self_test(struct sgp40_data *data)
> >  	}
> >  }
> >  
> > +static int sgp40_turn_heater_off(struct sgp40_data *data)
> > +{
> > +	int ret;
> > +	struct i2c_client *client = data->client;
> > +	struct sgp40_command turn_off = {.command = {0x36, 0x15}};
> > +
> > +	ret = i2c_master_send(client, (char*)&turn_off, sizeof(turn_off.command));
> > +	if (ret != sizeof(turn_off.command)) {
> > +		dev_err(data->dev, "i2c_master_send ret: %d, expected %zu", ret, sizeof(turn_off.command));
> > +		return -EIO;
> > +	}
> > +	msleep(1);
> > +	return 0;
> > +}
> > +
> >  static int sgp40_measure_resistance_raw(struct sgp40_data *data, u16 *resistance_raw)
> >  {
> >  	int ret;
> > @@ -417,10 +433,22 @@ static ssize_t serial_number_show(struct device *dev,
> >  	return sysfs_emit_at(buf, 0, "%llu\n", data->serial_number);
> >  }
> >  
> > +static ssize_t turn_heater_off_store(struct device *dev,
> > +				     struct device_attribute *attr,
> > +				     const char *buf, size_t len)
> > +{
> > +	struct sgp40_data *data = iio_priv(dev_to_iio_dev(dev));
> > +	sgp40_turn_heater_off(data);
> > +
> > +	return len;
> > +}
> > +
> >  static IIO_DEVICE_ATTR_RO(serial_number, 0);
> > +static IIO_DEVICE_ATTR_WO(turn_heater_off, 0);
> >  
> >  static struct attribute *sgp40_attributes[] = {
> >  	&iio_dev_attr_serial_number.dev_attr.attr,
> > +	&iio_dev_attr_turn_heater_off.dev_attr.attr,
> >  	NULL
> >  };
> >  
> > -- 
> > 2.55.0
> >   
> 


  reply	other threads:[~2026-09-20 17:52 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-18 13:40 [PATCH 0/3] iio: chemical: sgp40: Add secondary chip functionality Jaakko Koivisto
2026-09-18 13:40 ` [PATCH 1/3] iio: chemical: sgp40: Implement get_serial_number-command Jaakko Koivisto
2026-09-18 14:26   ` Maxwell Doose
2026-09-19 14:09   ` Andy Shevchenko
2026-09-18 13:40 ` [PATCH 2/3] iio: chemical: sgp40: Implement execute_self_test-command Jaakko Koivisto
2026-09-20 17:48   ` Jonathan Cameron
2026-09-18 13:40 ` [PATCH 3/3] iio: chemical: sgp40: Implement turn_heater_off-command Jaakko Koivisto
2026-09-18 23:36   ` Andreas Klinger
2026-09-20 17:52     ` Jonathan Cameron [this message]
2026-09-20 17:53 ` [PATCH 0/3] iio: chemical: sgp40: Add secondary chip functionality Jonathan Cameron

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260920185201.5a25dc05@jic23-hlaptop \
    --to=jic23@kernel.org \
    --cc=ak@it-klinger.de \
    --cc=andy@kernel.org \
    --cc=dlechner@baylibre.com \
    --cc=jmatko@utu.fi \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nuno.sa@analog.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®