From: Jonathan Cameron <jic23@kernel.org>
To: Matti Vaittinen <mazziesaccount@gmail.com>
Cc: Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>,
Lars-Peter Clausen <lars@metafoo.de>,
Rob Herring <robh+dt@kernel.org>,
Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
Conor Dooley <conor+dt@kernel.org>,
Angel Iglesias <ang.iglesiasg@gmail.com>,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
Andreas Klinger <ak@it-klinger.de>,
linux-iio@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/3] iio: pressure: Support ROHM BU1390
Date: Fri, 8 Sep 2023 19:45:09 +0100 [thread overview]
Message-ID: <20230908194509.6a4f4adc@jic23-huawei> (raw)
In-Reply-To: <08f7085ba1af2fae21c942f6c20a94c237df53ba.1694001462.git.mazziesaccount@gmail.com>
> +static int bm1390_read_temp(struct bm1390_data *data, int *temp)
> +{
> + u8 temp_reg[2] __aligned(2);
> + __be16 *temp_raw;
> + int ret;
> + s16 val;
> + bool negative;
> +
> + ret = regmap_bulk_read(data->regmap, BM1390_REG_TEMP_HI, &temp_reg,
> + sizeof(temp_reg));
> + if (ret)
> + return ret;
> +
> + if (temp_reg[0] & 0x80)
> + negative = true;
> + else
> + negative = false;
> +
> + temp_raw = (__be16 *)&temp_reg[0];
> + val = be16_to_cpu(*temp_raw);
> +
> + if (negative) {
> + /*
> + * Two's complement. I am not sure if all supported
> + * architectures actually use 2's complement represantation of
AFAIK they do. Many IIO drivers would be broken if not..
> + * signed ints. If yes, then we could just do the endianes
> + * conversion and say this is the s16 value. However, as I
> + * don't know, and as the conversion is pretty simple. let's
> + * just convert the signed 2's complement to absolute value and
> + * multiply by -1.
> + */
> + val = ~val + 1;
> + val *= -1;
> + }
> +
> + *temp = val;
> +
> + return 0;
> +}
next prev parent reply other threads:[~2023-09-08 18:53 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-06 12:36 [PATCH 0/3] Support ROHM BM1390 pressure sensor Matti Vaittinen
2023-09-06 12:37 ` [PATCH 1/3] dt-bindings: Add " Matti Vaittinen
2023-09-07 10:08 ` Conor Dooley
2023-09-08 5:10 ` Matti Vaittinen
2023-09-08 7:14 ` Benjamin Bara
2023-09-08 7:18 ` Matti Vaittinen
2023-09-06 12:37 ` [PATCH 2/3] iio: pressure: Support ROHM BU1390 Matti Vaittinen
2023-09-06 15:48 ` Andy Shevchenko
2023-09-07 5:57 ` Matti Vaittinen
2023-09-07 13:57 ` Andy Shevchenko
2023-09-08 6:12 ` Matti Vaittinen
2023-09-08 18:44 ` Jonathan Cameron
2023-09-11 5:32 ` Matti Vaittinen
2023-09-08 6:24 ` Matti Vaittinen
2023-09-08 18:33 ` Jonathan Cameron
2023-09-08 18:45 ` Jonathan Cameron [this message]
2023-09-11 5:15 ` Matti Vaittinen
2023-09-10 13:22 ` Jonathan Cameron
2023-09-11 10:40 ` Matti Vaittinen
2023-09-12 14:38 ` Jonathan Cameron
2023-09-14 11:47 ` Matti Vaittinen
2023-09-17 9:26 ` Jonathan Cameron
2023-09-18 11:42 ` Matti Vaittinen
2023-09-06 12:40 ` [PATCH 3/3] MAINTAINERS: Add ROHM BM1390 Matti Vaittinen
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=20230908194509.6a4f4adc@jic23-huawei \
--to=jic23@kernel.org \
--cc=ak@it-klinger.de \
--cc=andriy.shevchenko@linux.intel.com \
--cc=ang.iglesiasg@gmail.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=krzysztof.kozlowski+dt@linaro.org \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=matti.vaittinen@fi.rohmeurope.com \
--cc=mazziesaccount@gmail.com \
--cc=robh+dt@kernel.org \
/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