[PATCH 2.6] yenta: add an extra init function, don't overwrite global one

Daniel Ritz daniel.ritz at gmx.ch
Sun Aug 17 03:51:07 BST 2003


hi

a patch to stop the override functions from overwriting the global init
function with their own...done by adding an extra function pointer to
struct yenta_socket, call the function from yenta_init.

rgds
-daniel


--- 1.38/drivers/pcmcia/yenta_socket.c	Fri Aug 15 01:53:49 2003
+++ edited/drivers/pcmcia/yenta_socket.c	Sun Aug 17 01:41:21 2003
@@ -582,6 +582,10 @@
 	yenta_config_init(socket);
 	yenta_clear_maps(socket);
 
+	/* chip sepcific init */
+	if (socket->extra_init)
+		socket->extra_init(socket);
+
 	/* Re-enable interrupts */
 	cb_writel(socket, CB_SOCKET_MASK, CB_CDMASK);
 	return 0;
--- 1.6/drivers/pcmcia/yenta_socket.h	Mon Jun 30 22:33:00 2003
+++ edited/drivers/pcmcia/yenta_socket.h	Sun Aug 17 01:41:04 2003
@@ -103,6 +103,9 @@
 
 	struct pcmcia_socket socket;
 
+	/* additional chip specific init function  */
+	int (*extra_init)(struct yenta_socket *socket);
+
 	/* A few words of private data for special stuff of overrides... */
 	unsigned int private[8];
 };
--- 1.14/drivers/pcmcia/ti113x.h	Thu Aug  7 00:59:05 2003
+++ edited/drivers/pcmcia/ti113x.h	Sun Aug 17 01:41:41 2003
@@ -207,9 +207,8 @@
 	config_writeb(socket, 0x84, reg);
 }
 
-static void ti_set_zv(struct pcmcia_socket *sock)
+static void ti_set_zv(struct yenta_socket *socket)
 {
-	struct yenta_socket *socket = container_of(sock, struct yenta_socket, socket);
 	if(socket->dev->vendor == PCI_VENDOR_ID_TI)
 	{
 		switch(socket->dev->device)
@@ -218,21 +217,19 @@
 			case PCI_DEVICE_ID_TI_1220:
 			case PCI_DEVICE_ID_TI_1221:
 			case PCI_DEVICE_ID_TI_1225:
-				sock->zoom_video = ti_zoom_video;
+				socket->socket.zoom_video = ti_zoom_video;
 				break;	
 			case PCI_DEVICE_ID_TI_1250:
 			case PCI_DEVICE_ID_TI_1251A:
 			case PCI_DEVICE_ID_TI_1251B:
 			case PCI_DEVICE_ID_TI_1450:
-				sock->zoom_video = ti1250_zoom_video;
+				socket->socket.zoom_video = ti1250_zoom_video;
 		}
 	}
 }
-static int ti_init(struct pcmcia_socket *sock)
+static int ti_init(struct yenta_socket *socket)
 {
-	struct yenta_socket *socket = container_of(sock, struct yenta_socket, socket);
-	yenta_init(sock);
-	ti_set_zv(sock);
+	ti_set_zv(socket);
 	ti_intctl(socket);
 	return 0;
 }
@@ -285,7 +282,7 @@
 	}
 #endif
 
-	socket->socket.ops->init = ti_init;
+	socket->extra_init = ti_init;
 	return 0;
 }
 
@@ -296,11 +293,9 @@
 #define ti_irqmux(socket)	((socket)->private[4])
 
 
-static int ti113x_init(struct pcmcia_socket *sock)
+static int ti113x_init(struct yenta_socket *socket)
 {
-	struct yenta_socket *socket = container_of(sock, struct yenta_socket, socket);
-	yenta_init(sock);
-	ti_set_zv(sock);
+	ti_set_zv(socket);
 
 	config_writel(socket, TI113X_SYSTEM_CONTROL, ti_sysctl(socket));
 	config_writeb(socket, TI113X_CARD_CONTROL, ti_cardctl(socket));
@@ -319,15 +314,14 @@
 	if (socket->cb_irq)
 		ti_cardctl(socket) |= TI113X_CCR_PCI_IRQ_ENA | TI113X_CCR_PCI_CSC | TI113X_CCR_PCI_IREQ;
 	ti_override(socket);
-	socket->socket.ops->init = ti113x_init;
+	socket->extra_init = ti113x_init;
 	return 0;
 }
 
 
-static int ti1250_init(struct pcmcia_socket *sock)
+static int ti1250_init(struct yenta_socket *socket)
 {
-	struct yenta_socket *socket = container_of(sock, struct yenta_socket, socket);
-	ti113x_init(sock);
+	ti113x_init(socket);
 	ti_irqmux(socket) = config_readl(socket, TI122X_IRQMUX);
 #if 0
 	ti_irqmux(socket) = (ti_irqmux(socket) & ~0x0f) | 0x02; /* route INTA */
@@ -349,7 +343,7 @@
 	if (socket->cb_irq)
 		ti_diag(socket) |= TI1250_DIAG_PCI_CSC | TI1250_DIAG_PCI_IREQ;
 	ti113x_override(socket);
-	socket->socket.ops->init = ti1250_init;
+	socket->extra_init = ti1250_init;
 	return 0;
 }
 
--- 1.8/drivers/pcmcia/ricoh.h	Mon Jul 14 16:42:47 2003
+++ edited/drivers/pcmcia/ricoh.h	Sun Aug 17 01:41:56 2003
@@ -142,26 +142,23 @@
         config_writeb(socket, RL5C4XX_MISC_CONTROL, reg);
 }
 
-static void ricoh_set_zv(struct pcmcia_socket *sock)
+static void ricoh_set_zv(struct yenta_socket *socket)
 {
-	struct yenta_socket *socket = container_of(sock, struct yenta_socket, socket);
         if(socket->dev->vendor == PCI_VENDOR_ID_RICOH)
         {
                 switch(socket->dev->device)
                 {
                         /* There may be more .. */
 		case  PCI_DEVICE_ID_RICOH_RL5C478:
-			sock->zoom_video = ricoh_zoom_video;
+			socket->socket.zoom_video = ricoh_zoom_video;
 			break;  
                 }
         }
 }
 
-static int ricoh_init(struct pcmcia_socket *sock)
+static int ricoh_init(struct yenta_socket *socket)
 {
-	struct yenta_socket *socket = container_of(sock, struct yenta_socket, socket);
-	yenta_init(sock);
-	ricoh_set_zv(sock);
+	ricoh_set_zv(socket);
 
 	config_writew(socket, RL5C4XX_MISC, rl_misc(socket));
 	config_writew(socket, RL5C4XX_16BIT_CTL, rl_ctl(socket));
@@ -194,7 +191,7 @@
 		rl_config(socket) |= RL5C4XX_CONFIG_PREFETCH;
 	}
 
-	socket->socket.ops->init = ricoh_init;
+	socket->extra_init = ricoh_init;
 
 	return 0;
 }




More information about the linux-pcmcia mailing list