Hi Thomas, On Wed, Oct 03, 2012 at 08:25:16PM +0200, Thomas Petazzoni wrote: > > On Wed, 3 Oct 2012 19:07:31 +0200, Baruch Siach wrote: > > > I think that a template driver in the mainline kernel would be a great > > contribution to the kernel. > > On my side, I am questioning whether this is a goal that can actually > be achieved. > > In practice, Constantine driver will never be useful as a template for > any driver, for two main reasons: > > * It is only showing how to write a raw character driver, while most > drivers in the kernel are integrated inside an existing subsystem, > that requires the implementation of subsystem-specific APIs (tty > subsystem, mtd subsystem, input subsystem, network subsystem, etc.). > Therefore, each of those subsystems would require a separate > template driver. And in fact some of them already have such a > template, see for example > http://lxr.free-electrons.com/source/drivers/video/skeletonfb.c for > the framebuffer subsystem. Doing similar skeleton drivers for each > subsystem would most likely be a lot more useful. > > * This driver only shows how to implement a platform driver, while > only some of the drivers are platform drivers. Many other are I2C > drivers, SPI drivers, USB drivers, PCI drivers, etc. and therefore > this template does not show any of this. Another example is that > this driver is a platform driver, but does not support the Device > Tree, which is needed on ARM, PowerPC, Microblaze and probably at > least another architecture. > > Therefore the whole idea of writing a "generic template kernel driver" > is doomed to fail, as it is simply not possible.
To me the significance of this template driver is not as a demonstration of IO operations that are, as you correctly point out, subsystem specific. This driver uses the concepts of file operations and platform driver, I guess, because they are easy to emulate. But these are only means to demonstrate common driver programming patterns and mechanisms like interrupt handling, tasklets, workqueues, completion, etc. Details like DT binding, deprecated /proc use, as well as some other issues, are fixable in my opinion. baruch > Also, /proc entries are deprecated for drivers. No new driver should > create one. Use debugfs instead for debugging features, or possibly > sysfs if this is actually relevant. > > Best regards, > > Thomas -- http://baruch.siach.name/blog/ ~. .~ Tk Open Systems =}------------------------------------------------ooO--U--Ooo------------{= - bar...@tkos.co.il - tel: +972.2.679.5364, http://www.tkos.co.il - _______________________________________________ Celinux-dev mailing list Celinux-dev@lists.celinuxforum.org https://lists.celinuxforum.org/mailman/listinfo/celinux-dev