Linux-IIO Archive mirror
 help / color / mirror / Atom feed
From: "Otávio Silva" <otavio.ols@usp.br>
To: jic23@kernel.org
Cc: "Otávio Silva" <otavio.ols@usp.br>,
	"Thiago Duvanel" <thiago.duvanel@usp.br>,
	"Felipe Aníbal Brito" <felipeanibal@usp.br>,
	linux-iio@vger.kernel.org
Subject: [PATCH] iio: adc: use sign_extend32 to provide negative numbers conversion
Date: Sat, 20 Apr 2024 20:34:11 -0300	[thread overview]
Message-ID: <20240420233836.24971-1-otavio.ols@usp.br> (raw)

This implements the use of the sign_extend32 function to handle the output
of negative numbers.

Co-developed-by: Thiago Duvanel <thiago.duvanel@usp.br>
Signed-off-by: Thiago Duvanel <thiago.duvanel@usp.br>
Co-developed-by: Felipe Aníbal Brito <felipeanibal@usp.br>
Signed-off-by: Felipe Aníbal Brito <felipeanibal@usp.br>
Signed-off-by: Otávio Silva <otavio.ols@usp.br>
---
 drivers/iio/adc/ltc2309.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/iio/adc/ltc2309.c b/drivers/iio/adc/ltc2309.c
index 8b3a89c1b..cb93dbc94 100644
--- a/drivers/iio/adc/ltc2309.c
+++ b/drivers/iio/adc/ltc2309.c
@@ -124,7 +124,7 @@ static int ltc2309_read_raw_channel(struct ltc2309 *ltc2309,
 		return ret;
 	}
 
-	*val = be16_to_cpu(buf) >> 4;
+	*val = sign_extend32(be16_to_cpu(buf) >> 4, 11);
 
 	return ret;
 }
-- 
2.44.0


             reply	other threads:[~2024-04-20 23:39 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-20 23:34 Otávio Silva [this message]
2024-04-21 17:38 ` [PATCH] iio: adc: use sign_extend32 to provide negative numbers conversion Jonathan Cameron
2024-04-28  2:02   ` Otávio Silva

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=20240420233836.24971-1-otavio.ols@usp.br \
    --to=otavio.ols@usp.br \
    --cc=felipeanibal@usp.br \
    --cc=jic23@kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=thiago.duvanel@usp.br \
    /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 read-only IMAP folder(s) and NNTP newsgroup(s).