towards a integrated infrastructure for feature + errata handling in kernel

I have a confession to make: I am fanatic about clean code. I like it simple and I like it elegant.

Few days back, I had a chat on linux omap mailing list on what I'd dream to see instead of a half a dozen cpu_has_feature_XYZ() APIs in the system.. The thought is more of this form:
  • Some sort of infrastructure which is common to all silicons,platforms exist which provides method to register the tuple (silicon_rev_id | ip_module_rev_id, feature_errata_id)
  • Specific drivers such as DMA, I2C, McBSP, PRCM etc.. on registration provides to the system the an array of tuples for that device.
  • Platform on bootup provides the platform_data to the driver, which allows the driver to start, but now, it can also detect cpu_rev and can grap it's own IP Module rev from it's own register.. -> that is provided to the infrastructure

  • Every time there is a need to check to enable/disable feature/errata, all the code needs to do is:
if (is_enabled(dev, OMAP3_ISP) ) {
do my stuff;
}

is'nt that cleaner than
if (cpu_is_3430() && (cpu_rev >= OMAP3430_ES3P1) ) {
do my stuff;
}
or
if (cpu_is_3430() && (omap_features & OMAP_HAS_ISP) {
do my stuff;
}
  • Now what ever we do here can easily be displayed by the subsystem by exposing a cat /sys/devices/... /features or even club it with cat /proc/cpuinfo if that is what people want -> you can do it anytime anywhere if you retain just the data you need... ;)
  • No need to store the entire database of features in the infrastructure for ever, we can save memory by making the original array init_data and copying it into a list which is easier to search for the infrastructure..

Now, this infrastructure can also be readily used for external peripherals outside the chip - like camera sensors, RFBI displays etc.. come to think of this, it kinda looks the way how I2C board_info is handled in some ways.. hmmm...

Now, only thing I need is get some time to do this, as Kevin seems interested in the original patch.. couple of fortnights to go before i get some personal time to hack some *real* code.. ;) but what the heck.. if there is anyone out there who has the time and interest to do this.. go ahead and do it..

Comments

Popular posts from this blog

simpler alternative to minicom

Quick and Dirty userspace testing of regulator with virtual consumer

Setting up Email forwarding System for GIT