summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2009-04-22 23:39:27 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2009-07-21 16:41:44 +0200
commita2b7cd183bad9c9e0888ce62f5ae0f83c070cc2a (patch)
tree556535cae729eac244edff816476cab281c6be7b /include
parent6411c3b2be40bb295520db2e9f6f891873a48b1a (diff)
downloadbarebox-a2b7cd183bad9c9e0888ce62f5ae0f83c070cc2a.tar.gz
barebox-a2b7cd183bad9c9e0888ce62f5ae0f83c070cc2a.tar.xz
introduce cdev
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'include')
-rw-r--r--include/cfi_flash.h1
-rw-r--r--include/cfi_flash_new.h1
-rw-r--r--include/driver.h85
-rw-r--r--include/linux/mtd/mtd.h3
-rw-r--r--include/miiphy.h1
-rw-r--r--include/nand.h4
-rw-r--r--include/partition.h14
7 files changed, 64 insertions, 45 deletions
diff --git a/include/cfi_flash.h b/include/cfi_flash.h
index 22e3fca35c..e461ef14e1 100644
--- a/include/cfi_flash.h
+++ b/include/cfi_flash.h
@@ -32,6 +32,7 @@
typedef struct {
struct driver_d driver;
+ struct cdev cdev;
ulong size; /* total bank size in bytes */
ushort sector_count; /* number of erase units */
ulong flash_id; /* combined device & manufacturer code */
diff --git a/include/cfi_flash_new.h b/include/cfi_flash_new.h
index 5d4bd5b585..2ebe83b455 100644
--- a/include/cfi_flash_new.h
+++ b/include/cfi_flash_new.h
@@ -59,6 +59,7 @@ typedef struct {
ushort cfi_version; /* cfi version */
ushort cfi_offset; /* offset for cfi query */
struct cfi_cmd_set *cfi_cmd_set;
+ struct cdev cdev;
} flash_info_t;
struct cfi_cmd_set {
diff --git a/include/driver.h b/include/driver.h
index b2ab7c25ac..98d54ad3ad 100644
--- a/include/driver.h
+++ b/include/driver.h
@@ -98,7 +98,6 @@ struct device_d {
void *type_data; /*! In case this device is a specific device, this pointer
* points to the type specific device, i.e. eth_device
*/
-
struct driver_d *driver; /*! The driver for this device */
struct list_head list; /* The list of all devices */
@@ -133,22 +132,6 @@ struct driver_d {
/*! Called if an instance of a device is gone. */
void (*remove)(struct device_d *);
- /*! Called in response of reading from this device. Required */
- ssize_t (*read) (struct device_d*, void* buf, size_t count, ulong offset, ulong flags);
-
- /*! Called in response of write to this device. Required */
- ssize_t (*write) (struct device_d*, const void* buf, size_t count, ulong offset, ulong flags);
-
- int (*ioctl) (struct device_d*, int, void *);
-
- off_t (*lseek) (struct device_d*, off_t);
- int (*open) (struct device_d*, struct filep*);
- int (*close) (struct device_d*, struct filep*);
-
- int (*erase) (struct device_d*, size_t count, unsigned long offset);
- int (*protect)(struct device_d*, size_t count, unsigned long offset, int prot);
- int (*memmap)(struct device_d*, void **map, int flags);
-
void (*info) (struct device_d *);
void (*shortinfo) (struct device_d *);
@@ -231,20 +214,14 @@ extern struct list_head driver_list;
*/
struct driver_d *get_driver_by_name(const char *name);
-ssize_t dev_read(struct device_d *dev, void *buf, size_t count, ulong offset, ulong flags);
-ssize_t dev_write(struct device_d *dev, const void *buf, size_t count, ulong offset, ulong flags);
-int dev_open(struct device_d *dev, struct filep *);
-int dev_close(struct device_d *dev, struct filep *);
-int dev_ioctl(struct device_d *dev, int, void *);
-off_t dev_lseek(struct device_d *dev, off_t offset);
-int dev_erase(struct device_d *dev, size_t count, unsigned long offset);
+struct cdev;
+
int dev_protect(struct device_d *dev, size_t count, unsigned long offset, int prot);
-int dev_memmap(struct device_d *dev, void **map, int flags);
/* These are used by drivers which work with direct memory accesses */
-ssize_t mem_read(struct device_d *dev, void *buf, size_t count, ulong offset, ulong flags);
-ssize_t mem_write(struct device_d *dev, const void *buf, size_t count, ulong offset, ulong flags);
-int mem_memmap(struct device_d *dev, void **map, int flags);
+ssize_t mem_read(struct cdev *cdev, void *buf, size_t count, ulong offset, ulong flags);
+ssize_t mem_write(struct cdev *cdev, const void *buf, size_t count, ulong offset, ulong flags);
+int mem_memmap(struct cdev *cdev, void **map, int flags);
/* Use this if you have nothing to do in your drivers probe function */
int dummy_probe(struct device_d *);
@@ -254,10 +231,10 @@ int dummy_probe(struct device_d *);
*/
void devices_shutdown(void);
-int generic_memmap_ro(struct device_d *dev, void **map, int flags);
-int generic_memmap_rw(struct device_d *dev, void **map, int flags);
+int generic_memmap_ro(struct cdev *dev, void **map, int flags);
+int generic_memmap_rw(struct cdev *dev, void **map, int flags);
-static inline off_t dev_lseek_default(struct device_d *dev, off_t ofs)
+static inline off_t dev_lseek_default(struct cdev *cdev, off_t ofs)
{
return ofs;
}
@@ -312,5 +289,51 @@ struct bus_type {
};
extern struct bus_type platform_bus;
+
+struct file_operations {
+ /*! Called in response of reading from this device. Required */
+ ssize_t (*read)(struct cdev*, void* buf, size_t count, ulong offset, ulong flags);
+
+ /*! Called in response of write to this device. Required */
+ ssize_t (*write)(struct cdev*, const void* buf, size_t count, ulong offset, ulong flags);
+
+ int (*ioctl)(struct cdev*, int, void *);
+ off_t (*lseek)(struct cdev*, off_t);
+ int (*open)(struct cdev*, struct filep*);
+ int (*close)(struct cdev*, struct filep*);
+ int (*erase)(struct cdev*, size_t count, unsigned long offset);
+ int (*protect)(struct cdev*, size_t count, unsigned long offset, int prot);
+ int (*memmap)(struct cdev*, void **map, int flags);
+};
+
+struct cdev {
+ struct file_operations *ops;
+ void *priv;
+ struct device_d *dev;
+ struct list_head list;
+ char *name;
+ unsigned long offset;
+ size_t size;
+ unsigned int flags;
+};
+
+int devfs_create(struct cdev *);
+void devfs_remove(struct cdev *);
+struct cdev *cdev_by_name(const char *filename);
+
+#define DEVFS_PARTITION_FIXED (1 << 0)
+#define DEVFS_PARTITION_READONLY (1 << 1)
+#define DEVFS_IS_PARTITION (1 << 2)
+#define DEVFS_RDWR (1 << 3)
+
+int devfs_add_partition(const char *devname, unsigned long offset, size_t size,
+ int flags, const char *name);
+int devfs_del_partition(const char *name);
+
+struct memory_platform_data {
+ char *name;
+ unsigned int flags;
+};
+
#endif /* DRIVER_H */
diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h
index 3a2a1bc299..c6e28e228b 100644
--- a/include/linux/mtd/mtd.h
+++ b/include/linux/mtd/mtd.h
@@ -9,6 +9,7 @@
#ifndef __MTD_MTD_H__
#define __MTD_MTD_H__
+#include <driver.h>
#include <linux/types.h>
#include <list.h>
#include <linux/mtd/mtd-abi.h>
@@ -199,7 +200,9 @@ struct mtd_info {
int (*get_device) (struct mtd_info *mtd);
void (*put_device) (struct mtd_info *mtd);
+ struct device_d class_dev;
struct device_d *dev;
+ struct cdev cdev;
};
diff --git a/include/miiphy.h b/include/miiphy.h
index 23373e96b2..67f1b1ce98 100644
--- a/include/miiphy.h
+++ b/include/miiphy.h
@@ -146,6 +146,7 @@ struct miiphy_device {
int flags;
struct eth_device *edev;
+ struct cdev cdev;
};
int miiphy_register(struct miiphy_device *mdev);
diff --git a/include/nand.h b/include/nand.h
index 5121c4d5fc..522a0fc523 100644
--- a/include/nand.h
+++ b/include/nand.h
@@ -2,7 +2,9 @@
#ifndef __NAND_H__
#define __NAND_H__
-struct device_d *dev_add_bb_dev(struct device_d *dev, const char *name);
+struct nand_bb;
+
+int dev_add_bb_dev(char *filename, const char *name);
#endif /* __NAND_H__ */
diff --git a/include/partition.h b/include/partition.h
index cdf6368fd4..4eac8de86b 100644
--- a/include/partition.h
+++ b/include/partition.h
@@ -17,20 +17,8 @@ struct partition {
struct device_d device;
char name[16];
+ struct cdev cdev;
};
-#ifdef CONFIG_PARTITION
-struct device_d *dev_add_partition(struct device_d *dev, unsigned long offset,
- size_t size, int flags, const char *name);
-#else
-static inline struct device_d *dev_add_partition(struct device_d *dev,
- unsigned long offset, size_t size, int flags,
- const char *name)
-{
- return 0;
-}
-#endif
-/* FIXME: counterpart missing */
-
#endif /* __PARTITION_H */