mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jaakko Koivisto <jmatko@utu.fi>
To: Andy Shevchenko <andriy.shevchenko@intel.com>,
	Jaakko Koivisto <jmatko@utu.fi>
Cc: "Andreas Klinger" <ak@it-klinger.de>,
	"Jonathan Cameron" <jic23@kernel.org>,
	"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 1/3] iio: chemical: sgp40: Implement get_serial_number-command
Date: Thu, 24 Sep 2026 11:31:32 +0300	[thread overview]
Message-ID: <DLNENHM2KZMM.1IXMNOM1FL17W@utu.fi> (raw)
In-Reply-To: <aq6XtHY6Yp-qyg5f@ashevche-desk.local>

On Sat Sep 19, 2026 at 5:09 PM EEST, Andy Shevchenko wrote:
> On Fri, Sep 18, 2026 at 04:40:17PM +0300, Jaakko Koivisto wrote:
>> -Retrieve the chip serial number.
>> -Present the serial number to userspace as device attribute.
>> -Rename the tg_measure -struct now that is is used for multiple
>> commands.
>
> ...
>
>> +	ret = i2c_master_send(client, (char*)&get_sn, sizeof(get_sn.command));
>> +	if (ret != sizeof(get_sn.command)) {
>> +		dev_err(data->dev, "i2c_master_send ret: %d, expected %zu", ret, sizeof(get_sn.command));
>> +		return -EIO;
>> +	}
>> +	msleep(1);
>
> Explain this sleep.

It is the maximum time it takes for the chip to execute the command.
I'll add a comment describing it.

In testing this command works if the sleep is omitted, but I would leave
it here anyway to be sure we don't try to read the result before the
chip is ready.

>> +	ret = i2c_master_recv(client, (char*)&res, sizeof(res));
>> +	if (ret < 0)
>> +		return ret;
>> +	if (ret != sizeof(res)) {
>> +		dev_err(data->dev, "i2c_master_recv ret: %d, expected: %zu", ret, sizeof(res));
>> +		return -EIO;
>> +	}
>> +
>> +	if (crc8(sgp40_crc8_table, (u8*)&res.A, 2, SGP40_CRC8_INIT) != res.A_crc ||
>> +	    crc8(sgp40_crc8_table, (u8*)&res.B, 2, SGP40_CRC8_INIT) != res.B_crc ||
>> +	    crc8(sgp40_crc8_table, (u8*)&res.C, 2, SGP40_CRC8_INIT) != res.C_crc)
>> +	{
>> +		dev_warn(data->dev, "CRC error in get_serial_number");
>> +	}
>> +
>> +	data->serial_number = 0LL | ((u64)be16_to_cpu(res.A) << 32) | ((u64)be16_to_cpu(res.B) << 16) | (u64)be16_to_cpu(res.C);
>
> 0LL ?!
>

I have no excuse for this. Both unnecessary and for u64 should have been
LLU. I will remove it.

>> +	dev_dbg(data->dev, "serial number: %llu", data->serial_number);
>
> Why?!
>

You are right, not really debug information. Will remove.

>
> ...
>
>> -	struct sgp40_tg_measure tg = {.command = {0x26, 0x0F}};
>> +	struct sgp40_command tg = {.command = {0x26, 0x0F}};
>
> While at it, add more spaces.
>

Thanks, I'll fix this and other formatting mistakes.

> ...
>
>> +}
>> +
>
> Unneeded blank line.
>
>> +static IIO_DEVICE_ATTR_RO(serial_number, 0);
>> +
>> +static struct attribute *sgp40_attributes[] = {
>> +	&iio_dev_attr_serial_number.dev_attr.attr,
>> +	NULL
>> +};
>> +
>> +static struct attribute_group sgp40_attribute_group = {
>> +	.attrs = sgp40_attributes,
>> +};
>> +
>> +
>
> Single blank line is enough and we have ATTRIBUTE_GROUPS().
>

Is using ATTRIBUTE_GROUPS() valid here? ATTRIBUTE_GROUPS(sgp40) will
create both attribute_group sgp40_group and
attribute_group *sgp40_groups[], and we only need the first one for iio_info.
The extra *sgp40_groups[] will create unused variable -warning.

  reply	other threads:[~2026-09-24  8:32 UTC|newest]

Thread overview: 16+ 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-24  8:58     ` Jaakko Koivisto
2026-09-19 14:09   ` Andy Shevchenko
2026-09-24  8:31     ` Jaakko Koivisto [this message]
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-24  8:16     ` Jaakko Koivisto
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
2026-09-24  8:04       ` Jaakko Koivisto
2026-09-25  0:42         ` Jonathan Cameron
2026-09-20 17:53 ` [PATCH 0/3] iio: chemical: sgp40: Add secondary chip functionality Jonathan Cameron
2026-09-24  7:54   ` Jaakko Koivisto

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=DLNENHM2KZMM.1IXMNOM1FL17W@utu.fi \
    --to=jmatko@utu.fi \
    --cc=ak@it-klinger.de \
    --cc=andriy.shevchenko@intel.com \
    --cc=andy@kernel.org \
    --cc=dlechner@baylibre.com \
    --cc=jic23@kernel.org \
    --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®