2 * Copyright (C) 2014 John Crispin <blogic@openwrt.org>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License version 2.1
6 * as published by the Free Software Foundation
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
17 #include <asm/byteorder.h>
21 typedef int (*volume_probe_t)(void);
22 typedef int (*volume_init_t)(struct volume *v);
23 typedef void (*volume_stop_t)(struct volume *v);
24 typedef int (*volume_find_t)(struct volume *v, char *name);
25 typedef int (*volume_identify_t)(struct volume *v);
26 typedef int (*volume_read_t)(struct volume *v, void *buf, int offset, int length);
27 typedef int (*volume_write_t)(struct volume *v, void *buf, int offset, int length);
28 typedef int (*volume_erase_t)(struct volume *v, int start, int len);
29 typedef int (*volume_erase_all_t)(struct volume *v);
32 struct list_head list;
39 volume_identify_t identify;
43 volume_erase_all_t erase_all;
64 extern struct volume* volume_find(char *name);
65 extern void volume_register_driver(struct driver *drv);
67 static inline int volume_init(struct volume *v)
69 if (v && v->drv->init)
70 return v->drv->init(v);
74 static inline int volume_identify(struct volume *v)
76 if (v && v->drv->identify)
77 return v->drv->identify(v);
81 static inline int volume_erase(struct volume *v, int offset, int len)
83 if (v && v->drv->erase)
84 return v->drv->erase(v, offset, len);
88 static inline int volume_erase_all(struct volume *v)
90 if (v && v->drv->erase_all)
91 return v->drv->erase_all(v);
95 static inline int volume_read(struct volume *v, void *buf, int offset, int length)
97 if (v && v->drv->read)
98 return v->drv->read(v, buf, offset, length);
102 static inline int volume_write(struct volume *v, void *buf, int offset, int length)
104 if (v && v->drv->write)
105 return v->drv->write(v, buf, offset, length);
110 static void __attribute__((constructor)) \
111 drv_register_##x(void) { \
112 volume_register_driver(&x); \