From 5cff70d073c7fb83b6c57e75b8616bf64077c124 Mon Sep 17 00:00:00 2001 From: David Cohen Date: Mon, 10 Dec 2007 23:20:30 -0400 Subject: [PATCH] device.h: code cleanup and improvements. Making a code cleanup and improvements on device.h Signed-off-by: David Cohen --- include/tinyx/device.h | 50 ++++++++++++++++++++++++++------------------------ 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/include/tinyx/device.h b/include/tinyx/device.h index 72e436f..b5de65a 100644 --- a/include/tinyx/device.h +++ b/include/tinyx/device.h @@ -1,50 +1,48 @@ -#ifndef __DEVICE_H -#define __DEVICE_H +#ifndef __TINYX_DEVICE_H +#define __TINYX_DEVICE_H struct bus_type; struct device_driver; struct device; struct resource_mem { - struct list_head *head; - unsigned long start; unsigned long end; }; struct resource_irq { - struct list_head *head; - unsigned int start; }; -union resource { - struct list_head *head; - - struct resource_mem; - struct resource_irq; +struct resource { + union { + struct resource_mem mem; + struct resource_irq irq; + }; }; struct bus_type { struct list_head *head; - - const char *name; - int id; - void *private_data; + const char *name; + int id; + void *private_data; int (*probe) (struct bus_type *bus); int (*remove) (struct bus_type *bus); int (*match) (struct device *dev, struct device_driver *drv); - int (*writel) (struct device *dev, unsigned long address, unsigned int value); - int (*readl) (struct device *dev, unsigned long address, unsigned int value); + + void (*writeb) (struct device *dev, unsigned char val, unsigned long addr); + void (*writew) (struct device *dev, unsigned int val, unsigned long addr); + void (*writel) (struct device *dev, unsigned long val, unsigned long addr); + + unsigned char (*readb) (struct device *dev, unsigned long addr); + unsigned int (*readw) (struct device *dev, unsigned long addr); + unsigned long (*readl) (struct device *dev, unsigned long addr); }; struct device_driver { struct list_head *head; - - const char *name; - int id; - struct bus_type *bus; + const char *name; int (*probe) (struct device *dev); int (*remove) (struct device *dev); @@ -52,12 +50,16 @@ struct device_driver { struct device { struct list_head *head; - const char *name; int id; struct device_driver *drv; + struct bus_type *bus; void *private_data; - struct resource[] res; + struct resource *res; }; -#endif +int register_bus_type(struct bus_type *bus); +int register_device_driver(struct device_driver *drv); +int register_device(struct device *dev, struct bus_type *bus); + +#endif /* __TINYX_DEVICE_H */ -- 2.11.4.GIT