From: Vitaly W. <vw...@ru...> - 2005-12-12 16:56:51
|
BTW: David Brownell wrote: >+How do I write an "SPI Master Controller Driver"? >+------------------------------------------------- >+An SPI controller will probably be registered on the platform_bus; write >+a driver to bind to the device, whichever bus is involved. >+ >+The main task of this type of driver is to provide an "spi_master". >+Use spi_alloc_master() to allocate the master, and class_get_devdata() >+to get the driver-private data allocated for that device. >+ >+ struct spi_master *master; >+ struct CONTROLLER *c; >+ >+ master = spi_alloc_master(dev, sizeof *c); >+ if (!master) >+ return -ENODEV; >+ >+ c = class_get_devdata(&master->cdev); > > Here's an example of a mixture of two approaches which leads to misleading code. If you want to have abstract spi_master, then you have to disallow (or at least discourage) explicit usage of spi_master fields, otherwise 'kzalloc is your friend' and you don't have toadd this spi_alloc_master API as it's basically useless IMHO. As opposed to this, we use abstract handles where possible (i. e. for spi_message). I'd have understood your dissatisfaction with that if you were consistently following the approach 'expose everything, forget the extensibility, viva lightwieghtness', but you're mixing things. Vitaly |