From linux-arm-kernel-bounces@lists.arm.linux.org.uk Sat Oct 28 23:13:55 2006
Return-Path:
	<linux-arm-kernel-bounces+rpurdie=rpsys.net@lists.arm.linux.org.uk>
Received: from localhost (localhost [127.0.0.1]) by tim.rpsys.net
	(8.13.6/8.13.8) with ESMTP id k9SMDt2t027032 for <rpurdie@[127.0.0.1]>;
	Sat, 28 Oct 2006 23:13:55 +0100
Received: from tim.rpsys.net ([127.0.0.1]) by localhost (tim.rpsys.net
	[127.0.0.1]) (amavisd-new, port 10024) with LMTP id 26420-09 for
	<rpurdie@[127.0.0.1]>; Sat, 28 Oct 2006 23:13:53 +0100 (BST)
Received: from ZenIV.linux.org.uk (zeniv.linux.org.uk [195.92.253.2]) by
	tim.rpsys.net (8.13.6/8.13.8) with ESMTP id k9SMDkJ4027014
	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for
	<rpurdie@rpsys.net>; Sat, 28 Oct 2006 23:13:47 +0100
Received: from [2002:d993:5cf9:1:201:3dff:fe00:156]
	(helo=lists.arm.linux.org.uk) by ZenIV.linux.org.uk with esmtpsa (Exim 4.52
	#1 (Red Hat Linux)) id 1GdwLg-0004ZJ-Ez; Sat, 28 Oct 2006 23:08:17 +0100
Received: from localhost ([127.0.0.1] helo=lists.arm.linux.org.uk) by
	lists.arm.linux.org.uk with esmtp (Exim 4.50) id 1GdwLM-0006kl-M1; Sat, 28
	Oct 2006 23:07:56 +0100
Received: from caramon.arm.linux.org.uk
	([2002:d993:5cf9:1:a00:2bff:fe95:1d7b]) by lists.arm.linux.org.uk with
	esmtpsa (TLS-1.0:DHE_RSA_3DES_EDE_CBC_SHA:24) (Exim 4.50) id
	1GdwJL-0006ju-WC for linux-arm-kernel@lists.arm.linux.org.uk; Sat, 28 Oct
	2006 23:06:08 +0100
Received: from [2002:d993:5cf9:1:201:80ff:fe4b:1778]
	(helo=dyn-67.arm.linux.org.uk) by caramon.arm.linux.org.uk with esmtpsa
	(TLSv1:DES-CBC3-SHA:168) (Exim 4.52) id 1GdwJG-0000uG-MA for
	linux-arm-kernel@lists.arm.linux.org.uk; Sat, 28 Oct 2006 23:05:47 +0100
Received: from rmk by dyn-67.arm.linux.org.uk with local (Exim 4.62)
	(envelope-from <rmk@dyn-67.arm.linux.org.uk>) id 1GdwJF-0001Tb-BR for
	linux-arm-kernel@lists.arm.linux.org.uk; Sat, 28 Oct 2006 23:05:45 +0100
References:
	 <git-84b5abe69ff600a559e1a1fa29f1edad707d4e2f@dyn-67.arm.linux.org.uk>
In-reply-to: <git-84b5abe69ff600a559e1a1fa29f1edad707d4e2f@dyn-67.arm.linux.org.uk>
Message-ID: <git-9468613b2bb0a386af563953b613efc6c77bd8c1@dyn-67.arm.linux.org.uk>
From: Russell King <linux@arm.linux.org.uk>
To: LAK <linux-arm-kernel@lists.arm.linux.org.uk>
Date: Sat, 28 Oct 2006 22:56:13 +0100
Content-type: text/plain
Mime-Version: 1.0
Resent-From: rmk@arm.linux.org.uk
Resent-Date: Sat, 28 Oct 2006 23:05:45 +0100
Resent-To: linux-arm-kernel@lists.arm.linux.org.uk
Resent-Message-Id: <E1GdwJF-0001Tb-BR@dyn-67.arm.linux.org.uk>
Resent-Sender: Russell King <rmk@arm.linux.org.uk>
Subject: Re: [ARM] Fix suspend oops caused by PXA2xx PCMCIA driver
X-BeenThere: linux-arm-kernel@lists.arm.linux.org.uk
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: ARM Linux kernel discussions
	<linux-arm-kernel.lists.arm.linux.org.uk>
List-Unsubscribe:
	<http://lists.arm.linux.org.uk/mailman/listinfo/linux-arm-kernel>,
	<mailto:linux-arm-kernel-request@lists.arm.linux.org.uk?subject=unsubscribe>
List-Archive: <http://lists.arm.linux.org.uk/pipermail/linux-arm-kernel>
List-Post: <mailto:linux-arm-kernel@lists.arm.linux.org.uk>
List-Help:
	<mailto:linux-arm-kernel-request@lists.arm.linux.org.uk?subject=help>
List-Subscribe:
	<http://lists.arm.linux.org.uk/mailman/listinfo/linux-arm-kernel>,
	<mailto:linux-arm-kernel-request@lists.arm.linux.org.uk?subject=subscribe>
Sender: linux-arm-kernel-bounces@lists.arm.linux.org.uk
Errors-To:
	linux-arm-kernel-bounces+rpurdie=rpsys.net+rpurdie=rpsys.net@lists.arm.linux.org.uk
X-Virus-Scanned: amavisd-new at rpsys.net
X-Evolution-Source: imap://richard@tim.rpsys.net/
Content-Transfer-Encoding: 8bit

From: Russell King <rmk@dyn-67.arm.linux.org.uk>

The PXA2xx PCMCIA driver was registering a device_driver with the
platform_bus_type.  Unfortunately, this causes data outside the
device_driver structure to be dereferenced as if it were a
platform_driver structure, causing an oops.  Convert the PXA2xx
core driver to use the proper platform_driver structure.

Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
---
 drivers/pcmcia/pxa2xx_base.c    |   41 ++++++++++++++++++++++++++++-----------
 drivers/pcmcia/pxa2xx_base.h    |    2 +-
 drivers/pcmcia/pxa2xx_lubbock.c |    2 +-
 3 files changed, 31 insertions(+), 14 deletions(-)

9468613b2bb0a386af563953b613efc6c77bd8c1
diff --git a/drivers/pcmcia/pxa2xx_base.c b/drivers/pcmcia/pxa2xx_base.c
index b351813..dca9f85 100644
--- a/drivers/pcmcia/pxa2xx_base.c
+++ b/drivers/pcmcia/pxa2xx_base.c
@@ -166,7 +166,7 @@ #warning "it's not clear if this is righ
 }
 #endif
 
