提交 a5835786 编写于 作者: D Dominik Brodowski

pcmcia: cleanup device driver header file

The header file primarily used for (in-kernel) PCMCIA device drivers
also deserved a major cleanup. This header file also serves as the dumping
ground for all typedefs and definitions only used by the deprecated PCMCIA
ioctl and the deprecated PCMCIA userspace tools using this ioctl.
Signed-off-by: NDominik Brodowski <linux@dominikbrodowski.net>
上级 c23889ca
......@@ -28,45 +28,10 @@ typedef struct conf_reg_t {
#define CS_WRITE 2
/* for AdjustResourceInfo */
typedef struct adjust_t {
u_int Action;
u_int Resource;
u_int Attributes;
union {
struct memory {
u_long Base;
u_long Size;
} memory;
struct io {
ioaddr_t BasePort;
ioaddr_t NumPorts;
u_int IOAddrLines;
} io;
struct irq {
u_int IRQ;
} irq;
} resource;
} adjust_t;
/* Action field */
#define REMOVE_MANAGED_RESOURCE 1
#define ADD_MANAGED_RESOURCE 2
#define GET_FIRST_MANAGED_RESOURCE 3
#define GET_NEXT_MANAGED_RESOURCE 4
/* Resource field */
#define RES_MEMORY_RANGE 1
#define RES_IO_RANGE 2
#define RES_IRQ 3
/* Attribute field */
#define RES_IRQ_TYPE 0x03
#define RES_IRQ_TYPE_EXCLUSIVE 0
#define RES_IRQ_TYPE_TIME 1
#define RES_IRQ_TYPE_DYNAMIC 2
#define RES_IRQ_CSC 0x04
#define RES_SHARED 0x08
#define RES_RESERVED 0x10
#define RES_ALLOCATED 0x20
#define RES_REMOVED 0x40
typedef struct event_callback_args_t {
struct pcmcia_device *client_handle;
......
......@@ -10,7 +10,7 @@
* are Copyright (C) 1999 David A. Hinds. All Rights Reserved.
*
* (C) 1999 David A. Hinds
* (C) 2003 - 2004 Dominik Brodowski
* (C) 2003 - 2008 Dominik Brodowski
*/
#ifndef _LINUX_DS_H
......@@ -23,6 +23,196 @@
#include <pcmcia/cs_types.h>
#include <pcmcia/device_id.h>
#ifdef __KERNEL__
#include <linux/device.h>
#include <pcmcia/ss.h>
/*
* PCMCIA device drivers (16-bit cards only; 32-bit cards require CardBus
* a.k.a. PCI drivers
*/
struct pcmcia_socket;
struct pcmcia_device;
struct config_t;
/* dynamic device IDs for PCMCIA device drivers. See
* Documentation/pcmcia/driver.txt for details.
*/
struct pcmcia_dynids {
spinlock_t lock;
struct list_head list;
};
struct pcmcia_driver {
int (*probe) (struct pcmcia_device *dev);
void (*remove) (struct pcmcia_device *dev);
int (*suspend) (struct pcmcia_device *dev);
int (*resume) (struct pcmcia_device *dev);
struct module *owner;
struct pcmcia_device_id *id_table;
struct device_driver drv;
struct pcmcia_dynids dynids;
};
/* driver registration */
int pcmcia_register_driver(struct pcmcia_driver *driver);
void pcmcia_unregister_driver(struct pcmcia_driver *driver);
/* Some drivers use dev_node_t to store char or block device information.
* Don't use this in new drivers, though.
*/
typedef struct dev_node_t {
char dev_name[DEV_NAME_LEN];
u_short major, minor;
struct dev_node_t *next;
} dev_node_t;
struct pcmcia_device {
/* the socket and the device_no [for multifunction devices]
uniquely define a pcmcia_device */
struct pcmcia_socket *socket;
char *devname;
u8 device_no;
/* the hardware "function" device; certain subdevices can
* share one hardware "function" device. */
u8 func;
struct config_t* function_config;
struct list_head socket_device_list;
/* deprecated, will be cleaned up soon */
dev_node_t *dev_node;
u_int open;
io_req_t io;
irq_req_t irq;
config_req_t conf;
window_handle_t win;
/* Is the device suspended, or in the process of
* being removed? */
u16 suspended:1;
u16 _removed:1;
/* Flags whether io, irq, win configurations were
* requested, and whether the configuration is "locked" */
u16 _irq:1;
u16 _io:1;
u16 _win:4;
u16 _locked:1;
/* Flag whether a "fuzzy" func_id based match is
* allowed. */
u16 allow_func_id_match:1;
/* information about this device */
u16 has_manf_id:1;
u16 has_card_id:1;
u16 has_func_id:1;
u16 reserved:3;
u8 func_id;
u16 manf_id;
u16 card_id;
char * prod_id[4];
u64 dma_mask;
struct device dev;
#ifdef CONFIG_PCMCIA_IOCTL
/* device driver wanted by cardmgr */
struct pcmcia_driver * cardmgr;
#endif
/* data private to drivers */
void *priv;
};
#define to_pcmcia_dev(n) container_of(n, struct pcmcia_device, dev)
#define to_pcmcia_drv(n) container_of(n, struct pcmcia_driver, drv)
/* deprecated -- don't use! */
#define handle_to_dev(handle) (handle->dev)
/* (deprecated) error reporting by PCMCIA devices. Use dev_printk()
* or dev_dbg() directly in the driver, without referring to pcmcia_error_func()
* and/or pcmcia_error_ret() for those functions will go away soon.
*/
const char *pcmcia_error_func(int func);
const char *pcmcia_error_ret(int ret);
#define cs_error(p_dev, func, ret) \
{ \
dev_printk(KERN_NOTICE, &p_dev->dev, \
"%s : %s\n", \
pcmcia_error_func(func), \
pcmcia_error_ret(ret)); \
}
#endif /* __KERNEL__ */
/* Below, there are only definitions which are used by
* - the PCMCIA ioctl
* - deprecated PCMCIA userspace tools only
*
* here be dragons ... here be dragons ... here be dragons ... here be drag
*/
#if defined(CONFIG_PCMCIA_IOCTL) || !defined(__KERNEL__)
/* for AdjustResourceInfo */
typedef struct adjust_t {
u_int Action;
u_int Resource;
u_int Attributes;
union {
struct memory {
u_long Base;
u_long Size;
} memory;
struct io {
ioaddr_t BasePort;
ioaddr_t NumPorts;
u_int IOAddrLines;
} io;
struct irq {
u_int IRQ;
} irq;
} resource;
} adjust_t;
/* Action field */
#define REMOVE_MANAGED_RESOURCE 1
#define ADD_MANAGED_RESOURCE 2
#define GET_FIRST_MANAGED_RESOURCE 3
#define GET_NEXT_MANAGED_RESOURCE 4
/* Resource field */
#define RES_MEMORY_RANGE 1
#define RES_IO_RANGE 2
#define RES_IRQ 3
/* Attribute field */
#define RES_IRQ_TYPE 0x03
#define RES_IRQ_TYPE_EXCLUSIVE 0
#define RES_IRQ_TYPE_TIME 1
#define RES_IRQ_TYPE_DYNAMIC 2
#define RES_IRQ_CSC 0x04
#define RES_SHARED 0x08
#define RES_RESERVED 0x10
#define RES_ALLOCATED 0x20
#define RES_REMOVED 0x40
typedef struct tuple_parse_t {
tuple_t tuple;
cisdata_t data[255];
......@@ -60,6 +250,7 @@ typedef struct region_info_t {
u_char JedecMfr, JedecInfo;
memory_handle_t next;
} region_info_t;
#define REGION_TYPE 0x0001
#define REGION_TYPE_CM 0x0000
#define REGION_TYPE_AM 0x0001
......@@ -138,129 +329,11 @@ typedef union ds_ioctl_arg_t {
#define DS_UNBIND_REQUEST _IOW ('d', 63, bind_info_t)
#define DS_BIND_MTD _IOWR('d', 64, mtd_info_t)
/* used in userspace only */
#define CS_IN_USE 0x1e
#ifdef __KERNEL__
#include <linux/device.h>
#include <pcmcia/ss.h>
typedef struct dev_node_t {
char dev_name[DEV_NAME_LEN];
u_short major, minor;
struct dev_node_t *next;
} dev_node_t;
struct pcmcia_socket;
struct config_t;
struct pcmcia_dynids {
spinlock_t lock;
struct list_head list;
};
struct pcmcia_driver {
int (*probe) (struct pcmcia_device *dev);
void (*remove) (struct pcmcia_device *dev);
int (*suspend) (struct pcmcia_device *dev);
int (*resume) (struct pcmcia_device *dev);
struct module *owner;
struct pcmcia_device_id *id_table;
struct device_driver drv;
struct pcmcia_dynids dynids;
};
/* driver registration */
int pcmcia_register_driver(struct pcmcia_driver *driver);
void pcmcia_unregister_driver(struct pcmcia_driver *driver);
struct pcmcia_device {
/* the socket and the device_no [for multifunction devices]
uniquely define a pcmcia_device */
struct pcmcia_socket *socket;
char *devname;
u8 device_no;
/* the hardware "function" device; certain subdevices can
* share one hardware "function" device. */
u8 func;
struct config_t* function_config;
struct list_head socket_device_list;
/* deprecated, will be cleaned up soon */
dev_node_t *dev_node;
u_int open;
io_req_t io;
irq_req_t irq;
config_req_t conf;
window_handle_t win;
/* Is the device suspended, or in the process of
* being removed? */
u16 suspended:1;
u16 _removed:1;
/* Flags whether io, irq, win configurations were
* requested, and whether the configuration is "locked" */
u16 _irq:1;
u16 _io:1;
u16 _win:4;
u16 _locked:1;
/* Flag whether a "fuzzy" func_id based match is
* allowed. */
u16 allow_func_id_match:1;
/* information about this device */
u16 has_manf_id:1;
u16 has_card_id:1;
u16 has_func_id:1;
u16 reserved:3;
u8 func_id;
u16 manf_id;
u16 card_id;
char * prod_id[4];
u64 dma_mask;
struct device dev;
#ifdef CONFIG_PCMCIA_IOCTL
/* device driver wanted by cardmgr */
struct pcmcia_driver * cardmgr;
#endif
/* data private to drivers */
void *priv;
};
#define to_pcmcia_dev(n) container_of(n, struct pcmcia_device, dev)
#define to_pcmcia_drv(n) container_of(n, struct pcmcia_driver, drv)
#define handle_to_dev(handle) (handle->dev)
/* error reporting */
const char *pcmcia_error_func(int func);
const char *pcmcia_error_ret(int ret);
#define cs_error(p_dev, func, ret) \
{ \
dev_printk(KERN_NOTICE, &p_dev->dev, \
"%s : %s\n", \
pcmcia_error_func(func), \
pcmcia_error_ret(ret)); \
}
#endif /* !defined(__KERNEL__) || defined(CONFIG_PCMCIA_IOCTL) */
#endif /* __KERNEL__ */
#endif /* _LINUX_DS_H */
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册