Re: [PATCH 2.6-git] SPI core refresh

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux