public inbox for linux-iio@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/9] bitfield: add FIELD_GET_SIGNED()
@ 2026-04-17 17:36 Yury Norov
  2026-04-17 17:36 ` [PATCH 1/9] " Yury Norov
                   ` (9 more replies)
  0 siblings, 10 replies; 15+ messages in thread
From: Yury Norov @ 2026-04-17 17:36 UTC (permalink / raw)
  To: Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
	H. Peter Anvin, Andy Lutomirski, Peter Zijlstra, Jonathan Cameron,
	David Lechner, Nuno Sá, Andy Shevchenko, Ping-Ke Shih,
	Richard Cochran, Andrew Lunn, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Alexandre Belloni, Yury Norov,
	Rasmus Villemoes, Hans de Goede, Linus Walleij, Sakari Ailus,
	Salah Triki, Achim Gratz, Ben Collins, linux-kernel, linux-iio,
	linux-wireless, netdev, linux-rtc
  Cc: Yury Norov

The bitfields are designed in assumption that fields contain unsigned
integer values, thus extracting the values from the field implies
zero-extending.

Some drivers need to sign-extend their fields, and currently do it like:

	dc_re += sign_extend32(FIELD_GET(0xfff000, tmp), 11);
	dc_im += sign_extend32(FIELD_GET(0xfff, tmp), 11);

It's error-prone because it relies on user to provide the correct
index of the most significant bit.

This series adds a signed version of FIELD_GET(), which is the more
convenient and compiles (on x86_64) to just a couple instructions:
shl and sar.

Patch #1 adds FIELD_GET_SIGNED(), and the rest of the series applies it
tree-wide.

Yury Norov (9):
  bitfield: add FIELD_GET_SIGNED()
  x86/extable: switch to using FIELD_GET_SIGNED()
  iio: intel_dc_ti_adc: switch to using
  iio: magnetometer: yas530: switch to using FIELD_GET_SIGNED()
  iio: pressure: bmp280: switch to using
  iio: mcp9600: switch to using FIELD_GET_SIGNED()
  wifi: rtw89: switch to using FIELD_GET_SIGNED()
  rtc: rv3032: switch to using FIELD_GET_SIGNED()
  ptp: switch to using FIELD_GET_SIGNED()

 arch/x86/include/asm/extable_fixup_types.h       | 13 ++++---------
 arch/x86/mm/extable.c                            |  2 +-
 drivers/iio/adc/intel_dc_ti_adc.c                |  4 ++--
 drivers/iio/magnetometer/yamaha-yas530.c         | 12 ++++++------
 drivers/iio/pressure/bmp280-core.c               |  2 +-
 drivers/iio/temperature/mcp9600.c                |  2 +-
 .../net/wireless/realtek/rtw89/rtw8852a_rfk.c    |  4 ++--
 .../net/wireless/realtek/rtw89/rtw8852b_common.c |  4 ++--
 .../net/wireless/realtek/rtw89/rtw8852b_rfk.c    |  4 ++--
 drivers/net/wireless/realtek/rtw89/rtw8852c.c    |  4 ++--
 drivers/ptp/ptp_fc3.c                            |  4 ++--
 drivers/rtc/rtc-rv3032.c                         |  2 +-
 include/linux/bitfield.h                         | 16 ++++++++++++++++
 13 files changed, 42 insertions(+), 31 deletions(-)

-- 
2.51.0


^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2026-04-17 21:09 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-17 17:36 [PATCH 0/9] bitfield: add FIELD_GET_SIGNED() Yury Norov
2026-04-17 17:36 ` [PATCH 1/9] " Yury Norov
2026-04-17 18:12   ` Andy Shevchenko
2026-04-17 19:43   ` David Laight
2026-04-17 21:09     ` Yury Norov
2026-04-17 17:36 ` [PATCH 2/9] x86/extable: switch to using FIELD_GET_SIGNED() Yury Norov
2026-04-17 17:36 ` [PATCH 3/9] iio: intel_dc_ti_adc: " Yury Norov
2026-04-17 17:36 ` [PATCH 4/9] iio: magnetometer: yas530: " Yury Norov
2026-04-17 17:36 ` [PATCH 5/9] iio: pressure: bmp280: " Yury Norov
2026-04-17 17:36 ` [PATCH 6/9] iio: mcp9600: " Yury Norov
2026-04-17 17:36 ` [PATCH 7/9] wifi: rtw89: " Yury Norov
2026-04-17 17:36 ` [PATCH 8/9] rtc: rv3032: " Yury Norov
2026-04-17 17:36 ` [PATCH 9/9] ptp: " Yury Norov
2026-04-17 18:23 ` [PATCH 0/9] bitfield: add FIELD_GET_SIGNED() Andy Shevchenko
2026-04-17 19:21   ` Yury Norov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox