aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pcmcia
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/pcmcia')
-rw-r--r--drivers/pcmcia/cistpl.c7
-rw-r--r--drivers/pcmcia/cs_internal.h4
-rw-r--r--drivers/pcmcia/pcmcia_resource.c70
3 files changed, 48 insertions, 33 deletions
diff --git a/drivers/pcmcia/cistpl.c b/drivers/pcmcia/cistpl.c
index ba4a5acc2e9a..1733fab469a1 100644
--- a/drivers/pcmcia/cistpl.c
+++ b/drivers/pcmcia/cistpl.c
@@ -209,7 +209,7 @@ int pcmcia_read_cis_mem(struct pcmcia_socket *s, int attr, u_int addr,
209 * Probably only useful for writing one-byte registers. Must be called 209 * Probably only useful for writing one-byte registers. Must be called
210 * with ops_mutex held. 210 * with ops_mutex held.
211 */ 211 */
212void pcmcia_write_cis_mem(struct pcmcia_socket *s, int attr, u_int addr, 212int pcmcia_write_cis_mem(struct pcmcia_socket *s, int attr, u_int addr,
213 u_int len, void *ptr) 213 u_int len, void *ptr)
214{ 214{
215 void __iomem *sys, *end; 215 void __iomem *sys, *end;
@@ -231,7 +231,7 @@ void pcmcia_write_cis_mem(struct pcmcia_socket *s, int attr, u_int addr,
231 ((cis_width) ? MAP_16BIT : 0)); 231 ((cis_width) ? MAP_16BIT : 0));
232 if (!sys) { 232 if (!sys) {
233 dev_dbg(&s->dev, "could not map memory\n"); 233 dev_dbg(&s->dev, "could not map memory\n");
234 return; /* FIXME: Error */ 234 return -EINVAL;
235 } 235 }
236 236
237 writeb(flags, sys+CISREG_ICTRL0); 237 writeb(flags, sys+CISREG_ICTRL0);
@@ -256,7 +256,7 @@ void pcmcia_write_cis_mem(struct pcmcia_socket *s, int attr, u_int addr,
256 sys = set_cis_map(s, card_offset, flags); 256 sys = set_cis_map(s, card_offset, flags);
257 if (!sys) { 257 if (!sys) {
258 dev_dbg(&s->dev, "could not map memory\n"); 258 dev_dbg(&s->dev, "could not map memory\n");
259 return; /* FIXME: error */ 259 return -EINVAL;
260 } 260 }
261 261
262 end = sys + s->map_size; 262 end = sys + s->map_size;
@@ -270,6 +270,7 @@ void pcmcia_write_cis_mem(struct pcmcia_socket *s, int attr, u_int addr,
270 addr = 0; 270 addr = 0;
271 } 271 }
272 } 272 }
273 return 0;
273} 274}
274 275
275 276
diff --git a/drivers/pcmcia/cs_internal.h b/drivers/pcmcia/cs_internal.h
index 45e7fd1aa0bf..cebd40da8b9b 100644
--- a/drivers/pcmcia/cs_internal.h
+++ b/drivers/pcmcia/cs_internal.h
@@ -158,8 +158,8 @@ extern struct bin_attribute pccard_cis_attr;
158 158
159int pcmcia_read_cis_mem(struct pcmcia_socket *s, int attr, 159int pcmcia_read_cis_mem(struct pcmcia_socket *s, int attr,
160 u_int addr, u_int len, void *ptr); 160 u_int addr, u_int len, void *ptr);
161void pcmcia_write_cis_mem(struct pcmcia_socket *s, int attr, 161int pcmcia_write_cis_mem(struct pcmcia_socket *s, int attr,
162 u_int addr, u_int len, void *ptr); 162 u_int addr, u_int len, void *ptr);
163void release_cis_mem(struct pcmcia_socket *s); 163void release_cis_mem(struct pcmcia_socket *s);
164void destroy_cis_cache(struct pcmcia_socket *s); 164void destroy_cis_cache(struct pcmcia_socket *s);
165int pccard_read_tuple(struct pcmcia_socket *s, unsigned int function, 165int pccard_read_tuple(struct pcmcia_socket *s, unsigned int function,
diff --git a/drivers/pcmcia/pcmcia_resource.c b/drivers/pcmcia/pcmcia_resource.c
index 2394de468602..563750e77eaf 100644
--- a/drivers/pcmcia/pcmcia_resource.c
+++ b/drivers/pcmcia/pcmcia_resource.c
@@ -108,25 +108,25 @@ static void release_io_space(struct pcmcia_socket *s, unsigned int base,
108} /* release_io_space */ 108} /* release_io_space */
109 109
110 110
111/** pccard_access_configuration_register 111/**
112 * pcmcia_access_config() - read or write card configuration registers
112 * 113 *
113 * Access_configuration_register() reads and writes configuration 114 * pcmcia_access_config() reads and writes configuration registers in
114 * registers in attribute memory. Memory window 0 is reserved for 115 * attribute memory. Memory window 0 is reserved for this and the tuple
115 * this and the tuple reading services. 116 * reading services. Drivers must use pcmcia_read_config_byte() or
117 * pcmcia_write_config_byte().
116 */ 118 */
117 119static int pcmcia_access_config(struct pcmcia_device *p_dev,
118int pcmcia_access_configuration_register(struct pcmcia_device *p_dev, 120 off_t where, u8 *val,
119 conf_reg_t *reg) 121 int (*accessf) (struct pcmcia_socket *s,
122 int attr, unsigned int addr,
123 unsigned int len, void *ptr))
120{ 124{
121 struct pcmcia_socket *s; 125 struct pcmcia_socket *s;
122 config_t *c; 126 config_t *c;
123 int addr; 127 int addr;
124 u_char val;
125 int ret = 0; 128 int ret = 0;
126 129
127 if (!p_dev || !p_dev->function_config)
128 return -EINVAL;
129
130 s = p_dev->socket; 130 s = p_dev->socket;
131 131
132 mutex_lock(&s->ops_mutex); 132 mutex_lock(&s->ops_mutex);
@@ -138,26 +138,40 @@ int pcmcia_access_configuration_register(struct pcmcia_device *p_dev,
138 return -EACCES; 138 return -EACCES;
139 } 139 }
140 140
141 addr = (c->ConfigBase + reg->Offset) >> 1; 141 addr = (c->ConfigBase + where) >> 1;
142
143 ret = accessf(s, 1, addr, 1, val);
142 144
143 switch (reg->Action) {
144 case CS_READ:
145 ret = pcmcia_read_cis_mem(s, 1, addr, 1, &val);
146 reg->Value = val;
147 break;
148 case CS_WRITE:
149 val = reg->Value;
150 pcmcia_write_cis_mem(s, 1, addr, 1, &val);
151 break;
152 default:
153 dev_dbg(&s->dev, "Invalid conf register request\n");
154 ret = -EINVAL;
155 break;
156 }
157 mutex_unlock(&s->ops_mutex); 145 mutex_unlock(&s->ops_mutex);
146
158 return ret; 147 return ret;
159} /* pcmcia_access_configuration_register */ 148} /* pcmcia_access_config */
160EXPORT_SYMBOL(pcmcia_access_configuration_register); 149
150
151/**
152 * pcmcia_read_config_byte() - read a byte from a card configuration register
153 *
154 * pcmcia_read_config_byte() reads a byte from a configuration register in
155 * attribute memory.
156 */
157int pcmcia_read_config_byte(struct pcmcia_device *p_dev, off_t where, u8 *val)
158{
159 return pcmcia_access_config(p_dev, where, val, pcmcia_read_cis_mem);
160}
161EXPORT_SYMBOL(pcmcia_read_config_byte);
162
163
164/**
165 * pcmcia_write_config_byte() - write a byte to a card configuration register
166 *
167 * pcmcia_write_config_byte() writes a byte to a configuration register in
168 * attribute memory.
169 */
170int pcmcia_write_config_byte(struct pcmcia_device *p_dev, off_t where, u8 val)
171{
172 return pcmcia_access_config(p_dev, where, &val, pcmcia_write_cis_mem);
173}
174EXPORT_SYMBOL(pcmcia_write_config_byte);
161 175
162 176
163int pcmcia_map_mem_page(struct pcmcia_device *p_dev, window_handle_t wh, 177int pcmcia_map_mem_page(struct pcmcia_device *p_dev, window_handle_t wh,