aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDominik Brodowski <linux@dominikbrodowski.net>2010-07-24 06:23:21 -0400
committerDominik Brodowski <linux@dominikbrodowski.net>2010-08-03 03:02:35 -0400
commit1d5cc192d431bce2ebe9fde64054ce903200e179 (patch)
treecdcdfb77712349bf46f0876d420e2be81f901d74
parentac8b422838046ffc26be4874a3cbae0d313f4209 (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>
-rw-r--r--drivers/net/pcmcia/axnet_cs.c3
-rw-r--r--drivers/net/pcmcia/nmclan_cs.c21
-rw-r--r--drivers/net/pcmcia/xirc2ps_cs.c16
-rw-r--r--drivers/net/wireless/hostap/hostap_cs.c91
-rw-r--r--drivers/net/wireless/orinoco/spectrum_cs.c32
-rw-r--r--drivers/pcmcia/cistpl.c7
-rw-r--r--drivers/pcmcia/cs_internal.h4
-rw-r--r--drivers/pcmcia/pcmcia_resource.c70
-rw-r--r--drivers/serial/serial_cs.c8
-rw-r--r--drivers/ssb/pcmcia.c14
-rw-r--r--include/pcmcia/cs.h12
-rw-r--r--include/pcmcia/ds.h4
12 files changed, 104 insertions, 178 deletions
diff --git a/drivers/net/pcmcia/axnet_cs.c b/drivers/net/pcmcia/axnet_cs.c
index 467fd4bfb2bd..ee0a6d036f94 100644
--- a/drivers/net/pcmcia/axnet_cs.c
+++ b/drivers/net/pcmcia/axnet_cs.c
@@ -378,8 +378,7 @@ static int axnet_config(struct pcmcia_device *link)
378 /* Maybe PHY is in power down mode. (PPD_SET = 1) 378 /* Maybe PHY is in power down mode. (PPD_SET = 1)
379 Bit 2 of CCSR is active low. */ 379 Bit 2 of CCSR is active low. */
380 if (i == 32) { 380 if (i == 32) {
381 conf_reg_t reg = { 0, CS_WRITE, CISREG_CCSR, 0x04 }; 381 pcmcia_write_config_byte(link, CISREG_CCSR, 0x04);
382 pcmcia_access_configuration_register(link, &reg);
383 for (i = 0; i < 32; i++) { 382 for (i = 0; i < 32; i++) {
384 j = mdio_read(dev->base_addr + AXNET_MII_EEP, i, 1); 383 j = mdio_read(dev->base_addr + AXNET_MII_EEP, i, 1);
385 j2 = mdio_read(dev->base_addr + AXNET_MII_EEP, i, 2); 384 j2 = mdio_read(dev->base_addr + AXNET_MII_EEP, i, 2);
diff --git a/drivers/net/pcmcia/nmclan_cs.c b/drivers/net/pcmcia/nmclan_cs.c
index c0eacfae1512..c0d85af3e942 100644
--- a/drivers/net/pcmcia/nmclan_cs.c
+++ b/drivers/net/pcmcia/nmclan_cs.c
@@ -757,29 +757,20 @@ static void nmclan_reset(struct net_device *dev)
757 757
758#if RESET_XILINX 758#if RESET_XILINX
759 struct pcmcia_device *link = &lp->link; 759 struct pcmcia_device *link = &lp->link;
760 conf_reg_t reg; 760 u8 OrigCorValue;
761 u_long OrigCorValue;
762 761
763 /* Save original COR value */ 762 /* Save original COR value */
764 reg.Function = 0; 763 pcmcia_read_config_byte(link, CISREG_COR, &OrigCorValue);
765 reg.Action = CS_READ;
766 reg.Offset = CISREG_COR;
767 reg.Value = 0;
768 pcmcia_access_configuration_register(link, &reg);
769 OrigCorValue = reg.Value;
770 764
771 /* Reset Xilinx */ 765 /* Reset Xilinx */
772 reg.Action = CS_WRITE; 766 dev_dbg(&link->dev, "nmclan_reset: OrigCorValue=0x%x, resetting...\n",
773 reg.Offset = CISREG_COR;
774 dev_dbg(&link->dev, "nmclan_reset: OrigCorValue=0x%lX, resetting...\n",
775 OrigCorValue); 767 OrigCorValue);
776 reg.Value = COR_SOFT_RESET; 768 pcmcia_write_config_byte(link, CISREG_COR, COR_SOFT_RESET);
777 pcmcia_access_configuration_register(link, &reg);
778 /* Need to wait for 20 ms for PCMCIA to finish reset. */ 769 /* Need to wait for 20 ms for PCMCIA to finish reset. */
779 770
780 /* Restore original COR configuration index */ 771 /* Restore original COR configuration index */
781 reg.Value = COR_LEVEL_REQ | (OrigCorValue & COR_CONFIG_MASK); 772 pcmcia_write_config_byte(link, CISREG_COR,
782 pcmcia_access_configuration_register(link, &reg); 773 (COR_LEVEL_REQ | (OrigCorValue & COR_CONFIG_MASK)));
783 /* Xilinx is now completely reset along with the MACE chip. */ 774 /* Xilinx is now completely reset along with the MACE chip. */
784 lp->tx_free_frames=AM2150_MAX_TX_FRAMES; 775 lp->tx_free_frames=AM2150_MAX_TX_FRAMES;
785 776
diff --git a/drivers/net/pcmcia/xirc2ps_cs.c b/drivers/net/pcmcia/xirc2ps_cs.c
index a7662f0832eb..e3a85ce89880 100644
--- a/drivers/net/pcmcia/xirc2ps_cs.c
+++ b/drivers/net/pcmcia/xirc2ps_cs.c
@@ -869,7 +869,6 @@ xirc2ps_config(struct pcmcia_device * link)
869 goto config_error; 869 goto config_error;
870 870
871 if (local->dingo) { 871 if (local->dingo) {
872 conf_reg_t reg;
873 win_req_t req; 872 win_req_t req;
874 memreq_t mem; 873 memreq_t mem;
875 874
@@ -878,15 +877,14 @@ xirc2ps_config(struct pcmcia_device * link)
878 * the base address of the ethernet port (BasePort1) is written 877 * the base address of the ethernet port (BasePort1) is written
879 * to the BAR registers of the modem. 878 * to the BAR registers of the modem.
880 */ 879 */
881 reg.Action = CS_WRITE; 880 err = pcmcia_write_config_byte(link, CISREG_IOBASE_0,
882 reg.Offset = CISREG_IOBASE_0; 881 link->io.BasePort2 & 0xff);
883 reg.Value = link->io.BasePort2 & 0xff; 882 if (err)
884 if ((err = pcmcia_access_configuration_register(link, &reg)))
885 goto config_error; 883 goto config_error;
886 reg.Action = CS_WRITE; 884
887 reg.Offset = CISREG_IOBASE_1; 885 err = pcmcia_write_config_byte(link, CISREG_IOBASE_1,
888 reg.Value = (link->io.BasePort2 >> 8) & 0xff; 886 (link->io.BasePort2 >> 8) & 0xff);
889 if ((err = pcmcia_access_configuration_register(link, &reg))) 887 if (err)
890 goto config_error; 888 goto config_error;
891 889
892 /* There is no config entry for the Ethernet part which 890 /* There is no config entry for the Ethernet part which
diff --git a/drivers/net/wireless/hostap/hostap_cs.c b/drivers/net/wireless/hostap/hostap_cs.c
index 2f4b6d4350ab..691293675a93 100644
--- a/drivers/net/wireless/hostap/hostap_cs.c
+++ b/drivers/net/wireless/hostap/hostap_cs.c
@@ -224,27 +224,18 @@ static int prism2_pccard_card_present(local_info_t *local)
224static void sandisk_set_iobase(local_info_t *local) 224static void sandisk_set_iobase(local_info_t *local)
225{ 225{
226 int res; 226 int res;
227 conf_reg_t reg;
228 struct hostap_cs_priv *hw_priv = local->hw_priv; 227 struct hostap_cs_priv *hw_priv = local->hw_priv;
229 228
230 reg.Function = 0; 229 res = pcmcia_write_config_byte(hw_priv->link, 0x10,
231 reg.Action = CS_WRITE; 230 hw_priv->link->io.BasePort1 & 0x00ff);
232 reg.Offset = 0x10; /* 0x3f0 IO base 1 */
233 reg.Value = hw_priv->link->io.BasePort1 & 0x00ff;
234 res = pcmcia_access_configuration_register(hw_priv->link,
235 &reg);
236 if (res != 0) { 231 if (res != 0) {
237 printk(KERN_DEBUG "Prism3 SanDisk - failed to set I/O base 0 -" 232 printk(KERN_DEBUG "Prism3 SanDisk - failed to set I/O base 0 -"
238 " res=%d\n", res); 233 " res=%d\n", res);
239 } 234 }
240 udelay(10); 235 udelay(10);
241 236
242 reg.Function = 0; 237 res = pcmcia_write_config_byte(hw_priv->link, 0x12,
243 reg.Action = CS_WRITE; 238 (hw_priv->link->io.BasePort1 >> 8) & 0x00ff);
244 reg.Offset = 0x12; /* 0x3f2 IO base 2 */
245 reg.Value = (hw_priv->link->io.BasePort1 & 0xff00) >> 8;
246 res = pcmcia_access_configuration_register(hw_priv->link,
247 &reg);
248 if (res != 0) { 239 if (res != 0) {
249 printk(KERN_DEBUG "Prism3 SanDisk - failed to set I/O base 1 -" 240 printk(KERN_DEBUG "Prism3 SanDisk - failed to set I/O base 1 -"
250 " res=%d\n", res); 241 " res=%d\n", res);
@@ -270,7 +261,6 @@ static void sandisk_write_hcr(local_info_t *local, int hcr)
270static int sandisk_enable_wireless(struct net_device *dev) 261static int sandisk_enable_wireless(struct net_device *dev)
271{ 262{
272 int res, ret = 0; 263 int res, ret = 0;
273 conf_reg_t reg;
274 struct hostap_interface *iface = netdev_priv(dev); 264 struct hostap_interface *iface = netdev_priv(dev);
275 local_info_t *local = iface->local; 265 local_info_t *local = iface->local;
276 struct hostap_cs_priv *hw_priv = local->hw_priv; 266 struct hostap_cs_priv *hw_priv = local->hw_priv;
@@ -297,12 +287,8 @@ static int sandisk_enable_wireless(struct net_device *dev)
297 " - using vendor-specific initialization\n", dev->name); 287 " - using vendor-specific initialization\n", dev->name);
298 hw_priv->sandisk_connectplus = 1; 288 hw_priv->sandisk_connectplus = 1;
299 289
300 reg.Function = 0; 290 res = pcmcia_write_config_byte(hw_priv->link, CISREG_COR,
301 reg.Action = CS_WRITE; 291 COR_SOFT_RESET);
302 reg.Offset = CISREG_COR;
303 reg.Value = COR_SOFT_RESET;
304 res = pcmcia_access_configuration_register(hw_priv->link,
305 &reg);
306 if (res != 0) { 292 if (res != 0) {
307 printk(KERN_DEBUG "%s: SanDisk - COR sreset failed (%d)\n", 293 printk(KERN_DEBUG "%s: SanDisk - COR sreset failed (%d)\n",
308 dev->name, res); 294 dev->name, res);
@@ -310,16 +296,13 @@ static int sandisk_enable_wireless(struct net_device *dev)
310 } 296 }
311 mdelay(5); 297 mdelay(5);
312 298
313 reg.Function = 0;
314 reg.Action = CS_WRITE;
315 reg.Offset = CISREG_COR;
316 /* 299 /*
317 * Do not enable interrupts here to avoid some bogus events. Interrupts 300 * Do not enable interrupts here to avoid some bogus events. Interrupts
318 * will be enabled during the first cor_sreset call. 301 * will be enabled during the first cor_sreset call.
319 */ 302 */
320 reg.Value = COR_LEVEL_REQ | 0x8 | COR_ADDR_DECODE | COR_FUNC_ENA; 303 res = pcmcia_write_config_byte(hw_priv->link, CISREG_COR,
321 res = pcmcia_access_configuration_register(hw_priv->link, 304 (COR_LEVEL_REQ | 0x8 | COR_ADDR_DECODE |
322 &reg); 305 COR_FUNC_ENA));
323 if (res != 0) { 306 if (res != 0) {
324 printk(KERN_DEBUG "%s: SanDisk - COR sreset failed (%d)\n", 307 printk(KERN_DEBUG "%s: SanDisk - COR sreset failed (%d)\n",
325 dev->name, res); 308 dev->name, res);
@@ -342,30 +325,23 @@ done:
342static void prism2_pccard_cor_sreset(local_info_t *local) 325static void prism2_pccard_cor_sreset(local_info_t *local)
343{ 326{
344 int res; 327 int res;
345 conf_reg_t reg; 328 u8 val;
346 struct hostap_cs_priv *hw_priv = local->hw_priv; 329 struct hostap_cs_priv *hw_priv = local->hw_priv;
347 330
348 if (!prism2_pccard_card_present(local)) 331 if (!prism2_pccard_card_present(local))
349 return; 332 return;
350 333
351 reg.Function = 0; 334 res = pcmcia_read_config_byte(hw_priv->link, CISREG_COR, &val);
352 reg.Action = CS_READ;
353 reg.Offset = CISREG_COR;
354 reg.Value = 0;
355 res = pcmcia_access_configuration_register(hw_priv->link,
356 &reg);
357 if (res != 0) { 335 if (res != 0) {
358 printk(KERN_DEBUG "prism2_pccard_cor_sreset failed 1 (%d)\n", 336 printk(KERN_DEBUG "prism2_pccard_cor_sreset failed 1 (%d)\n",
359 res); 337 res);
360 return; 338 return;
361 } 339 }
362 printk(KERN_DEBUG "prism2_pccard_cor_sreset: original COR %02x\n", 340 printk(KERN_DEBUG "prism2_pccard_cor_sreset: original COR %02x\n",
363 reg.Value); 341 val);
364 342
365 reg.Action = CS_WRITE; 343 val |= COR_SOFT_RESET;
366 reg.Value |= COR_SOFT_RESET; 344 res = pcmcia_write_config_byte(hw_priv->link, CISREG_COR, val);
367 res = pcmcia_access_configuration_register(hw_priv->link,
368 &reg);
369 if (res != 0) { 345 if (res != 0) {
370 printk(KERN_DEBUG "prism2_pccard_cor_sreset failed 2 (%d)\n", 346 printk(KERN_DEBUG "prism2_pccard_cor_sreset failed 2 (%d)\n",
371 res); 347 res);
@@ -374,11 +350,10 @@ static void prism2_pccard_cor_sreset(local_info_t *local)
374 350
375 mdelay(hw_priv->sandisk_connectplus ? 5 : 2); 351 mdelay(hw_priv->sandisk_connectplus ? 5 : 2);
376 352
377 reg.Value &= ~COR_SOFT_RESET; 353 val &= ~COR_SOFT_RESET;
378 if (hw_priv->sandisk_connectplus) 354 if (hw_priv->sandisk_connectplus)
379 reg.Value |= COR_IREQ_ENA; 355 val |= COR_IREQ_ENA;
380 res = pcmcia_access_configuration_register(hw_priv->link, 356 res = pcmcia_write_config_byte(hw_priv->link, CISREG_COR, val);
381 &reg);
382 if (res != 0) { 357 if (res != 0) {
383 printk(KERN_DEBUG "prism2_pccard_cor_sreset failed 3 (%d)\n", 358 printk(KERN_DEBUG "prism2_pccard_cor_sreset failed 3 (%d)\n",
384 res); 359 res);
@@ -395,8 +370,7 @@ static void prism2_pccard_cor_sreset(local_info_t *local)
395static void prism2_pccard_genesis_reset(local_info_t *local, int hcr) 370static void prism2_pccard_genesis_reset(local_info_t *local, int hcr)
396{ 371{
397 int res; 372 int res;
398 conf_reg_t reg; 373 u8 old_cor;
399 int old_cor;
400 struct hostap_cs_priv *hw_priv = local->hw_priv; 374 struct hostap_cs_priv *hw_priv = local->hw_priv;
401 375
402 if (!prism2_pccard_card_present(local)) 376 if (!prism2_pccard_card_present(local))
@@ -407,25 +381,17 @@ static void prism2_pccard_genesis_reset(local_info_t *local, int hcr)
407 return; 381 return;
408 } 382 }
409 383
410 reg.Function = 0; 384 res = pcmcia_read_config_byte(hw_priv->link, CISREG_COR, &old_cor);
411 reg.Action = CS_READ;
412 reg.Offset = CISREG_COR;
413 reg.Value = 0;
414 res = pcmcia_access_configuration_register(hw_priv->link,
415 &reg);
416 if (res != 0) { 385 if (res != 0) {
417 printk(KERN_DEBUG "prism2_pccard_genesis_sreset failed 1 " 386 printk(KERN_DEBUG "prism2_pccard_genesis_sreset failed 1 "
418 "(%d)\n", res); 387 "(%d)\n", res);
419 return; 388 return;
420 } 389 }
421 printk(KERN_DEBUG "prism2_pccard_genesis_sreset: original COR %02x\n", 390 printk(KERN_DEBUG "prism2_pccard_genesis_sreset: original COR %02x\n",
422 reg.Value); 391 old_cor);
423 old_cor = reg.Value;
424 392
425 reg.Action = CS_WRITE; 393 res = pcmcia_write_config_byte(hw_priv->link, CISREG_COR,
426 reg.Value |= COR_SOFT_RESET; 394 old_cor | COR_SOFT_RESET);
427 res = pcmcia_access_configuration_register(hw_priv->link,
428 &reg);
429 if (res != 0) { 395 if (res != 0) {
430 printk(KERN_DEBUG "prism2_pccard_genesis_sreset failed 2 " 396 printk(KERN_DEBUG "prism2_pccard_genesis_sreset failed 2 "
431 "(%d)\n", res); 397 "(%d)\n", res);
@@ -435,11 +401,7 @@ static void prism2_pccard_genesis_reset(local_info_t *local, int hcr)
435 mdelay(10); 401 mdelay(10);
436 402
437 /* Setup Genesis mode */ 403 /* Setup Genesis mode */
438 reg.Action = CS_WRITE; 404 res = pcmcia_write_config_byte(hw_priv->link, CISREG_CCSR, hcr);
439 reg.Value = hcr;
440 reg.Offset = CISREG_CCSR;
441 res = pcmcia_access_configuration_register(hw_priv->link,
442 &reg);
443 if (res != 0) { 405 if (res != 0) {
444 printk(KERN_DEBUG "prism2_pccard_genesis_sreset failed 3 " 406 printk(KERN_DEBUG "prism2_pccard_genesis_sreset failed 3 "
445 "(%d)\n", res); 407 "(%d)\n", res);
@@ -447,11 +409,8 @@ static void prism2_pccard_genesis_reset(local_info_t *local, int hcr)
447 } 409 }
448 mdelay(10); 410 mdelay(10);
449 411
450 reg.Action = CS_WRITE; 412 res = pcmcia_write_config_byte(hw_priv->link, CISREG_COR,
451 reg.Offset = CISREG_COR; 413 old_cor & ~COR_SOFT_RESET);
452 reg.Value = old_cor & ~COR_SOFT_RESET;
453 res = pcmcia_access_configuration_register(hw_priv->link,
454 &reg);
455 if (res != 0) { 414 if (res != 0) {
456 printk(KERN_DEBUG "prism2_pccard_genesis_sreset failed 4 " 415 printk(KERN_DEBUG "prism2_pccard_genesis_sreset failed 4 "
457 "(%d)\n", res); 416 "(%d)\n", res);
diff --git a/drivers/net/wireless/orinoco/spectrum_cs.c b/drivers/net/wireless/orinoco/spectrum_cs.c
index cad30e499dba..39399cd2e683 100644
--- a/drivers/net/wireless/orinoco/spectrum_cs.c
+++ b/drivers/net/wireless/orinoco/spectrum_cs.c
@@ -79,35 +79,27 @@ static int
79spectrum_reset(struct pcmcia_device *link, int idle) 79spectrum_reset(struct pcmcia_device *link, int idle)
80{ 80{
81 int ret; 81 int ret;
82 conf_reg_t reg; 82 u8 save_cor;
83 u_int save_cor; 83 u8 ccsr;
84 84
85 /* Doing it if hardware is gone is guaranteed crash */ 85 /* Doing it if hardware is gone is guaranteed crash */
86 if (!pcmcia_dev_present(link)) 86 if (!pcmcia_dev_present(link))
87 return -ENODEV; 87 return -ENODEV;
88 88
89 /* Save original COR value */ 89 /* Save original COR value */
90 reg.Function = 0; 90 ret = pcmcia_read_config_byte(link, CISREG_COR, &save_cor);
91 reg.Action = CS_READ;
92 reg.Offset = CISREG_COR;
93 ret = pcmcia_access_configuration_register(link, &reg);
94 if (ret) 91 if (ret)
95 goto failed; 92 goto failed;
96 save_cor = reg.Value;
97 93
98 /* Soft-Reset card */ 94 /* Soft-Reset card */
99 reg.Action = CS_WRITE; 95 ret = pcmcia_write_config_byte(link, CISREG_COR,
100 reg.Offset = CISREG_COR; 96 (save_cor | COR_SOFT_RESET));
101 reg.Value = (save_cor | COR_SOFT_RESET);
102 ret = pcmcia_access_configuration_register(link, &reg);
103 if (ret) 97 if (ret)
104 goto failed; 98 goto failed;
105 udelay(1000); 99 udelay(1000);
106 100
107 /* Read CCSR */ 101 /* Read CCSR */
108 reg.Action = CS_READ; 102 ret = pcmcia_read_config_byte(link, CISREG_CCSR, &ccsr);
109 reg.Offset = CISREG_CCSR;
110 ret = pcmcia_access_configuration_register(link, &reg);
111 if (ret) 103 if (ret)
112 goto failed; 104 goto failed;
113 105
@@ -115,19 +107,15 @@ spectrum_reset(struct pcmcia_device *link, int idle)
115 * Start or stop the firmware. Memory width bit should be 107 * Start or stop the firmware. Memory width bit should be
116 * preserved from the value we've just read. 108 * preserved from the value we've just read.
117 */ 109 */
118 reg.Action = CS_WRITE; 110 ccsr = (idle ? HCR_IDLE : HCR_RUN) | (ccsr & HCR_MEM16);
119 reg.Offset = CISREG_CCSR; 111 ret = pcmcia_write_config_byte(link, CISREG_CCSR, ccsr);
120 reg.Value = (idle ? HCR_IDLE : HCR_RUN) | (reg.Value & HCR_MEM16);
121 ret = pcmcia_access_configuration_register(link, &reg);
122 if (ret) 112 if (ret)
123 goto failed; 113 goto failed;
124 udelay(1000); 114 udelay(1000);
125 115
126 /* Restore original COR configuration index */ 116 /* Restore original COR configuration index */
127 reg.Action = CS_WRITE; 117 ret = pcmcia_write_config_byte(link, CISREG_COR,
128 reg.Offset = CISREG_COR; 118 (save_cor & ~COR_SOFT_RESET));
129 reg.Value = (save_cor & ~COR_SOFT_RESET);
130 ret = pcmcia_access_configuration_register(link, &reg);
131 if (ret) 119 if (ret)
132 goto failed; 120 goto failed;
133 udelay(1000); 121 udelay(1000);
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,
diff --git a/drivers/serial/serial_cs.c b/drivers/serial/serial_cs.c
index 2b99c7baf35b..2be8b107ed51 100644
--- a/drivers/serial/serial_cs.c
+++ b/drivers/serial/serial_cs.c
@@ -114,16 +114,14 @@ static void quirk_setup_brainboxes_0104(struct pcmcia_device *link, struct uart_
114 114
115static int quirk_post_ibm(struct pcmcia_device *link) 115static int quirk_post_ibm(struct pcmcia_device *link)
116{ 116{
117 conf_reg_t reg = { 0, CS_READ, 0x800, 0 }; 117 u8 val;
118 int ret; 118 int ret;
119 119
120 ret = pcmcia_access_configuration_register(link, &reg); 120 ret = pcmcia_read_config_byte(link, 0x800, &val);
121 if (ret) 121 if (ret)
122 goto failed; 122 goto failed;
123 123
124 reg.Action = CS_WRITE; 124 ret = pcmcia_write_config_byte(link, 0x800, val | 1);
125 reg.Value = reg.Value | 1;
126 ret = pcmcia_access_configuration_register(link, &reg);
127 if (ret) 125 if (ret)
128 goto failed; 126 goto failed;
129 return 0; 127 return 0;
diff --git a/drivers/ssb/pcmcia.c b/drivers/ssb/pcmcia.c
index 21520308178b..526682d68de8 100644
--- a/drivers/ssb/pcmcia.c
+++ b/drivers/ssb/pcmcia.c
@@ -71,14 +71,9 @@
71/* Write to a PCMCIA configuration register. */ 71/* Write to a PCMCIA configuration register. */
72static int ssb_pcmcia_cfg_write(struct ssb_bus *bus, u8 offset, u8 value) 72static int ssb_pcmcia_cfg_write(struct ssb_bus *bus, u8 offset, u8 value)
73{ 73{
74 conf_reg_t reg;
75 int res; 74 int res;
76 75
77 memset(&reg, 0, sizeof(reg)); 76 res = pcmcia_write_config_byte(bus->host_pcmcia, offset, value);
78 reg.Offset = offset;
79 reg.Action = CS_WRITE;
80 reg.Value = value;
81 res = pcmcia_access_configuration_register(bus->host_pcmcia, &reg);
82 if (unlikely(res != 0)) 77 if (unlikely(res != 0))
83 return -EBUSY; 78 return -EBUSY;
84 79
@@ -88,16 +83,11 @@ static int ssb_pcmcia_cfg_write(struct ssb_bus *bus, u8 offset, u8 value)
88/* Read from a PCMCIA configuration register. */ 83/* Read from a PCMCIA configuration register. */
89static int ssb_pcmcia_cfg_read(struct ssb_bus *bus, u8 offset, u8 *value) 84static int ssb_pcmcia_cfg_read(struct ssb_bus *bus, u8 offset, u8 *value)
90{ 85{
91 conf_reg_t reg;
92 int res; 86 int res;
93 87
94 memset(&reg, 0, sizeof(reg)); 88 res = pcmcia_read_config_byte(bus->host_pcmcia, offset, value);
95 reg.Offset = offset;
96 reg.Action = CS_READ;
97 res = pcmcia_access_configuration_register(bus->host_pcmcia, &reg);
98 if (unlikely(res != 0)) 89 if (unlikely(res != 0))
99 return -EBUSY; 90 return -EBUSY;
100 *value = reg.Value;
101 91
102 return 0; 92 return 0;
103} 93}
diff --git a/include/pcmcia/cs.h b/include/pcmcia/cs.h
index c78d9b112080..64e853d58c35 100644
--- a/include/pcmcia/cs.h
+++ b/include/pcmcia/cs.h
@@ -19,18 +19,6 @@
19#include <linux/interrupt.h> 19#include <linux/interrupt.h>
20#endif 20#endif
21 21
22/* For AccessConfigurationRegister */
23typedef struct conf_reg_t {
24 u_char Function;
25 u_int Action;
26 off_t Offset;
27 u_int Value;
28} conf_reg_t;
29
30/* Actions */
31#define CS_READ 1
32#define CS_WRITE 2
33
34/* for AdjustResourceInfo */ 22/* for AdjustResourceInfo */
35/* Action field */ 23/* Action field */
36#define REMOVE_MANAGED_RESOURCE 1 24#define REMOVE_MANAGED_RESOURCE 1
diff --git a/include/pcmcia/ds.h b/include/pcmcia/ds.h
index e614aa0ca2a2..d494ce417b4f 100644
--- a/include/pcmcia/ds.h
+++ b/include/pcmcia/ds.h
@@ -174,8 +174,8 @@ struct pcmcia_device *pcmcia_dev_present(struct pcmcia_device *p_dev);
174int pcmcia_reset_card(struct pcmcia_socket *skt); 174int pcmcia_reset_card(struct pcmcia_socket *skt);
175 175
176/* CIS config */ 176/* CIS config */
177int pcmcia_access_configuration_register(struct pcmcia_device *p_dev, 177int pcmcia_read_config_byte(struct pcmcia_device *p_dev, off_t where, u8 *val);
178 conf_reg_t *reg); 178int pcmcia_write_config_byte(struct pcmcia_device *p_dev, off_t where, u8 val);
179 179
180/* device configuration */ 180/* device configuration */
181int pcmcia_request_io(struct pcmcia_device *p_dev, io_req_t *req); 181int pcmcia_request_io(struct pcmcia_device *p_dev, io_req_t *req);