--9zSXsLTf0vkW971A
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

On Tue, Dec 23, 2003 at 01:03:04PM -0800, Andrew Morton wrote:
> Arjan van de Ven <arjanv@redhat.com> wrote:
> >
> > fwiw below is the ide-cs transformation.
> 
> Gack, that was utterly mimeified and I was unable to persuade sylpheed to
> decrypt it.  Attachements from you, my man!

AARGH I need to kick mutt in the butt; one more try with both attached and
inline; if it's still horked I need to go read some mutt code ;(



 25-akpm/drivers/ide/legacy/ide-cs.c |   57 +++++++++++++++++-------------------
 1 files changed, 28 insertions(+), 29 deletions(-)

diff -puN drivers/ide/legacy/ide-cs.c~remove-CardServices-from-ide-cs drivers/ide/legacy/ide-cs.c
--- 25/drivers/ide/legacy/ide-cs.c~remove-CardServices-from-ide-cs	Tue Dec 23 13:29:09 2003
+++ 25-akpm/drivers/ide/legacy/ide-cs.c	Tue Dec 23 13:29:09 2003
@@ -152,7 +152,7 @@ static dev_link_t *ide_attach(void)
     client_reg.event_handler = &ide_event;
     client_reg.Version = 0x0210;
     client_reg.event_callback_args.client_data = link;
-    ret = CardServices(RegisterClient, &link->handle, &client_reg);
+    ret = pcmcia_register_client(&link->handle, &client_reg);
     if (ret != CS_SUCCESS) {
 	cs_error(link->handle, RegisterClient, ret);
 	ide_detach(link);
@@ -188,7 +188,7 @@ static void ide_detach(dev_link_t *link)
 	ide_release(link);
     
     if (link->handle) {
-	ret = CardServices(DeregisterClient, link->handle);
+	ret = pcmcia_deregister_client(link->handle);
 	if (ret != CS_SUCCESS)
 	    cs_error(link->handle, DeregisterClient, ret);
     }
@@ -207,11 +207,8 @@ static void ide_detach(dev_link_t *link)
 
 ======================================================================*/
 
-#define CS_CHECK(fn, args...) \
-while ((last_ret=CardServices(last_fn=(fn), args))!=0) goto cs_failed
-
-#define CFG_CHECK(fn, args...) \
-if (CardServices(fn, args) != 0) goto next_entry
+#define CS_CHECK(fn, ret) \
+do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0)
 
 static int idecs_register(unsigned long io, unsigned long ctl, unsigned long irq)
 {
@@ -241,16 +238,16 @@ void ide_config(dev_link_t *link)
     tuple.TupleOffset = 0; tuple.TupleDataMax = 255;
     tuple.Attributes = 0;
     tuple.DesiredTuple = CISTPL_CONFIG;
-    CS_CHECK(GetFirstTuple, handle, &tuple);
-    CS_CHECK(GetTupleData, handle, &tuple);
-    CS_CHECK(ParseTuple, handle, &tuple, &parse);
+    CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple));
+    CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple));
+    CS_CHECK(ParseTuple, pcmcia_parse_tuple(handle, &tuple, &parse));
     link->conf.ConfigBase = parse.config.base;
     link->conf.Present = parse.config.rmask[0];
 
     tuple.DesiredTuple = CISTPL_MANFID;
-    if (!CardServices(GetFirstTuple, handle, &tuple) &&
-	!CardServices(GetTupleData, handle, &tuple) &&
-	!CardServices(ParseTuple, handle, &tuple, &parse))
+    if (!pcmcia_get_first_tuple(handle, &tuple) &&
+	!pcmcia_get_tuple_data(handle, &tuple) &&
+	!pcmcia_parse_tuple(handle, &tuple, &parse))
 	is_kme = ((parse.manfid.manf == MANFID_KME) &&
 		  ((parse.manfid.card == PRODID_KME_KXLC005_A) ||
 		   (parse.manfid.card == PRODID_KME_KXLC005_B)));
@@ -259,16 +256,16 @@ void ide_config(dev_link_t *link)
     link->state |= DEV_CONFIG;
 
     /* Not sure if this is right... look up the current Vcc */
