The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [DRIVER MODEL] Add platform_driver
@ 2005-11-05 18:11 Russell King
  2005-11-05 18:12 ` Russell King
                   ` (20 more replies)
  0 siblings, 21 replies; 23+ messages in thread
From: Russell King @ 2005-11-05 18:11 UTC (permalink / raw)
  To: Linux Kernel List

The following set of patches adds a platform_driver structure, which
is much like the pci_driver structure:

struct platform_driver {
	int (*probe)(struct platform_device *);
	int (*remove)(struct platform_device *);
	void (*shutdown)(struct platform_device *);
	int (*suspend)(struct platform_device *, pm_message_t state);
	int (*resume)(struct platform_device *);
	struct device_driver driver;
};

The idea behind this is to stop using the struct device_driver
suspend/resume fields, and eventually eliminate the other function
pointers from within that structure.

Why?

Virtually every other user wraps the device_driver structure in
their own structure, which contains function pointers specific
to their implementation.  For instance, pci_driver contains:

    int  (*probe)  (struct pci_dev *dev, const struct pci_device_id *id);
    void (*remove) (struct pci_dev *dev);
    int  (*suspend) (struct pci_dev *dev, pm_message_t state);
    int  (*resume) (struct pci_dev *dev);
    int  (*enable_wake) (struct pci_dev *dev, pci_power_t state, int enable);
    void (*shutdown) (struct pci_dev *dev);

and as can be seen, the arguments to these methods are typed
according to the bus type.

Hence, the methods in struct device_driver are just adding needless
bloat to the kernel.  In addition, use of these device_driver methods
invariably requires a container_of() manipulation of the struct_device
structure, and doing that in every driver is also needless code bloat.

Also, from the type safety aspect, it's better to have methods which
are passed the correct type and if they aren't have a compiler
warning or build failure.

Hence, the following patches introduce struct platform_driver, and
then convert the platform device drivers over to this new model.

Due to the way the conversion is done, unconverted drivers will still
continue to work as before... for the time being.

Patches, which are built on top of my previous driver model patch set,
follow.

-- 
Russell King
 Linux kernel    2.6 ARM Linux   - http://www.arm.linux.org.uk/
 maintainer of:  2.6 Serial core

^ permalink raw reply	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2005-11-06 20:41 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-11-05 18:11 [DRIVER MODEL] Add platform_driver Russell King
2005-11-05 18:12 ` Russell King
2005-11-06 20:39   ` Greg KH
2005-11-05 18:12 ` [DRIVER MODEL] Convert arch/arm Russell King
2005-11-05 18:13 ` [DRIVER MODEL] Convert arch/um/ Russell King
2005-11-05 18:14 ` [DRIVER MODEL] Convert arch/xtensa/ Russell King
2005-11-05 18:14 ` [DRIVER MODEL] Convert ARM s3c2410 drivers Russell King
2005-11-05 18:15 ` [DRIVER MODEL] Convert ARM SA1100 drivers Russell King
2005-11-05 18:15 ` [DRIVER MODEL] Convert ARM PXA drivers Russell King
2005-11-05 18:15 ` [DRIVER MODEL] Convert ARM IMX drivers Russell King
2005-11-05 18:16 ` [DRIVER MODEL] Convert ARM OMAP drivers Russell King
2005-11-05 18:16 ` [DRIVER MODEL] Convert ARM Zaurus drivers Russell King
2005-11-05 18:17 ` [DRIVER MODEL] Convert MMC drivers Russell King
2005-11-05 18:17 ` [DRIVER MODEL] Convert MTD drivers Russell King
2005-11-05 18:17 ` [DRIVER MODEL] Convert serial drivers Russell King
2005-11-05 18:17 ` [DRIVER MODEL] Convert i2c drivers Russell King
2005-11-05 18:18 ` [DRIVER MODEL] Convert input drivers Russell King
2005-11-05 18:18 ` [DRIVER MODEL] Convert network drivers Russell King
2005-11-05 18:18 ` [DRIVER MODEL] Convert USB drivers Russell King
2005-11-05 18:19 ` [DRIVER MODEL] Convert miscellaneous char drivers Russell King
2005-11-05 18:19 ` [DRIVER MODEL] Convert video drivers Russell King
2005-11-05 18:19 ` [DRIVER MODEL] Convert ALSA Russell King
2005-11-05 18:20 ` [DRIVER MODEL] Convert drivers/misc/hdpuftrs Russell King

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox