From: Lars-Peter Clausen <lars@metafoo.de>
To: Jonathan Cameron <jic23@kernel.org>, Jyoti Bhayana <jbhayana@google.com>
Cc: Hartmut Knaack <knaack.h@gmx.de>,
Peter Meerwald-Stadler <pmeerw@pmeerw.net>,
Mauro Carvalho Chehab <mchehab+huawei@kernel.org>,
"David S. Miller" <davem@davemloft.net>,
Rob Herring <robh@kernel.org>,
Lukas Bulwahn <lukas.bulwahn@gmail.com>,
linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org,
cristian.marussi@arm.com, sudeep.holla@arm.com,
egranata@google.com, mikhail.golubev@opensynergy.com,
Igor.Skalkin@opensynergy.com, Peter.hilber@opensynergy.com,
ankitarora@google.com
Subject: Re: [RFC PATCH v2 1/1] iio/scmi: Adding support for IIO SCMI Based Sensors
Date: Wed, 30 Dec 2020 17:09:54 +0100 [thread overview]
Message-ID: <220be27a-8eef-8582-9a8c-270f16fda688@metafoo.de> (raw)
In-Reply-To: <20201230134104.48d07ff5@archlinux>
On 12/30/20 2:41 PM, Jonathan Cameron wrote:
> On Thu, 24 Dec 2020 03:19:21 +0000
> Jyoti Bhayana <jbhayana@google.com> wrote:
>
>> + /*
>> + * The seconds field in the sensor interval in SCMI is 16 bits long
>> + * Therefore seconds = 1/Hz <= 0xFFFF. As floating point calculations are
>> + * discouraged in the kernel driver code, to calculate the scale factor (sf)
>> + * (1* 1000000 * sf)/uHz <= 0xFFFF. Therefore, sf <= (uHz * 0xFFFF)/1000000
>> + * To calculate the multiplier,we convert the sf into char string and
>> + * count the number of characters
>> + */
>> +
>> + mult = scnprintf(buf, 32, "%llu", ((u64)uHz * 0xFFFF) / UHZ_PER_HZ) - 1;
> use sizeof(buf) instead of having 32 again.
>
Since this is just interested in the number of characters and not the
string itself I believe it is possible to just call sprintf with NULL
instead of a buffer. It will then still return the number of characters,
but not print anything.
But maybe providing a ilog10() helper is the better approach.
next prev parent reply other threads:[~2020-12-30 16:11 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-24 3:19 [RFC PATCH v2 0/1] Adding support for IIO SCMI based sensors Jyoti Bhayana
2020-12-24 3:19 ` [RFC PATCH v2 1/1] iio/scmi: Adding support for IIO SCMI Based Sensors Jyoti Bhayana
2020-12-30 13:41 ` Jonathan Cameron
2020-12-30 16:09 ` Lars-Peter Clausen [this message]
2020-12-30 12:37 ` [RFC PATCH v2 0/1] Adding support for IIO SCMI based sensors Jonathan Cameron
2021-01-05 23:09 ` Reply to " Jyoti Bhayana
2021-01-06 10:29 ` Jonathan Cameron
2021-01-06 11:26 ` Cristian Marussi
2021-01-06 14:36 ` Jonathan Cameron
2021-01-06 16:12 ` Cristian Marussi
2021-01-06 21:23 ` Jyoti Bhayana
2021-01-09 19:01 ` Jonathan Cameron
2021-01-11 6:44 ` Jyoti Bhayana
2021-01-11 12:33 ` Jonathan Cameron
2021-01-11 21:17 ` Jyoti Bhayana
2021-01-16 19:33 ` Jonathan Cameron
2021-01-17 7:15 ` Jyoti Bhayana
2021-01-17 11:56 ` Jonathan Cameron
2021-01-17 21:02 ` Jyoti Bhayana
2021-01-18 13:42 ` 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=220be27a-8eef-8582-9a8c-270f16fda688@metafoo.de \
--to=lars@metafoo.de \
--cc=Igor.Skalkin@opensynergy.com \
--cc=Peter.hilber@opensynergy.com \
--cc=ankitarora@google.com \
--cc=cristian.marussi@arm.com \
--cc=davem@davemloft.net \
--cc=egranata@google.com \
--cc=jbhayana@google.com \
--cc=jic23@kernel.org \
--cc=knaack.h@gmx.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lukas.bulwahn@gmail.com \
--cc=mchehab+huawei@kernel.org \
--cc=mikhail.golubev@opensynergy.com \
--cc=pmeerw@pmeerw.net \
--cc=robh@kernel.org \
--cc=sudeep.holla@arm.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;
as well as URLs for NNTP newsgroup(s).