-    CS_CHECK(GetConfigurationInfo, handle, &conf);
+    CS_CHECK(GetConfigurationInfo, pcmcia_get_configuration_info(handle, &conf));
     link->conf.Vcc = conf.Vcc;
     
     pass = io_base = ctl_base = 0;
     tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY;
     tuple.Attributes = 0;
-    CS_CHECK(GetFirstTuple, handle, &tuple);
+    CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple));
     while (1) {
-	CFG_CHECK(GetTupleData, handle, &tuple);
-	CFG_CHECK(ParseTuple, handle, &tuple, &parse);
+    	if (pcmcia_get_tuple_data(handle, &tuple) != 0) goto next_entry;
+	if (pcmcia_parse_tuple(handle, &tuple, &parse) != 0) goto next_entry;
 
 	/* Check for matching Vcc, unless we're desperate */
 	if (!pass) {
@@ -299,13 +296,15 @@ void ide_config(dev_link_t *link)
 		link->io.NumPorts1 = 8;
 		link->io.BasePort2 = io->win[1].base;
 		link->io.NumPorts2 = (is_kme) ? 2 : 1;
-		CFG_CHECK(RequestIO, link->handle, &link->io);
+		if (pcmcia_request_io(link->handle, &link->io) != 0)
+			goto next_entry;
 		io_base = link->io.BasePort1;
 		ctl_base = link->io.BasePort2;
 	    } else if ((io->nwin == 1) && (io->win[0].len >= 16)) {
 		link->io.NumPorts1 = io->win[0].len;
 		link->io.NumPorts2 = 0;
-		CFG_CHECK(RequestIO, link->handle, &link->io);
+		if (pcmcia_request_io(link->handle, &link->io) != 0)
+			goto next_entry;
 		io_base = link->io.BasePort1;
 		ctl_base = link->io.BasePort1+0x0e;
 	    } else goto next_entry;
@@ -316,16 +315,16 @@ void ide_config(dev_link_t *link)
     next_entry:
 	if (cfg->flags & CISTPL_CFTABLE_DEFAULT) dflt = *cfg;
 	if (pass) {
-	    CS_CHECK(GetNextTuple, handle, &tuple);
-	} else if (CardServices(GetNextTuple, handle, &tuple) != 0) {
-	    CS_CHECK(GetFirstTuple, handle, &tuple);
+	    CS_CHECK(GetNextTuple, pcmcia_get_next_tuple(handle, &tuple));
+	} else if (pcmcia_get_next_tuple(handle, &tuple) != 0) {
+	    CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple));
 	    memset(&dflt, 0, sizeof(dflt));
 	    pass++;
 	}
     }
     
-    CS_CHECK(RequestIRQ, handle, &link->irq);
-    CS_CHECK(RequestConfiguration, handle, &link->conf);
+    CS_CHECK(RequestIRQ, pcmcia_request_irq(handle, &link->irq));
+    CS_CHECK(RequestConfiguration, pcmcia_request_configuration(handle, &link->conf));
 
     /* deal with brain dead IDE resource management */
     release_region(link->io.BasePort1, link->io.NumPorts1);
@@ -413,9 +412,9 @@ void ide_release(dev_link_t *link)
     info->ndev = 0;
     link->dev = NULL;
     
-    CardServices(ReleaseConfiguration, link->handle);
-    CardServices(ReleaseIO, link->handle, &link->io);
-    CardServices(ReleaseIRQ, link->handle, &link->irq);
+    pcmcia_release_configuration(link->handle);
+    pcmcia_release_io(link->handle, &link->io);
+    pcmcia_release_irq(link->handle, &link->irq);
     
     link->state &= ~DEV_CONFIG;
 
@@ -452,14 +451,14 @@ int ide_event(event_t event, int priorit
 	/* Fall through... */
     case CS_EVENT_RESET_PHYSICAL:
 	if (link->state & DEV_CONFIG)
-	    CardServices(ReleaseConfiguration, link->handle);
+	    pcmcia_release_configuration(link->handle);
 	break;
     case CS_EVENT_PM_RESUME:
 	link->state &= ~DEV_SUSPEND;
 	/* Fall through... */
     case CS_EVENT_CARD_RESET:
 	if (DEV_OK(link))
-	    CardServices(RequestConfiguration, link->handle, &link->conf);
+	    pcmcia_request_configuration(link->handle, &link->conf);
 	break;
     }
     return 0;

_