New driver model for ide and motherboard devices
Subsystems (4)
Hi!
Here it is... It would be nice to get it to Linus.
Pavel
Documentation/driver-model.txt +2 -2
@@ -248,10 +248,10 @@ ejection event could take place here. suspend: - Perform one step of the device suspend process. + Perform one step of the device suspend process. Returns 0 on success. resume: - Perform one step of the device resume process. + Perform one step of the device resume process. Returns 0 on success. The probe() and remove() callbacks are intended to be much simpler than the current PCI correspondents.
arch/i386/kernel/i8259.c +8 -0
@@ -11,6 +11,7 @@#include <linux/smp_lock.h> #include <linux/init.h> #include <linux/kernel_stat.h> +#include <linux/device.h> #include <asm/atomic.h> #include <asm/system.h>
@@ -333,10 +334,17 @@ } } +static struct device device_i8259A; +void __init init_8259A (int auto_eoi) {unsigned long flags; +device_init_dev (&device_i8259A); +device_register (&device_i8259A); +strcpy (device_i8259A.name,"i8259A" ); +strcpy (device_i8259A.bus_id,"0020" ); + device_i8259A.parent = &sys_iobus;spin_lock_irqsave (&i8259A_lock, flags);outb (0xff ,0x21 );/* mask all of 8259A-1 */
arch/i386/kernel/setup.c +11 -0
@@ -99,6 +99,7 @@#include <linux/highmem.h> #include <linux/bootmem.h> #include <linux/seq_file.h> +#include <linux/device.h> #include <asm/processor.h> #include <linux/console.h> #include <asm/mtrr.h>
@@ -780,6 +781,15 @@ } } +struct iobus sys_iobus; + +void __init setup_sys_bus (void ) +{ +sprintf (sys_iobus.name,"Bus for motherboard and strange devices" ); +sprintf (sys_iobus.bus_id,"sys" ); +iobus_register (&sys_iobus); +} +void __init setup_arch (char **cmdline_p) {unsigned long bootmap_size, low_mem_size;
@@ -1028,6 +1038,7 @@ } }request_resource (&iomem_resource, &vram_resource); +setup_sys_bus ();/* request I/O space for devices used on all i[345]86 PCs */ for (i =0 ; i <STANDARD_IO_RESOURCES ; i++)
arch/i386/kernel/time.c +9 -0
@@ -41,6 +41,7 @@#include <linux/delay.h> #include <linux/init.h> #include <linux/smp.h> +#include <linux/device.h> #include <asm/io.h> #include <asm/smp.h>
@@ -634,9 +635,17 @@return 0 ; } +static struct device device_i8253; +void __init time_init (void ) {extern int x86_udelay_tsc; + +device_init_dev (&device_i8253); +strcpy (device_i8253.name,"i8253" ); +strcpy (device_i8253.bus_id,"0040" ); + device_i8253.parent = &sys_iobus; +device_register (&device_i8253); xtime.tv_sec =get_cmos_time (); xtime.tv_usec =0 ;
drivers/block/floppy.c +7 -0
@@ -167,6 +167,7 @@#include <linux/interrupt.h> #include <linux/init.h> #include <linux/devfs_fs_kernel.h> +#include <linux/device.h> /* * PS/2 floppies have much slower step rates than regular floppies.
@@ -4148,11 +4149,17 @@static int have_no_fdc= -ENODEV ; +static struct device device_floppy;int __init floppy_init (void ) {int i,unit,drive; +device_init_dev (&device_floppy); +strcpy (device_floppy.name,"floppy" ); +strcpy (device_floppy.bus_id,"03?0" ); + device_floppy.parent = &sys_iobus; +device_register (&device_floppy); raw_cmd =NULL ;
drivers/ide/ide-disk.c +19 -0
@@ -816,6 +816,23 @@return ide_unregister_subdriver (drive); } +static int idedisk_suspend (ide_drive_t *drive,u32 state,u32 stage) +{ +/* During S4, interrupt might be pending over resume. If it hits us and we +think it is completion interrupt from something started between suspend, +we'll destroy data. Don't do that. */ +if (state ==4 ) +return -EINVAL ; +return 0 ; +} + +static int idedisk_resume (ide_drive_t *drive,u32 stage) +{ +return 0 ; +} + + +/* * IDE subdriver functions, registered with ide.c */
@@ -839,6 +856,8 @@ special: idedisk_special, proc: idedisk_proc, driver_reinit: idedisk_reinit, + suspend: idedisk_suspend, + resume: idedisk_resume, };int idedisk_init (void );
drivers/ide/ide-probe.c +32 -0
@@ -448,8 +448,40 @@return (region_errors); } +int ide_hwif_suspend (struct device * dev,u32 state,u32 stage) +{ +int i, res =0 ; +ide_hwif_t *hwif = dev->driver_data; + +for (i=0 ; i<MAX_DRIVES ; i++) { +if (hwif->drives[i].driver->suspend) + res = hwif->drives[i].driver->suspend (hwif->drives+i, state, stage); +if (res) +return res; + } +return 0 ; +} + +int ide_hwif_resume (struct device * dev,u32 stage) +{ +ide_hwif_t *hwif = dev->driver_data; +return 0 ; +} + +struct device_driver ide_device_driver = { + suspend: ide_hwif_suspend, + resume: ide_hwif_resume, +}; +static void hwif_register (ide_hwif_t *hwif) { +device_init_dev (&hwif->device); +sprintf (hwif->device.bus_id,"%4x" , hwif->io_ports[IDE_DATA_OFFSET ]); +sprintf (hwif->device.name,"ide" ); + hwif->device.driver = &ide_device_driver; + hwif->device.driver_data = hwif; + hwif->device.parent = &sys_iobus; +device_register (&hwif->device);if (((unsigned long )hwif->io_ports[IDE_DATA_OFFSET ] |7 ) == ((unsigned long )hwif->io_ports[IDE_STATUS_OFFSET ])) {ide_request_region (hwif->io_ports[IDE_DATA_OFFSET ],8 , hwif->name);
include/linux/device.h +1 -0
@@ -249,5 +249,6 @@ }extern void put_iobus (struct iobus * iobus); +extern struct iobus sys_iobus;#endif /* _DEVICE_H_ */
include/linux/ide.h +6 -0
@@ -14,6 +14,7 @@#include <linux/blkdev.h> #include <linux/proc_fs.h> #include <linux/devfs_fs_kernel.h> +#include <linux/device.h> #include <asm/hdreg.h> /*
@@ -536,6 +537,7 @@void *hwif_data;/* extra hwif data */ ide_busproc_t *busproc;/* driver soft-power interface */ byte bus_state;/* power state of the IDE bus */ +struct device device; } ide_hwif_t;
@@ -667,6 +669,8 @@typedef ide_startstop_t (ide_special_proc )(ide_drive_t *);typedef void (ide_setting_proc )(ide_drive_t *);typedef int (ide_driver_reinit_proc )(ide_drive_t *); +typedef int (ide_suspend_proc )(ide_drive_t *,u32 state,u32 stage); +typedef int (ide_resume_proc )(ide_drive_t *,u32 stage); typedef struct ide_driver_s { const char *name;
@@ -688,6 +692,8 @@ide_special_proc *special;ide_proc_entry_t *proc;ide_driver_reinit_proc *driver_reinit; +ide_suspend_proc *suspend; +ide_resume_proc *resume; } ide_driver_t;#define DRIVER (drive) ((ide_driver_t *)((drive)->driver))
Signature · 2 lines
(about SSSCA) "I don't say this lightly. However, I really think that the U.S. no longer is classifiable as a democracy, but rather as a plutocracy." --hpa