public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/4] Refactor 104-quad-8 to match device operations
@ 2023-03-18 14:59 William Breathitt Gray
  2023-03-18 14:59 ` [PATCH 1/4] counter: 104-quad-8: Utilize bitfield access macros William Breathitt Gray
                   ` (3 more replies)
  0 siblings, 4 replies; 13+ messages in thread
From: William Breathitt Gray @ 2023-03-18 14:59 UTC (permalink / raw)
  To: linux-iio
  Cc: Johannes Berg, Jonathan Cameron, Andy Shevchenko, Andrew Morton,
	linux-kernel, William Breathitt Gray

The 104-quad-8 driver was initially introduced to the IIO subsystem
where it didn't quite fit with the existing paradigm [0]; these
differences eventually led to the creation of the Counter subsystem[1].
As a result of its awkward beginnings, the design of the 104-quad-8
driver was structured around maintaining abstract state buffers that
would eventually be converted to match the actual device registers
states on-the-fly as needed.

The original design approach for the 104-quad-8 driver was neither
efficient nor easy to troubleshoot, but it did allow us to focus on
implementing and supporting necessary APIs for the nascent Counter
subsystem. Now that development for the 104-quad-8 driver has shifted
to maintenance, it is a good time to refactor and clean up the code to
match closer to what is actually happening on the device. This patchset
is an attempt to rectify the situation as such.

The primary change is a transition from maintaining individual
configuration states independently, to storing buffers of the device
register configurations. To that end, the bitfield API is leveraged to
access and retrieve field states. Modifying bitfields is a common code
pattern so a FIELD_MODIFY macro is introduced to facililate such.
Finally some helper functions are introduced to abstract the handling of
the PR, FLAG, and PSC registers.

Modifying a buffer state in-place is a common pattern, so should we also
consider adding a field_replace() function similar to bitmap_replace()?

[0] https://lore.kernel.org/r/b43e2942b763b87afc85bfa9fe36e5695cba4c44.1475079578.git.vilhelm.gray@gmail.com/
[1] https://lore.kernel.org/r/cover.1554184734.git.vilhelm.gray@gmail.com/

William Breathitt Gray (4):
  counter: 104-quad-8: Utilize bitfield access macros
  bitfield: Introduce the FIELD_MODIFY() macro
  counter: 104-quad-8: Refactor to buffer states for CMR, IOR, and IDR
  counter: 104-quad-8: Utilize helper functions to handle PR, FLAG and
    PSC

 drivers/counter/104-quad-8.c | 526 ++++++++++++++++++-----------------
 include/linux/bitfield.h     |  18 +-
 2 files changed, 283 insertions(+), 261 deletions(-)


base-commit: 00f4bc5184c19cb33f468f1ea409d70d19f8f502
-- 
2.39.2


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

end of thread, other threads:[~2023-03-20 17:07 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-03-18 14:59 [PATCH 0/4] Refactor 104-quad-8 to match device operations William Breathitt Gray
2023-03-18 14:59 ` [PATCH 1/4] counter: 104-quad-8: Utilize bitfield access macros William Breathitt Gray
2023-03-18 14:59 ` [PATCH 2/4] bitfield: Introduce the FIELD_MODIFY() macro William Breathitt Gray
2023-03-20  8:50   ` Johannes Berg
2023-03-20 12:22     ` Andy Shevchenko
2023-03-20 15:03     ` William Breathitt Gray
2023-03-18 14:59 ` [PATCH 3/4] counter: 104-quad-8: Refactor to buffer states for CMR, IOR, and IDR William Breathitt Gray
2023-03-18 14:59 ` [PATCH 4/4] counter: 104-quad-8: Utilize helper functions to handle PR, FLAG and PSC William Breathitt Gray
2023-03-20 12:28   ` Andy Shevchenko
2023-03-20 15:31     ` William Breathitt Gray
2023-03-20 15:36       ` Andy Shevchenko
2023-03-20 15:53         ` William Breathitt Gray
2023-03-20 16:54           ` Andy Shevchenko

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