-int pxa2xx_drv_pcmcia_probe(struct device *dev)
+int __pxa2xx_drv_pcmcia_probe(struct device *dev)
 {
 	int ret;
 	struct pcmcia_low_level *ops;
@@ -203,35 +203,52 @@ #endif
 
 	return ret;
 }
-EXPORT_SYMBOL(pxa2xx_drv_pcmcia_probe);
+EXPORT_SYMBOL(__pxa2xx_drv_pcmcia_probe);
 
-static int pxa2xx_drv_pcmcia_resume(struct device *dev)
+
+static int pxa2xx_drv_pcmcia_probe(struct platform_device *dev)
+{
+	return __pxa2xx_drv_pcmcia_probe(&dev->dev);
+}
+
+static int pxa2xx_drv_pcmcia_remove(struct platform_device *dev)
+{
+	return soc_common_drv_pcmcia_remove(&dev->dev);
+}
+
+static int pxa2xx_drv_pcmcia_suspend(struct platform_device *dev, pm_message_t state)
+{
+	return pcmcia_socket_dev_suspend(&dev->dev, state);
+}
+
+static int pxa2xx_drv_pcmcia_resume(struct platform_device *dev)
 {
-	struct pcmcia_low_level *ops = dev->platform_data;
+	struct pcmcia_low_level *ops = dev->dev.platform_data;
 	int nr = ops ? ops->nr : 0;
 
 	MECR = nr > 1 ? MECR_CIT | MECR_NOS : (nr > 0 ? MECR_CIT : 0);
 
-	return pcmcia_socket_dev_resume(dev);
+	return pcmcia_socket_dev_resume(&dev->dev);
 }
 
-static struct device_driver pxa2xx_pcmcia_driver = {
+static struct platform_driver pxa2xx_pcmcia_driver = {
 	.probe		= pxa2xx_drv_pcmcia_probe,
-	.remove		= soc_common_drv_pcmcia_remove,
-	.suspend 	= pcmcia_socket_dev_suspend,
+	.remove		= pxa2xx_drv_pcmcia_remove,
+	.suspend 	= pxa2xx_drv_pcmcia_suspend,
 	.resume 	= pxa2xx_drv_pcmcia_resume,
-	.name		= "pxa2xx-pcmcia",
-	.bus		= &platform_bus_type,
+	.driver		= {
+		.name	= "pxa2xx-pcmcia",
+	},
 };
 
 static int __init pxa2xx_pcmcia_init(void)
 {
-	return driver_register(&pxa2xx_pcmcia_driver);
+	return platform_driver_register(&pxa2xx_pcmcia_driver);
 }
 
 static void __exit pxa2xx_pcmcia_exit(void)
 {
-	driver_unregister(&pxa2xx_pcmcia_driver);
+	platform_driver_unregister(&pxa2xx_pcmcia_driver);
 }
 
 fs_initcall(pxa2xx_pcmcia_init);
diff --git a/drivers/pcmcia/pxa2xx_base.h b/drivers/pcmcia/pxa2xx_base.h
index e46cff3..235d681 100644
--- a/drivers/pcmcia/pxa2xx_base.h
+++ b/drivers/pcmcia/pxa2xx_base.h
@@ -1,3 +1,3 @@
 /* temporary measure */
-extern int pxa2xx_drv_pcmcia_probe(struct device *);
+extern int __pxa2xx_drv_pcmcia_probe(struct device *);
 
diff --git a/drivers/pcmcia/pxa2xx_lubbock.c b/drivers/pcmcia/pxa2xx_lubbock.c
index fd1f691..a92f111 100644
--- a/drivers/pcmcia/pxa2xx_lubbock.c
+++ b/drivers/pcmcia/pxa2xx_lubbock.c
@@ -260,7 +260,7 @@ int __init pcmcia_lubbock_init(struct sa
 		lubbock_set_misc_wr((1 << 15) | (1 << 14), 0);
 
 		sadev->dev.platform_data = &lubbock_pcmcia_ops;
-		ret = pxa2xx_drv_pcmcia_probe(&sadev->dev);
+		ret = __pxa2xx_drv_pcmcia_probe(&sadev->dev);
 	}
 
 	return ret;


-------------------------------------------------------------------
List admin: http://lists.arm.linux.org.uk/mailman/listinfo/linux-arm-kernel
FAQ:        http://www.arm.linux.org.uk/mailinglists/faq.php
Etiquette:  http://www.arm.linux.org.uk/mailinglists/etiquette.php


