Linux Kernel Module: Expose I²C registers to sysfs

Solution for Linux Kernel Module: Expose I²C registers to sysfs
is Given Below:

I’m wiring up an MCU to a Raspberry Pi via I²C, the latter being the bus master. As the MCU keeps track of several subsystems, I’m looking for a well organized way to expose the configuration to the user space on the RPi side of things.

Preferably, I’d like to create a hierarchy of character devices under /sys/class, e.g.:

/sys/class/<project>/<submodule1>/<option1>
/sys/class/<project>/<submodule1>/<option2>
/sys/class/<project>/<submodule2>/<submodule2-1>/<option1>
/sys/class/<project>/<submodule2>/<submodule2-2>/<option1>

However, from my research I doubt this is the way to do it: As far as I can tell, the second level hierarchy (submodule2-{1,2}) is not modeled by the Linux’ device API and minor numbers are limited (even though 8 bits might be just enough to enumerate the registers).

Getting to the point, my questions are:

  1. Did I miss the API functions to model the above hierarchy in an LKM?
  2. Using regmap as a mature alternative, how do I best map from the hierarchical register name to the corresponding address?
  3. Are there other viable alternatives that I overlooked?
  4. Where do I best look for best practice in LKM development as of today, given that the search results are often rather old (e.g. regarding kernel version v2.3)?