diff options
author | Dominik Brodowski <linux@dominikbrodowski.net> | 2006-03-01 18:09:29 -0500 |
---|---|---|
committer | Dominik Brodowski <linux@dominikbrodowski.net> | 2006-03-31 10:26:33 -0500 |
commit | e2d4096365e06b9a3799afbadc28b4519c0b3526 (patch) | |
tree | 90ec691d71f9c0309048714e359b8ba351b533f7 /include | |
parent | f6fbe01ac976f3ec618cd5fb71ad9ce2cfa7ab2b (diff) |
[PATCH] pcmcia: use bitfield instead of p_state and state
Instead of the two status values struct pcmcia_device->p_state and state,
use descriptive bitfields. Most value-checking in drivers was invalid, as
the core now only calls the ->remove() (a.k.a. detach) function in case the
attachement _and_ configuration was successful.
Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
Diffstat (limited to 'include')
-rw-r--r-- | include/pcmcia/ds.h | 40 |
1 files changed, 24 insertions, 16 deletions
diff --git a/include/pcmcia/ds.h b/include/pcmcia/ds.h index 93a7ebc34156..a8ce8fc11514 100644 --- a/include/pcmcia/ds.h +++ b/include/pcmcia/ds.h | |||
@@ -96,6 +96,7 @@ typedef union ds_ioctl_arg_t { | |||
96 | 96 | ||
97 | #ifdef __KERNEL__ | 97 | #ifdef __KERNEL__ |
98 | #include <linux/device.h> | 98 | #include <linux/device.h> |
99 | #include <pcmcia/ss.h> | ||
99 | 100 | ||
100 | typedef struct dev_node_t { | 101 | typedef struct dev_node_t { |
101 | char dev_name[DEV_NAME_LEN]; | 102 | char dev_name[DEV_NAME_LEN]; |
@@ -103,15 +104,11 @@ typedef struct dev_node_t { | |||
103 | struct dev_node_t *next; | 104 | struct dev_node_t *next; |
104 | } dev_node_t; | 105 | } dev_node_t; |
105 | 106 | ||
106 | /* Flags for device state */ | 107 | #define pcmcia_dev_present(p_dev) \ |
107 | #define DEV_PRESENT 0x01 | 108 | (p_dev->socket->pcmcia_state.present) |
108 | #define DEV_CONFIG 0x02 | ||
109 | #define DEV_SUSPEND_NORELEASE 0x04 | ||
110 | #define DEV_CONFIG_PENDING 0x10 | ||
111 | #define DEV_BUSY 0x80 | ||
112 | 109 | ||
113 | #define DEV_OK(l) \ | 110 | #define DEV_OK(l) \ |
114 | ((l) && ((l->state & ~DEV_BUSY) == (DEV_CONFIG|DEV_PRESENT))) | 111 | ((l) && (!l->suspended) && pcmcia_dev_present(l)) |
115 | 112 | ||
116 | 113 | ||
117 | struct pcmcia_socket; | 114 | struct pcmcia_socket; |
@@ -133,6 +130,7 @@ struct pcmcia_driver { | |||
133 | int pcmcia_register_driver(struct pcmcia_driver *driver); | 130 | int pcmcia_register_driver(struct pcmcia_driver *driver); |
134 | void pcmcia_unregister_driver(struct pcmcia_driver *driver); | 131 | void pcmcia_unregister_driver(struct pcmcia_driver *driver); |
135 | 132 | ||
133 | |||
136 | struct pcmcia_device { | 134 | struct pcmcia_device { |
137 | /* the socket and the device_no [for multifunction devices] | 135 | /* the socket and the device_no [for multifunction devices] |
138 | uniquely define a pcmcia_device */ | 136 | uniquely define a pcmcia_device */ |
@@ -151,25 +149,32 @@ struct pcmcia_device { | |||
151 | 149 | ||
152 | /* deprecated, will be cleaned up soon */ | 150 | /* deprecated, will be cleaned up soon */ |
153 | dev_node_t *dev_node; | 151 | dev_node_t *dev_node; |
154 | u_int state; | ||
155 | u_int open; | 152 | u_int open; |
156 | io_req_t io; | 153 | io_req_t io; |
157 | irq_req_t irq; | 154 | irq_req_t irq; |
158 | config_req_t conf; | 155 | config_req_t conf; |
159 | window_handle_t win; | 156 | window_handle_t win; |
160 | void *priv; | ||
161 | 157 | ||
162 | u_int p_state; | 158 | /* Is the device suspended? */ |
159 | u16 suspended:1; | ||
160 | |||
161 | /* Flags whether io, irq, win configurations were | ||
162 | * requested, and whether the configuration is "locked" */ | ||
163 | u16 _irq:1; | ||
164 | u16 _io:1; | ||
165 | u16 _win:4; | ||
166 | u16 _locked:1; | ||
163 | 167 | ||
164 | u8 suspended:1; | 168 | /* Flag whether a "fuzzy" func_id based match is |
165 | u8 reserved:3; | 169 | * allowed. */ |
170 | u16 allow_func_id_match:1; | ||
166 | 171 | ||
167 | /* information about this device */ | 172 | /* information about this device */ |
168 | u8 has_manf_id:1; | 173 | u16 has_manf_id:1; |
169 | u8 has_card_id:1; | 174 | u16 has_card_id:1; |
170 | u8 has_func_id:1; | 175 | u16 has_func_id:1; |
171 | 176 | ||
172 | u8 allow_func_id_match:1; | 177 | u16 reserved:4; |
173 | 178 | ||
174 | u8 func_id; | 179 | u8 func_id; |
175 | u16 manf_id; | 180 | u16 manf_id; |
@@ -183,6 +188,9 @@ struct pcmcia_device { | |||
183 | /* device driver wanted by cardmgr */ | 188 | /* device driver wanted by cardmgr */ |
184 | struct pcmcia_driver * cardmgr; | 189 | struct pcmcia_driver * cardmgr; |
185 | #endif | 190 | #endif |
191 | |||
192 | /* data private to drivers */ | ||
193 | void *priv; | ||
186 | }; | 194 | }; |
187 | 195 | ||
188 | #define to_pcmcia_dev(n) container_of(n, struct pcmcia_device, dev) | 196 | #define to_pcmcia_dev(n) container_of(n, struct pcmcia_device, dev) |