diff options
author | Dominik Brodowski <linux@dominikbrodowski.net> | 2010-07-24 06:23:21 -0400 |
---|---|---|
committer | Dominik Brodowski <linux@dominikbrodowski.net> | 2010-08-03 03:02:35 -0400 |
commit | 1d5cc192d431bce2ebe9fde64054ce903200e179 (patch) | |
tree | cdcdfb77712349bf46f0876d420e2be81f901d74 /drivers/pcmcia | |
parent | ac8b422838046ffc26be4874a3cbae0d313f4209 (diff) |
pcmcia: use pcmica_{read,write}_config_byte
Use pcmcia_read_config_byte and pcmcia_write_config_byte instead
of pcmcia_access_configuration_register.
CC: netdev@vger.kernel.org
CC: linux-wireless@vger.kernel.org
CC: linux-serial@vger.kernel.org
CC: Michael Buesch <mb@bu3sch.de>
Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
Diffstat (limited to 'drivers/pcmcia')
-rw-r--r-- | drivers/pcmcia/cistpl.c | 7 | ||||
-rw-r--r-- | drivers/pcmcia/cs_internal.h | 4 | ||||
-rw-r--r-- | drivers/pcmcia/pcmcia_resource.c | 70 |
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 | */ |
212 | void pcmcia_write_cis_mem(struct pcmcia_socket *s, int attr, u_int addr, | 212 | int 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 | ||
159 | int pcmcia_read_cis_mem(struct pcmcia_socket *s, int attr, | 159 | int 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); |
161 | void pcmcia_write_cis_mem(struct pcmcia_socket *s, int attr, | 161 | int 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); |
163 | void release_cis_mem(struct pcmcia_socket *s); | 163 | void release_cis_mem(struct pcmcia_socket *s); |
164 | void destroy_cis_cache(struct pcmcia_socket *s); | 164 | void destroy_cis_cache(struct pcmcia_socket *s); |
165 | int pccard_read_tuple(struct pcmcia_socket *s, unsigned int function, | 165 | int 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 | 119 | static int pcmcia_access_config(struct pcmcia_device *p_dev, | |
118 | int 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 */ |
160 | EXPORT_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 | */ | ||
157 | int 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 | } | ||
161 | EXPORT_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 | */ | ||
170 | int 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 | } | ||
174 | EXPORT_SYMBOL(pcmcia_write_config_byte); | ||
161 | 175 | ||
162 | 176 | ||
163 | int pcmcia_map_mem_page(struct pcmcia_device *p_dev, window_handle_t wh, | 177 | int pcmcia_map_mem_page(struct pcmcia_device *p_dev, window_handle_t wh, |