From: Wolfgang Grandegger <wg-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org>
To: Willy Lambert <lambert.willy-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: "socketcan-users-0fE9KPoRgkgATYTw5x5z8w@public.gmane.org"
<socketcan-users-0fE9KPoRgkgATYTw5x5z8w@public.gmane.org>,
linux-can-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: Using sja1000_isa on a 64b system
Date: Sat, 12 Nov 2011 22:15:04 +0100 [thread overview]
Message-ID: <4EBEE1D8.7040407@grandegger.com> (raw)
In-Reply-To: <4EBEE043.6070601-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org>
[-- Attachment #1: Type: text/plain, Size: 511 bytes --]
On 11/12/2011 10:08 PM, Wolfgang Grandegger wrote:
> On 11/12/2011 10:55 AM, Willy Lambert wrote:
...
>>> I failed to apply the patch, is it for 2.6.38.8 kernels ?
>
> No, it's for up-to-date *mainline* linux version 3.1.x. Any chance to
> switch to David Miller's "net-nex-2.6" tree?. Otherwise I'm going to
> adapt the patch to 2.6.38.8.
Well, the patch also applies to 2.6.38.8. Maybe you have some problems
extracting the patch. Therefore I have attached it as attachment this
time. Good luck.
Wolfgang.
[-- Attachment #2: 0001-can-sja1000_isa-convert-to-platform-driver-to-suppor.patch --]
[-- Type: text/x-diff, Size: 5768 bytes --]
From dd2c8d7cf8f23a20aecd234a6cf7675b59f5779d Mon Sep 17 00:00:00 2001
From: Wolfgang Grandegger <wg-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org>
Date: Thu, 10 Nov 2011 09:10:18 +0100
Subject: [PATCH] can: sja1000_isa: convert to platform driver to support x86_64 systems
This driver is currently not supported on x86_64 systems because the
"isa_driver" interface is used. To overcome this limitation, this
driver is converted to a platform driver, similar to the serial 8250
driver.
Signed-off-by: Wolfgang Grandegger <wg-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org>
---
drivers/net/can/sja1000/Kconfig | 1 -
drivers/net/can/sja1000/sja1000_isa.c | 86 ++++++++++++++++++++++-----------
2 files changed, 57 insertions(+), 30 deletions(-)
diff --git a/drivers/net/can/sja1000/Kconfig b/drivers/net/can/sja1000/Kconfig
index fe9e64d..36e9d59 100644
--- a/drivers/net/can/sja1000/Kconfig
+++ b/drivers/net/can/sja1000/Kconfig
@@ -6,7 +6,6 @@ if CAN_SJA1000
config CAN_SJA1000_ISA
tristate "ISA Bus based legacy SJA1000 driver"
- depends on ISA
---help---
This driver adds legacy support for SJA1000 chips connected to
the ISA bus using I/O port, memory mapped or indirect access.
diff --git a/drivers/net/can/sja1000/sja1000_isa.c b/drivers/net/can/sja1000/sja1000_isa.c
index 496223e..3301031 100644
--- a/drivers/net/can/sja1000/sja1000_isa.c
+++ b/drivers/net/can/sja1000/sja1000_isa.c
@@ -17,7 +17,7 @@
#include <linux/kernel.h>
#include <linux/module.h>
-#include <linux/isa.h>
+#include <linux/platform_device.h>
#include <linux/interrupt.h>
#include <linux/netdevice.h>
#include <linux/delay.h>
@@ -75,6 +75,8 @@ MODULE_PARM_DESC(ocr, "Output control register "
#define SJA1000_IOSIZE 0x20
#define SJA1000_IOSIZE_INDIRECT 0x02
+static struct platform_device *sja1000_isa_devs[MAXDEV];
+
static u8 sja1000_isa_mem_read_reg(const struct sja1000_priv *priv, int reg)
{
return readb(priv->reg_base + reg);
@@ -115,24 +117,13 @@ static void sja1000_isa_port_write_reg_indirect(const struct sja1000_priv *priv,
outb(val, base + 1);
}
-static int __devinit sja1000_isa_match(struct device *pdev, unsigned int idx)
-{
- if (port[idx] || mem[idx]) {
- if (irq[idx])
- return 1;
- } else if (idx)
- return 0;
-
- dev_err(pdev, "insufficient parameters supplied\n");
- return 0;
-}
-
-static int __devinit sja1000_isa_probe(struct device *pdev, unsigned int idx)
+static int __devinit sja1000_isa_probe(struct platform_device *pdev)
{
struct net_device *dev;
struct sja1000_priv *priv;
void __iomem *base = NULL;
int iosize = SJA1000_IOSIZE;
+ int idx = pdev->id;
int err;
if (mem[idx]) {
@@ -203,17 +194,17 @@ static int __devinit sja1000_isa_probe(struct device *pdev, unsigned int idx)
else
priv->cdr = CDR_DEFAULT;
- dev_set_drvdata(pdev, dev);
- SET_NETDEV_DEV(dev, pdev);
+ dev_set_drvdata(&pdev->dev, dev);
+ SET_NETDEV_DEV(dev, &pdev->dev);
err = register_sja1000dev(dev);
if (err) {
- dev_err(pdev, "registering %s failed (err=%d)\n",
+ dev_err(&pdev->dev, "registering %s failed (err=%d)\n",
DRV_NAME, err);
goto exit_unmap;
}
- dev_info(pdev, "%s device registered (reg_base=0x%p, irq=%d)\n",
+ dev_info(&pdev->dev, "%s device registered (reg_base=0x%p, irq=%d)\n",
DRV_NAME, priv->reg_base, dev->irq);
return 0;
@@ -229,13 +220,14 @@ static int __devinit sja1000_isa_probe(struct device *pdev, unsigned int idx)
return err;
}
-static int __devexit sja1000_isa_remove(struct device *pdev, unsigned int idx)
+static int __devexit sja1000_isa_remove(struct platform_device *pdev)
{
- struct net_device *dev = dev_get_drvdata(pdev);
+ struct net_device *dev = dev_get_drvdata(&pdev->dev);
struct sja1000_priv *priv = netdev_priv(dev);
+ int idx = pdev->id;
unregister_sja1000dev(dev);
- dev_set_drvdata(pdev, NULL);
+ dev_set_drvdata(&pdev->dev, NULL);
if (mem[idx]) {
iounmap(priv->reg_base);
@@ -251,29 +243,65 @@ static int __devexit sja1000_isa_remove(struct device *pdev, unsigned int idx)
return 0;
}
-static struct isa_driver sja1000_isa_driver = {
- .match = sja1000_isa_match,
+static struct platform_driver sja1000_isa_driver = {
.probe = sja1000_isa_probe,
.remove = __devexit_p(sja1000_isa_remove),
.driver = {
.name = DRV_NAME,
+ .owner = THIS_MODULE,
},
};
static int __init sja1000_isa_init(void)
{
- int err = isa_register_driver(&sja1000_isa_driver, MAXDEV);
+ int idx, err;
+
+ for (idx = 0; idx < MAXDEV; idx++) {
+ if ((port[idx] || mem[idx]) && irq[idx]) {
+ sja1000_isa_devs[idx] =
+ platform_device_alloc(DRV_NAME, idx);
+ if (!sja1000_isa_devs[idx]) {
+ err = -ENOMEM;
+ goto exit_free_devices;
+ }
+ err = platform_device_add(sja1000_isa_devs[idx]);
+ if (err) {
+ platform_device_put(sja1000_isa_devs[idx]);
+ goto exit_free_devices;
+ }
+ } else {
+ pr_err("%s: insufficient parameters supplied\n",
+ DRV_NAME);
+ goto exit_free_devices;
+ }
+
+ err = platform_driver_register(&sja1000_isa_driver);
+ if (err)
+ goto exit_free_devices;
+
+ pr_info("Legacy %s driver for max. %d devices registered\n",
+ DRV_NAME, MAXDEV);
+
+ return 0;
+
+exit_free_devices:
+ while (--idx >= 0) {
+ if (sja1000_isa_devs[idx])
+ platform_device_unregister(sja1000_isa_devs[idx]);
+ }
- if (!err)
- printk(KERN_INFO
- "Legacy %s driver for max. %d devices registered\n",
- DRV_NAME, MAXDEV);
return err;
}
static void __exit sja1000_isa_exit(void)
{
- isa_unregister_driver(&sja1000_isa_driver);
+ int idx;
+
+ platform_driver_unregister(&sja1000_isa_driver);
+ for (idx = 0; idx < MAXDEV; idx++) {
+ if (sja1000_isa_devs[idx])
+ platform_device_unregister(sja1000_isa_devs[idx]);
+ }
}
module_init(sja1000_isa_init);
--
1.7.4.1
[-- Attachment #3: Type: text/plain, Size: 191 bytes --]
_______________________________________________
Socketcan-users mailing list
Socketcan-users-0fE9KPoRgkgATYTw5x5z8w@public.gmane.org
https://lists.berlios.de/mailman/listinfo/socketcan-users
next prev parent reply other threads:[~2011-11-12 21:15 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CAKvQZ_3HSdfOn4xGq7j8GsWJ+iHVan0Ygr=tR+cQm-tpQQWV2A@mail.gmail.com>
[not found] ` <4E4CA945.7080504@hartkopp.net>
[not found] ` <4E4CC9D5.6040708@pengutronix.de>
[not found] ` <CAKvQZ_0raVFUsCFYA2FVH_138DCMw6ipKHdz=Dh62K4YpM5o=Q@mail.gmail.com>
[not found] ` <4E5CCAA5.4030009@grandegger.com>
[not found] ` <CAKvQZ_0TFUd4FwOvr4AXArviMYPGHH6Xex4Cjy7LxYoEuBUpxA@mail.gmail.com>
[not found] ` <4E6271CD.6040407@grandegger.com>
[not found] ` <CAKvQZ_2PyM5zo5-4PtrMGjMEML3j02MKCCJU=zpnkSK2N_XUjg@mail.gmail.com>
[not found] ` <4E64B6CB.8010505@grandegger.com>
[not found] ` <CAKvQZ_1gp9XvVmh+ZEUdEVz2TrvkhHtVKc20ViNgSx=uuPWajQ@mail.gmail.com>
[not found] ` <4E653775.4030503@grandegger.com>
[not found] ` <4E653775.4030503-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org>
2011-11-09 18:03 ` Using sja1000_isa on a 64b system Willy Lambert
2011-11-09 18:05 ` Fwd: [Socketcan-users] " Willy Lambert
2011-11-10 8:36 ` Wolfgang Grandegger
[not found] ` <4EBB8CFD.3050602-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org>
2011-11-10 8:39 ` Willy Lambert
[not found] ` <CAKvQZ_1A5H_wDjnmvd5bDmtXvAyL3XNy6HesPR6jGzisoUe8eA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-11-10 8:48 ` Wolfgang Grandegger
[not found] ` <4EBB8FDC.40704-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org>
2011-11-10 10:58 ` Willy Lambert
2011-11-12 9:27 ` Willy Lambert
[not found] ` <CAKvQZ_3d=2-0+RrxkjCe7Nxvtgn42uYOS4f4B7_6TmaxEji7UQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-11-12 9:55 ` Willy Lambert
2011-11-12 21:08 ` [Socketcan-users] " Wolfgang Grandegger
[not found] ` <4EBEE043.6070601-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org>
2011-11-12 21:15 ` Wolfgang Grandegger [this message]
2011-11-13 8:42 ` Willy Lambert
[not found] ` <CAKvQZ_1QmJAPUZAEvV-2FSo2HR4byApoEqWPnOts9up90U4BVg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-11-13 9:15 ` Willy Lambert
[not found] ` <CAKvQZ_3anOf1SbE5TK6gvJf4v3gw1MBae0hw5JGr__szt7KoQQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-11-13 19:31 ` Wolfgang Grandegger
2011-11-14 9:51 ` [Socketcan-users] " Wolfgang Grandegger
[not found] ` <4EC0E4BE.4010101-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org>
2011-11-14 14:51 ` Willy Lambert
[not found] ` <CAKvQZ_2GkTqFrp-9quut0f33KL9tdD9NSTZ3btDHLZNP=a2VwQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-11-14 15:19 ` Wolfgang Grandegger
[not found] ` <4EC13191.6070901-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org>
2011-11-14 15:57 ` Willy Lambert
2011-11-15 8:06 ` [Socketcan-users] " Wolfgang Grandegger
[not found] ` <4EC21D95.5070508-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org>
2011-11-15 12:28 ` Willy Lambert
[not found] ` <CAKvQZ_2YrdYiq1_wge1zgyyDQws4+mn02+iZ-E5jgaqTma_3dw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-11-15 12:36 ` Wolfgang Grandegger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4EBEE1D8.7040407@grandegger.com \
--to=wg-5yr1bzd7o62+xt7jha+gda@public.gmane.org \
--cc=lambert.willy-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=linux-can-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=socketcan-users-0fE9KPoRgkgATYTw5x5z8w@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).