linux-can.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: Using sja1000_isa on a 64b system
       [not found]                     ` <4E653775.4030503-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org>
@ 2011-11-09 18:03                       ` Willy Lambert
  2011-11-09 18:05                         ` Fwd: [Socketcan-users] " Willy Lambert
  2011-11-10  8:36                         ` Wolfgang Grandegger
  0 siblings, 2 replies; 20+ messages in thread
From: Willy Lambert @ 2011-11-09 18:03 UTC (permalink / raw)
  To: Wolfgang Grandegger
  Cc: socketcan-users-0fE9KPoRgkgATYTw5x5z8w@public.gmane.org,
	linux-can-u79uwXL29TY76Z2rM5mHXA


[-- Attachment #1.1: Type: text/plain, Size: 2472 bytes --]

2011/9/5 Wolfgang Grandegger <wg-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org>

> On 09/05/2011 07:35 PM, Willy Lambert wrote:
> > 2011/9/5 Wolfgang Grandegger <wg-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org>
> >
> >> On 09/04/2011 09:09 PM, Willy Lambert wrote:
> >>> 2011/9/3 Wolfgang Grandegger <wg-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org>
> >> ...
> >>>> What CAN hardware are you using?
> >>>
> >>>
> >>> Motherboad and CAN stack :
> >>>
> >>
> http://www.advantech.com/products/PCM-3362/mod_2B69DA4C-D506-4AEA-8CC3-F6E58E3CBC87.aspx
> >>> http://www.ixxat.com/pc_i_04_104_en.html
> >>
> >> OK...
> >>
> >>>> And what bus is it
> >>>> connected to? Why do I ask? In "arch/x86/Kconfig" there is:
> >>>>
> >>>>  # x86_64 have no ISA slots, but can have ISA-style DMA.
> >>>>  config ISA_DMA_API
> >>>>        bool "ISA-style DMA support" if (X86_64 && EXPERT)
> >>>>        default y
> >>>>        help
> >>>>          Enables ISA-style DMA support for devices requiring such
> >>>> controllers.
> >>>>          If unsure, say Y.
> >>>>
> >>>>  if X86_32
> >>>>
> >>>>  config ISA
> >>>>        bool "ISA support"
> >>>>        ---help---
> >>>>          Find out whether you have ISA slots on your motherboard.  ISA
> >> is
> >>>> the
> >>>>          name of a bus system, i.e. the way the CPU talks to the other
> >>>> stuff
> >>>>          inside your box.  Other bus systems are PCI, EISA,
> MicroChannel
> >>>>          (MCA) or VESA.  ISA is an older system, now being displaced
> by
> >>>> PCI;
> >>>>          newer boards don't support it.  If you have ISA, say Y,
> >> otherwise
> >>>> N.
> >>>>
> >>>>
> >>>> Maybe the assumption that the x86_64 does not have ISA slots is wrong
> >> and
> >>>> we
> >>>> should fix that instead of moving to a platform driver like Oliver
> >>>> suggested.
> >>
> >> Intel Atom N450 on that board supports the PC/104-Plus bus, which is PCI
> >> (not ISA) based, therefore a SJA1000-PCI-driver seems more appropriate.
> >> Do you find the SJA1000 device with "lspci -vv"?
>
> Ah, at a closer look, the PC/104-Plus is an extension of the PC/104 from
> factor with an additional connector for PCI. It therefore still supports
> ISA bus communication, which the IXXAT PC-I 04/104 board uses.
>
> Therefore I'm going to prepare a patch removing the "X86_32" restriction
> for CONFIG_ISA above. Sorry for confusion.
>

May I bump this up ? I read your conversation on other linux ML, but I
don't really know how it ended.


>
> Wolfgang.
>

[-- Attachment #1.2: Type: text/html, Size: 4083 bytes --]

[-- Attachment #2: Type: text/plain, Size: 191 bytes --]

_______________________________________________
Socketcan-users mailing list
Socketcan-users-0fE9KPoRgkgATYTw5x5z8w@public.gmane.org
https://lists.berlios.de/mailman/listinfo/socketcan-users

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Fwd: [Socketcan-users] Using sja1000_isa on a 64b system
  2011-11-09 18:03                       ` Using sja1000_isa on a 64b system Willy Lambert
@ 2011-11-09 18:05                         ` Willy Lambert
  2011-11-10  8:36                         ` Wolfgang Grandegger
  1 sibling, 0 replies; 20+ messages in thread
From: Willy Lambert @ 2011-11-09 18:05 UTC (permalink / raw)
  To: linux-can

---------- Forwarded message ----------
From: Willy Lambert <lambert.willy@gmail.com>
Date: 2011/11/9
Subject: Re: [Socketcan-users] Using sja1000_isa on a 64b system
To: Wolfgang Grandegger <wg@grandegger.com>
Cc : "socketcan-users@lists.berlios.de"
<socketcan-users@lists.berlios.de>, linux-can@vger.kernel.org




2011/9/5 Wolfgang Grandegger <wg@grandegger.com>
>
> On 09/05/2011 07:35 PM, Willy Lambert wrote:
> > 2011/9/5 Wolfgang Grandegger <wg@grandegger.com>
> >
> >> On 09/04/2011 09:09 PM, Willy Lambert wrote:
> >>> 2011/9/3 Wolfgang Grandegger <wg@grandegger.com>
> >> ...
> >>>> What CAN hardware are you using?
> >>>
> >>>
> >>> Motherboad and CAN stack :
> >>>
> >> http://www.advantech.com/products/PCM-3362/mod_2B69DA4C-D506-4AEA-8CC3-F6E58E3CBC87.aspx
> >>> http://www.ixxat.com/pc_i_04_104_en.html
> >>
> >> OK...
> >>
> >>>> And what bus is it
> >>>> connected to? Why do I ask? In "arch/x86/Kconfig" there is:
> >>>>
> >>>>  # x86_64 have no ISA slots, but can have ISA-style DMA.
> >>>>  config ISA_DMA_API
> >>>>        bool "ISA-style DMA support" if (X86_64 && EXPERT)
> >>>>        default y
> >>>>        help
> >>>>          Enables ISA-style DMA support for devices requiring such
> >>>> controllers.
> >>>>          If unsure, say Y.
> >>>>
> >>>>  if X86_32
> >>>>
> >>>>  config ISA
> >>>>        bool "ISA support"
> >>>>        ---help---
> >>>>          Find out whether you have ISA slots on your motherboard.  ISA
> >> is
> >>>> the
> >>>>          name of a bus system, i.e. the way the CPU talks to the other
> >>>> stuff
> >>>>          inside your box.  Other bus systems are PCI, EISA, MicroChannel
> >>>>          (MCA) or VESA.  ISA is an older system, now being displaced by
> >>>> PCI;
> >>>>          newer boards don't support it.  If you have ISA, say Y,
> >> otherwise
> >>>> N.
> >>>>
> >>>>
> >>>> Maybe the assumption that the x86_64 does not have ISA slots is wrong
> >> and
> >>>> we
> >>>> should fix that instead of moving to a platform driver like Oliver
> >>>> suggested.
> >>
> >> Intel Atom N450 on that board supports the PC/104-Plus bus, which is PCI
> >> (not ISA) based, therefore a SJA1000-PCI-driver seems more appropriate.
> >> Do you find the SJA1000 device with "lspci -vv"?
>
> Ah, at a closer look, the PC/104-Plus is an extension of the PC/104 from
> factor with an additional connector for PCI. It therefore still supports
> ISA bus communication, which the IXXAT PC-I 04/104 board uses.
>
> Therefore I'm going to prepare a patch removing the "X86_32" restriction
> for CONFIG_ISA above. Sorry for confusion.

May I bump this up ? I read your conversation on other linux ML, but I
don't really know how it ended.

>
> Wolfgang.

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [Socketcan-users] Using sja1000_isa on a 64b system
  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>
  1 sibling, 1 reply; 20+ messages in thread
From: Wolfgang Grandegger @ 2011-11-10  8:36 UTC (permalink / raw)
  To: Willy Lambert; +Cc: socketcan-users@lists.berlios.de, linux-can

Hi Willy,

On 11/09/2011 07:03 PM, Willy Lambert wrote:
> 2011/9/5 Wolfgang Grandegger <wg@grandegger.com>
... 
>> Ah, at a closer look, the PC/104-Plus is an extension of the PC/104 from
>> factor with an additional connector for PCI. It therefore still supports
>> ISA bus communication, which the IXXAT PC-I 04/104 board uses.
>>
>> Therefore I'm going to prepare a patch removing the "X86_32" restriction
>> for CONFIG_ISA above. Sorry for confusion.
>>
> 
> May I bump this up ? I read your conversation on other linux ML, but I
> don't really know how it ended.

Some time ago I posted a patch to the relevant mls removing the
restriction mentioned above. But enabling CONFIG_ISA also for x86_64
systems is not wished mainly to avoid the expected mess with old
legacy ISA driver code. Therefore we should convert the driver to a
platform driver. I have attached the *untested* patch below. Could you
please give it a try? If it works fine, I will send it finally to the
netdev ml.

Thanks,

Wolfgang.


From dd2c8d7cf8f23a20aecd234a6cf7675b59f5779d Mon Sep 17 00:00:00 2001
From: Wolfgang Grandegger <wg@grandegger.com>
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@grandegger.com>
---
 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


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* Re: Using sja1000_isa on a 64b system
       [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-12  9:27                             ` Willy Lambert
  1 sibling, 1 reply; 20+ messages in thread
From: Willy Lambert @ 2011-11-10  8:39 UTC (permalink / raw)
  To: Wolfgang Grandegger
  Cc: socketcan-users-0fE9KPoRgkgATYTw5x5z8w@public.gmane.org,
	linux-can-u79uwXL29TY76Z2rM5mHXA

2011/11/10 Wolfgang Grandegger <wg-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org>:
> Hi Willy,
>
> On 11/09/2011 07:03 PM, Willy Lambert wrote:
>> 2011/9/5 Wolfgang Grandegger <wg-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org>
> ...
>>> Ah, at a closer look, the PC/104-Plus is an extension of the PC/104 from
>>> factor with an additional connector for PCI. It therefore still supports
>>> ISA bus communication, which the IXXAT PC-I 04/104 board uses.
>>>
>>> Therefore I'm going to prepare a patch removing the "X86_32" restriction
>>> for CONFIG_ISA above. Sorry for confusion.
>>>
>>
>> May I bump this up ? I read your conversation on other linux ML, but I
>> don't really know how it ended.
>
> Some time ago I posted a patch to the relevant mls removing the
> restriction mentioned above. But enabling CONFIG_ISA also for x86_64
> systems is not wished mainly to avoid the expected mess with old
> legacy ISA driver code. Therefore we should convert the driver to a
> platform driver. I have attached the *untested* patch below. Could you
> please give it a try? If it works fine, I will send it finally to the
> netdev ml.
>

For sure I'll do. But it'll take some time because switching from 32b to 64b.


> Thanks,
>
> Wolfgang.
>
>
> 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
>
>

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Using sja1000_isa on a 64b system
       [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>
  0 siblings, 1 reply; 20+ messages in thread
From: Wolfgang Grandegger @ 2011-11-10  8:48 UTC (permalink / raw)
  To: Willy Lambert
  Cc: socketcan-users-0fE9KPoRgkgATYTw5x5z8w@public.gmane.org,
	linux-can-u79uwXL29TY76Z2rM5mHXA

On 11/10/2011 09:39 AM, Willy Lambert wrote:
> 2011/11/10 Wolfgang Grandegger <wg-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org>:
>> Hi Willy,
>>
>> On 11/09/2011 07:03 PM, Willy Lambert wrote:
>>> 2011/9/5 Wolfgang Grandegger <wg-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org>
>> ...
>>>> Ah, at a closer look, the PC/104-Plus is an extension of the PC/104 from
>>>> factor with an additional connector for PCI. It therefore still supports
>>>> ISA bus communication, which the IXXAT PC-I 04/104 board uses.
>>>>
>>>> Therefore I'm going to prepare a patch removing the "X86_32" restriction
>>>> for CONFIG_ISA above. Sorry for confusion.
>>>>
>>>
>>> May I bump this up ? I read your conversation on other linux ML, but I
>>> don't really know how it ended.
>>
>> Some time ago I posted a patch to the relevant mls removing the
>> restriction mentioned above. But enabling CONFIG_ISA also for x86_64
>> systems is not wished mainly to avoid the expected mess with old
>> legacy ISA driver code. Therefore we should convert the driver to a
>> platform driver. I have attached the *untested* patch below. Could you
>> please give it a try? If it works fine, I will send it finally to the
>> netdev ml.
>>
> 
> For sure I'll do. But it'll take some time because switching from 32b to 64b.

OK, please test first on 32b and let me know. Then I'm quite sure that
it will also work on 64b.

Wolfgang.

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Using sja1000_isa on a 64b system
       [not found]                                   ` <4EBB8FDC.40704-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org>
@ 2011-11-10 10:58                                     ` Willy Lambert
  0 siblings, 0 replies; 20+ messages in thread
From: Willy Lambert @ 2011-11-10 10:58 UTC (permalink / raw)
  To: Wolfgang Grandegger
  Cc: socketcan-users-0fE9KPoRgkgATYTw5x5z8w@public.gmane.org,
	linux-can-u79uwXL29TY76Z2rM5mHXA

2011/11/10 Wolfgang Grandegger <wg-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org>:
> On 11/10/2011 09:39 AM, Willy Lambert wrote:
>> 2011/11/10 Wolfgang Grandegger <wg-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org>:
>>> Hi Willy,
>>>
>>> On 11/09/2011 07:03 PM, Willy Lambert wrote:
>>>> 2011/9/5 Wolfgang Grandegger <wg-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org>
>>> ...
>>>>> Ah, at a closer look, the PC/104-Plus is an extension of the PC/104 from
>>>>> factor with an additional connector for PCI. It therefore still supports
>>>>> ISA bus communication, which the IXXAT PC-I 04/104 board uses.
>>>>>
>>>>> Therefore I'm going to prepare a patch removing the "X86_32" restriction
>>>>> for CONFIG_ISA above. Sorry for confusion.
>>>>>
>>>>
>>>> May I bump this up ? I read your conversation on other linux ML, but I
>>>> don't really know how it ended.
>>>
>>> Some time ago I posted a patch to the relevant mls removing the
>>> restriction mentioned above. But enabling CONFIG_ISA also for x86_64
>>> systems is not wished mainly to avoid the expected mess with old
>>> legacy ISA driver code. Therefore we should convert the driver to a
>>> platform driver. I have attached the *untested* patch below. Could you
>>> please give it a try? If it works fine, I will send it finally to the
>>> netdev ml.
>>>
>>
>> For sure I'll do. But it'll take some time because switching from 32b to 64b.
>
> OK, please test first on 32b and let me know. Then I'm quite sure that
> it will also work on 64b.
>
> Wolfgang.
>

Oh sorry I didn't realized (even if it was obvious in the end) it was
also working on a 32b system. I test this as soon as my former driver
is working (cf the other thread)

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Using sja1000_isa on a 64b system
       [not found]                           ` <4EBB8CFD.3050602-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org>
  2011-11-10  8:39                             ` Willy Lambert
@ 2011-11-12  9:27                             ` Willy Lambert
       [not found]                               ` <CAKvQZ_3d=2-0+RrxkjCe7Nxvtgn42uYOS4f4B7_6TmaxEji7UQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  1 sibling, 1 reply; 20+ messages in thread
From: Willy Lambert @ 2011-11-12  9:27 UTC (permalink / raw)
  To: Wolfgang Grandegger
  Cc: socketcan-users-0fE9KPoRgkgATYTw5x5z8w@public.gmane.org,
	linux-can-u79uwXL29TY76Z2rM5mHXA

2011/11/10 Wolfgang Grandegger <wg-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org>:
> Hi Willy,
>
> On 11/09/2011 07:03 PM, Willy Lambert wrote:
>> 2011/9/5 Wolfgang Grandegger <wg-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org>
> ...
>>> Ah, at a closer look, the PC/104-Plus is an extension of the PC/104 from
>>> factor with an additional connector for PCI. It therefore still supports
>>> ISA bus communication, which the IXXAT PC-I 04/104 board uses.
>>>
>>> Therefore I'm going to prepare a patch removing the "X86_32" restriction
>>> for CONFIG_ISA above. Sorry for confusion.
>>>
>>
>> May I bump this up ? I read your conversation on other linux ML, but I
>> don't really know how it ended.
>
> Some time ago I posted a patch to the relevant mls removing the
> restriction mentioned above. But enabling CONFIG_ISA also for x86_64
> systems is not wished mainly to avoid the expected mess with old
> legacy ISA driver code. Therefore we should convert the driver to a
> platform driver. I have attached the *untested* patch below. Could you
> please give it a try? If it works fine, I will send it finally to the
> netdev ml.
>
> Thanks,
>
> Wolfgang.
>
>
> 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
>
>

I failed to apply the patch, is it for 2.6.38.8 kernels ?
I even try to modify the file editing by hand, by it doesn't compile.

The command uI use was : ard@ard-host:~/src/linux-2.6.38.8$ patch -p1
< wg_platform_driver.Patch
which I think is good because the .rej file is in the right place
drivers/net/can/sja1000/sja1000_isa.c.rej

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Using sja1000_isa on a 64b system
       [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
  0 siblings, 1 reply; 20+ messages in thread
From: Willy Lambert @ 2011-11-12  9:55 UTC (permalink / raw)
  To: Wolfgang Grandegger
  Cc: socketcan-users-0fE9KPoRgkgATYTw5x5z8w@public.gmane.org,
	linux-can-u79uwXL29TY76Z2rM5mHXA

2011/11/12 Willy Lambert <lambert.willy-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>:
> 2011/11/10 Wolfgang Grandegger <wg-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org>:
>> Hi Willy,
>>
>> On 11/09/2011 07:03 PM, Willy Lambert wrote:
>>> 2011/9/5 Wolfgang Grandegger <wg-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org>
>> ...
>>>> Ah, at a closer look, the PC/104-Plus is an extension of the PC/104 from
>>>> factor with an additional connector for PCI. It therefore still supports
>>>> ISA bus communication, which the IXXAT PC-I 04/104 board uses.
>>>>
>>>> Therefore I'm going to prepare a patch removing the "X86_32" restriction
>>>> for CONFIG_ISA above. Sorry for confusion.
>>>>
>>>
>>> May I bump this up ? I read your conversation on other linux ML, but I
>>> don't really know how it ended.
>>
>> Some time ago I posted a patch to the relevant mls removing the
>> restriction mentioned above. But enabling CONFIG_ISA also for x86_64
>> systems is not wished mainly to avoid the expected mess with old
>> legacy ISA driver code. Therefore we should convert the driver to a
>> platform driver. I have attached the *untested* patch below. Could you
>> please give it a try? If it works fine, I will send it finally to the
>> netdev ml.
>>
>> Thanks,
>>
>> Wolfgang.
>>
>>
>> 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
>>
>>
>
> I failed to apply the patch, is it for 2.6.38.8 kernels ?
> I even try to modify the file editing by hand, by it doesn't compile.
>
> The command uI use was : ard@ard-host:~/src/linux-2.6.38.8$ patch -p1
> < wg_platform_driver.Patch
> which I think is good because the .rej file is in the right place
> drivers/net/can/sja1000/sja1000_isa.c.rej
>

sorry the mail went to fast, here is the error log :

patching file drivers/net/can/sja1000/sja1000_isa.c
Hunk #2 succeeded at 75 with fuzz 1.
Hunk #3 FAILED at 117.
Hunk #4 FAILED at 205.
Hunk #5 FAILED at 231.
Hunk #6 FAILED at 253.
4 out of 6 hunks FAILED -- saving rejects to file
drivers/net/can/sja1000/sja1000_isa.c.rej

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [Socketcan-users] Using sja1000_isa on a 64b system
  2011-11-12  9:55                                 ` Willy Lambert
@ 2011-11-12 21:08                                   ` Wolfgang Grandegger
       [not found]                                     ` <4EBEE043.6070601-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org>
  0 siblings, 1 reply; 20+ messages in thread
From: Wolfgang Grandegger @ 2011-11-12 21:08 UTC (permalink / raw)
  To: Willy Lambert; +Cc: socketcan-users@lists.berlios.de, linux-can

On 11/12/2011 10:55 AM, Willy Lambert wrote:
> 2011/11/12 Willy Lambert <lambert.willy@gmail.com>:
>> 2011/11/10 Wolfgang Grandegger <wg@grandegger.com>:
>>> Hi Willy,
>>>
>>> On 11/09/2011 07:03 PM, Willy Lambert wrote:
>>>> 2011/9/5 Wolfgang Grandegger <wg@grandegger.com>
>>> ...
>>>>> Ah, at a closer look, the PC/104-Plus is an extension of the PC/104 from
>>>>> factor with an additional connector for PCI. It therefore still supports
>>>>> ISA bus communication, which the IXXAT PC-I 04/104 board uses.
>>>>>
>>>>> Therefore I'm going to prepare a patch removing the "X86_32" restriction
>>>>> for CONFIG_ISA above. Sorry for confusion.
>>>>>
>>>>
>>>> May I bump this up ? I read your conversation on other linux ML, but I
>>>> don't really know how it ended.
>>>
>>> Some time ago I posted a patch to the relevant mls removing the
>>> restriction mentioned above. But enabling CONFIG_ISA also for x86_64
>>> systems is not wished mainly to avoid the expected mess with old
>>> legacy ISA driver code. Therefore we should convert the driver to a
>>> platform driver. I have attached the *untested* patch below. Could you
>>> please give it a try? If it works fine, I will send it finally to the
>>> netdev ml.
>>>
>>> Thanks,
>>>
>>> Wolfgang.
>>>
>>>
>>> From dd2c8d7cf8f23a20aecd234a6cf7675b59f5779d Mon Sep 17 00:00:00 2001
>>> From: Wolfgang Grandegger <wg@grandegger.com>
>>> 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@grandegger.com>
>>> ---
>>>  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
>>>
>>>
>>
>> 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.

Wolfgang.

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Using sja1000_isa on a 64b system
       [not found]                                     ` <4EBEE043.6070601-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org>
@ 2011-11-12 21:15                                       ` Wolfgang Grandegger
  2011-11-13  8:42                                         ` [Socketcan-users] " Willy Lambert
  0 siblings, 1 reply; 20+ messages in thread
From: Wolfgang Grandegger @ 2011-11-12 21:15 UTC (permalink / raw)
  To: Willy Lambert
  Cc: socketcan-users-0fE9KPoRgkgATYTw5x5z8w@public.gmane.org,
	linux-can-u79uwXL29TY76Z2rM5mHXA

[-- 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

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* Re: [Socketcan-users] Using sja1000_isa on a 64b system
  2011-11-12 21:15                                       ` Wolfgang Grandegger
@ 2011-11-13  8:42                                         ` Willy Lambert
       [not found]                                           ` <CAKvQZ_1QmJAPUZAEvV-2FSo2HR4byApoEqWPnOts9up90U4BVg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  0 siblings, 1 reply; 20+ messages in thread
From: Willy Lambert @ 2011-11-13  8:42 UTC (permalink / raw)
  To: Wolfgang Grandegger; +Cc: socketcan-users@lists.berlios.de, linux-can

2011/11/12 Wolfgang Grandegger <wg@grandegger.com>:
> 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.

It's ok now :
ard@ard-host:~/src/linux-2.6.38.8$ patch -p1 < wg_platform.patch
patching file drivers/net/can/sja1000/Kconfig
patching file drivers/net/can/sja1000/sja1000_isa.c

I must have done something wrong. I am going to test it now


>
> Wolfgang.
>

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Using sja1000_isa on a 64b system
       [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>
  0 siblings, 1 reply; 20+ messages in thread
From: Willy Lambert @ 2011-11-13  9:15 UTC (permalink / raw)
  To: Wolfgang Grandegger
  Cc: socketcan-users-0fE9KPoRgkgATYTw5x5z8w@public.gmane.org,
	linux-can-u79uwXL29TY76Z2rM5mHXA

2011/11/13 Willy Lambert <lambert.willy-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>:
> 2011/11/12 Wolfgang Grandegger <wg-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org>:
>> 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.
>
> It's ok now :
> ard@ard-host:~/src/linux-2.6.38.8$ patch -p1 < wg_platform.patch
> patching file drivers/net/can/sja1000/Kconfig
> patching file drivers/net/can/sja1000/sja1000_isa.c
>
> I must have done something wrong. I am going to test it now
>

arg, it doesn't compile I had a look a sources but I don't see the error :

  CC [M]  drivers/xenomai/can/rtcan_raw_dev.o
drivers/net/can/sja1000/sja1000_isa.c: In function ‘sja1000_isa_init’:
drivers/net/can/sja1000/sja1000_isa.c:297: error: invalid storage
class for function ‘sja1000_isa_exit’
drivers/net/can/sja1000/sja1000_isa.c:296: warning: ISO C90 forbids
mixed declarations and code
drivers/net/can/sja1000/sja1000_isa.c:307: error: invalid storage
class for function ‘__inittest’
drivers/net/can/sja1000/sja1000_isa.c:307: warning: ‘alias’ attribute ignored
drivers/net/can/sja1000/sja1000_isa.c:308: error: invalid storage
class for function ‘__exittest’
drivers/net/can/sja1000/sja1000_isa.c:308: warning: ISO C90 forbids
mixed declarations and code
drivers/net/can/sja1000/sja1000_isa.c:308: warning: ‘alias’ attribute ignored
drivers/net/can/sja1000/sja1000_isa.c:308: error: expected declaration
or statement at end of input
make[5]: *** [drivers/net/can/sja1000/sja1000_isa.o] Error 1



>
>>
>> Wolfgang.
>>
>

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Using sja1000_isa on a 64b system
       [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
  0 siblings, 1 reply; 20+ messages in thread
From: Wolfgang Grandegger @ 2011-11-13 19:31 UTC (permalink / raw)
  To: Willy Lambert
  Cc: socketcan-users-0fE9KPoRgkgATYTw5x5z8w@public.gmane.org,
	linux-can-u79uwXL29TY76Z2rM5mHXA

On 11/13/2011 10:15 AM, Willy Lambert wrote:
> 2011/11/13 Willy Lambert <lambert.willy-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>:
>> 2011/11/12 Wolfgang Grandegger <wg-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org>:
>>> 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.
>>
>> It's ok now :
>> ard@ard-host:~/src/linux-2.6.38.8$ patch -p1 < wg_platform.patch
>> patching file drivers/net/can/sja1000/Kconfig
>> patching file drivers/net/can/sja1000/sja1000_isa.c
>>
>> I must have done something wrong. I am going to test it now
>>
> 
> arg, it doesn't compile I had a look a sources but I don't see the error :
> 
>   CC [M]  drivers/xenomai/can/rtcan_raw_dev.o
> drivers/net/can/sja1000/sja1000_isa.c: In function ‘sja1000_isa_init’:
> drivers/net/can/sja1000/sja1000_isa.c:297: error: invalid storage
> class for function ‘sja1000_isa_exit’
> drivers/net/can/sja1000/sja1000_isa.c:296: warning: ISO C90 forbids
> mixed declarations and code
> drivers/net/can/sja1000/sja1000_isa.c:307: error: invalid storage
> class for function ‘__inittest’
> drivers/net/can/sja1000/sja1000_isa.c:307: warning: ‘alias’ attribute ignored
> drivers/net/can/sja1000/sja1000_isa.c:308: error: invalid storage
> class for function ‘__exittest’
> drivers/net/can/sja1000/sja1000_isa.c:308: warning: ISO C90 forbids
> mixed declarations and code
> drivers/net/can/sja1000/sja1000_isa.c:308: warning: ‘alias’ attribute ignored
> drivers/net/can/sja1000/sja1000_isa.c:308: error: expected declaration
> or statement at end of input
> make[5]: *** [drivers/net/can/sja1000/sja1000_isa.o] Error 1

Argh, a "}" is missing, sorry. I will test the patch more carefully
before re-sending.

Wolfgang.

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [Socketcan-users] Using sja1000_isa on a 64b system
  2011-11-13 19:31                                                 ` Wolfgang Grandegger
@ 2011-11-14  9:51                                                   ` Wolfgang Grandegger
       [not found]                                                     ` <4EC0E4BE.4010101-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org>
  0 siblings, 1 reply; 20+ messages in thread
From: Wolfgang Grandegger @ 2011-11-14  9:51 UTC (permalink / raw)
  To: Willy Lambert; +Cc: socketcan-users@lists.berlios.de, linux-can

[-- Attachment #1: Type: text/plain, Size: 2213 bytes --]

On 11/13/2011 08:31 PM, Wolfgang Grandegger wrote:
> On 11/13/2011 10:15 AM, Willy Lambert wrote:
>> 2011/11/13 Willy Lambert <lambert.willy@gmail.com>:
>>> 2011/11/12 Wolfgang Grandegger <wg@grandegger.com>:
>>>> 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.
>>>
>>> It's ok now :
>>> ard@ard-host:~/src/linux-2.6.38.8$ patch -p1 < wg_platform.patch
>>> patching file drivers/net/can/sja1000/Kconfig
>>> patching file drivers/net/can/sja1000/sja1000_isa.c
>>>
>>> I must have done something wrong. I am going to test it now
>>>
>>
>> arg, it doesn't compile I had a look a sources but I don't see the error :
>>
>>   CC [M]  drivers/xenomai/can/rtcan_raw_dev.o
>> drivers/net/can/sja1000/sja1000_isa.c: In function ‘sja1000_isa_init’:
>> drivers/net/can/sja1000/sja1000_isa.c:297: error: invalid storage
>> class for function ‘sja1000_isa_exit’
>> drivers/net/can/sja1000/sja1000_isa.c:296: warning: ISO C90 forbids
>> mixed declarations and code
>> drivers/net/can/sja1000/sja1000_isa.c:307: error: invalid storage
>> class for function ‘__inittest’
>> drivers/net/can/sja1000/sja1000_isa.c:307: warning: ‘alias’ attribute ignored
>> drivers/net/can/sja1000/sja1000_isa.c:308: error: invalid storage
>> class for function ‘__exittest’
>> drivers/net/can/sja1000/sja1000_isa.c:308: warning: ISO C90 forbids
>> mixed declarations and code
>> drivers/net/can/sja1000/sja1000_isa.c:308: warning: ‘alias’ attribute ignored
>> drivers/net/can/sja1000/sja1000_isa.c:308: error: expected declaration
>> or statement at end of input
>> make[5]: *** [drivers/net/can/sja1000/sja1000_isa.o] Error 1
> 
> Argh, a "}" is missing, sorry. I will test the patch more carefully
> before re-sending.

See attachment.

Wolfgang.

[-- Attachment #2: sja1000-isa-platform-x86-64.patch --]
[-- Type: text/x-diff, Size: 7240 bytes --]

[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.

This patch also fixes some warnings: "comparison is always false due
to limited range of data type".

Signed-off-by: Wolfgang Grandegger <wg@grandegger.com>
---
 drivers/net/can/sja1000/Kconfig       |    1 
 drivers/net/can/sja1000/sja1000_isa.c |  109 ++++++++++++++++++++++------------
 2 files changed, 72 insertions(+), 38 deletions(-)

Index: linux-2.6.38.8/drivers/net/can/sja1000/Kconfig
===================================================================
--- linux-2.6.38.8.orig/drivers/net/can/sja1000/Kconfig	2011-11-13 20:24:52.447054533 +0100
+++ linux-2.6.38.8/drivers/net/can/sja1000/Kconfig	2011-11-13 20:24:55.943071866 +0100
@@ -6,7 +6,6 @@
 
 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.
Index: linux-2.6.38.8/drivers/net/can/sja1000/sja1000_isa.c
===================================================================
--- linux-2.6.38.8.orig/drivers/net/can/sja1000/sja1000_isa.c	2011-11-13 20:24:52.431054451 +0100
+++ linux-2.6.38.8/drivers/net/can/sja1000/sja1000_isa.c	2011-11-14 10:44:50.026339684 +0100
@@ -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>
@@ -44,9 +44,9 @@
 static unsigned long mem[MAXDEV];
 static int __devinitdata irq[MAXDEV];
 static int __devinitdata clk[MAXDEV];
-static char __devinitdata cdr[MAXDEV] = {[0 ... (MAXDEV - 1)] = -1};
-static char __devinitdata ocr[MAXDEV] = {[0 ... (MAXDEV - 1)] = -1};
-static char __devinitdata indirect[MAXDEV] = {[0 ... (MAXDEV - 1)] = -1};
+static unsigned char __devinitdata cdr[MAXDEV] = {[0 ... (MAXDEV - 1)] = 0xff};
+static unsigned char __devinitdata ocr[MAXDEV] = {[0 ... (MAXDEV - 1)] = 0xff};
+static int __devinitdata indirect[MAXDEV] = {[0 ... (MAXDEV - 1)] = -1};
 
 module_param_array(port, ulong, NULL, S_IRUGO);
 MODULE_PARM_DESC(port, "I/O port number");
@@ -54,7 +54,7 @@
 module_param_array(mem, ulong, NULL, S_IRUGO);
 MODULE_PARM_DESC(mem, "I/O memory address");
 
-module_param_array(indirect, byte, NULL, S_IRUGO);
+module_param_array(indirect, int, NULL, S_IRUGO);
 MODULE_PARM_DESC(indirect, "Indirect access via address and data port");
 
 module_param_array(irq, int, NULL, S_IRUGO);
@@ -75,6 +75,8 @@
 #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,26 +117,18 @@
 	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;
 
+	dev_dbg(&pdev->dev, "probing idx=%d: port=%#lx, mem=%#lx, irq=%d\n",
+		idx, port[idx], mem[idx], irq[idx]);
+
 	if (mem[idx]) {
 		if (!request_mem_region(mem[idx], iosize, DRV_NAME)) {
 			err = -EBUSY;
@@ -189,31 +183,31 @@
 	else
 		priv->can.clock.freq = CLK_DEFAULT / 2;
 
-	if (ocr[idx] != -1)
+	if (ocr[idx] != 0xff)
 		priv->ocr = ocr[idx] & 0xff;
-	else if (ocr[0] != -1)
+	else if (ocr[0] != 0xff)
 		priv->ocr = ocr[0] & 0xff;
 	else
 		priv->ocr = OCR_DEFAULT;
 
-	if (cdr[idx] != -1)
+	if (cdr[idx] != 0xff)
 		priv->cdr = cdr[idx] & 0xff;
-	else if (cdr[0] != -1)
+	else if (cdr[0] != 0xff)
 		priv->cdr = cdr[0] & 0xff;
 	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 +223,14 @@
 	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 +246,69 @@
 	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;
+			}
+			pr_debug("%s: platform device %d: port=%#lx, mem=%#lx, "
+				 "irq=%d\n",
+				 DRV_NAME, idx, port[idx], mem[idx], irq[idx]);
+		} 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);

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Using sja1000_isa on a 64b system
       [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>
  0 siblings, 1 reply; 20+ messages in thread
From: Willy Lambert @ 2011-11-14 14:51 UTC (permalink / raw)
  To: Wolfgang Grandegger
  Cc: socketcan-users-0fE9KPoRgkgATYTw5x5z8w@public.gmane.org,
	linux-can-u79uwXL29TY76Z2rM5mHXA

2011/11/14 Wolfgang Grandegger <wg-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org>:
> On 11/13/2011 08:31 PM, Wolfgang Grandegger wrote:
>> On 11/13/2011 10:15 AM, Willy Lambert wrote:
>>> 2011/11/13 Willy Lambert <lambert.willy-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>:
>>>> 2011/11/12 Wolfgang Grandegger <wg-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org>:
>>>>> 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.
>>>>
>>>> It's ok now :
>>>> ard@ard-host:~/src/linux-2.6.38.8$ patch -p1 < wg_platform.patch
>>>> patching file drivers/net/can/sja1000/Kconfig
>>>> patching file drivers/net/can/sja1000/sja1000_isa.c
>>>>
>>>> I must have done something wrong. I am going to test it now
>>>>
>>>
>>> arg, it doesn't compile I had a look a sources but I don't see the error :
>>>
>>>   CC [M]  drivers/xenomai/can/rtcan_raw_dev.o
>>> drivers/net/can/sja1000/sja1000_isa.c: In function ‘sja1000_isa_init’:
>>> drivers/net/can/sja1000/sja1000_isa.c:297: error: invalid storage
>>> class for function ‘sja1000_isa_exit’
>>> drivers/net/can/sja1000/sja1000_isa.c:296: warning: ISO C90 forbids
>>> mixed declarations and code
>>> drivers/net/can/sja1000/sja1000_isa.c:307: error: invalid storage
>>> class for function ‘__inittest’
>>> drivers/net/can/sja1000/sja1000_isa.c:307: warning: ‘alias’ attribute ignored
>>> drivers/net/can/sja1000/sja1000_isa.c:308: error: invalid storage
>>> class for function ‘__exittest’
>>> drivers/net/can/sja1000/sja1000_isa.c:308: warning: ISO C90 forbids
>>> mixed declarations and code
>>> drivers/net/can/sja1000/sja1000_isa.c:308: warning: ‘alias’ attribute ignored
>>> drivers/net/can/sja1000/sja1000_isa.c:308: error: expected declaration
>>> or statement at end of input
>>> make[5]: *** [drivers/net/can/sja1000/sja1000_isa.o] Error 1
>>
>> Argh, a "}" is missing, sorry. I will test the patch more carefully
>> before re-sending.
>
> See attachment.

Thanks, the compilation is now ok, but when I load them on my target I
have this in dmesg :
CAN device driver interface
sja1000 CAN netdevice driver
sja1000_isa: insufficient parameters supplied

The loading command is :
modprobe sja1000_isa irq=10,10 mem=0xD0000,0xD0200 ocr=0x5e,0x5e cdr=0,0
And I am sure it is the same than before, so I think there is a
problem when you read the parameters

>
> Wolfgang.
>

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Using sja1000_isa on a 64b system
       [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>
  0 siblings, 1 reply; 20+ messages in thread
From: Wolfgang Grandegger @ 2011-11-14 15:19 UTC (permalink / raw)
  To: Willy Lambert
  Cc: socketcan-users-0fE9KPoRgkgATYTw5x5z8w@public.gmane.org,
	linux-can-u79uwXL29TY76Z2rM5mHXA

[-- Attachment #1: Type: text/plain, Size: 3141 bytes --]

On 11/14/2011 03:51 PM, Willy Lambert wrote:
> 2011/11/14 Wolfgang Grandegger <wg-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org>:
>> On 11/13/2011 08:31 PM, Wolfgang Grandegger wrote:
>>> On 11/13/2011 10:15 AM, Willy Lambert wrote:
>>>> 2011/11/13 Willy Lambert <lambert.willy-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>:
>>>>> 2011/11/12 Wolfgang Grandegger <wg-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org>:
>>>>>> 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.
>>>>>
>>>>> It's ok now :
>>>>> ard@ard-host:~/src/linux-2.6.38.8$ patch -p1 < wg_platform.patch
>>>>> patching file drivers/net/can/sja1000/Kconfig
>>>>> patching file drivers/net/can/sja1000/sja1000_isa.c
>>>>>
>>>>> I must have done something wrong. I am going to test it now
>>>>>
>>>>
>>>> arg, it doesn't compile I had a look a sources but I don't see the error :
>>>>
>>>>   CC [M]  drivers/xenomai/can/rtcan_raw_dev.o
>>>> drivers/net/can/sja1000/sja1000_isa.c: In function ‘sja1000_isa_init’:
>>>> drivers/net/can/sja1000/sja1000_isa.c:297: error: invalid storage
>>>> class for function ‘sja1000_isa_exit’
>>>> drivers/net/can/sja1000/sja1000_isa.c:296: warning: ISO C90 forbids
>>>> mixed declarations and code
>>>> drivers/net/can/sja1000/sja1000_isa.c:307: error: invalid storage
>>>> class for function ‘__inittest’
>>>> drivers/net/can/sja1000/sja1000_isa.c:307: warning: ‘alias’ attribute ignored
>>>> drivers/net/can/sja1000/sja1000_isa.c:308: error: invalid storage
>>>> class for function ‘__exittest’
>>>> drivers/net/can/sja1000/sja1000_isa.c:308: warning: ISO C90 forbids
>>>> mixed declarations and code
>>>> drivers/net/can/sja1000/sja1000_isa.c:308: warning: ‘alias’ attribute ignored
>>>> drivers/net/can/sja1000/sja1000_isa.c:308: error: expected declaration
>>>> or statement at end of input
>>>> make[5]: *** [drivers/net/can/sja1000/sja1000_isa.o] Error 1
>>>
>>> Argh, a "}" is missing, sorry. I will test the patch more carefully
>>> before re-sending.
>>
>> See attachment.
> 
> Thanks, the compilation is now ok, but when I load them on my target I
> have this in dmesg :
> CAN device driver interface
> sja1000 CAN netdevice driver
> sja1000_isa: insufficient parameters supplied
> 
> The loading command is :
> modprobe sja1000_isa irq=10,10 mem=0xD0000,0xD0200 ocr=0x5e,0x5e cdr=0,0
> And I am sure it is the same than before, so I think there is a
> problem when you read the parameters

Again, my fault., sorry Could you please retry with the attached patch.
Could you please also enable CAN device debugging
(CONFIG_CAN_DEBUG_DEVICES=y).

Thanks,

Wolfgang.

[-- Attachment #2: sja1000-isa-platform-x86-64.patch --]
[-- Type: text/x-diff, Size: 7327 bytes --]

[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.

This patch also fixes some warnings: "comparison is always false due
to limited range of data type".

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 |  110 ++++++++++++++++++++++------------
 2 files changed, 73 insertions(+), 38 deletions(-)

Index: linux-2.6.38.8/drivers/net/can/sja1000/Kconfig
===================================================================
--- linux-2.6.38.8.orig/drivers/net/can/sja1000/Kconfig	2011-11-13 20:24:52.447054533 +0100
+++ linux-2.6.38.8/drivers/net/can/sja1000/Kconfig	2011-11-13 20:24:55.943071866 +0100
@@ -6,7 +6,6 @@
 
 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.
Index: linux-2.6.38.8/drivers/net/can/sja1000/sja1000_isa.c
===================================================================
--- linux-2.6.38.8.orig/drivers/net/can/sja1000/sja1000_isa.c	2011-11-13 20:24:52.431054451 +0100
+++ linux-2.6.38.8/drivers/net/can/sja1000/sja1000_isa.c	2011-11-14 16:18:44.513685553 +0100
@@ -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>
@@ -44,9 +44,9 @@
 static unsigned long mem[MAXDEV];
 static int __devinitdata irq[MAXDEV];
 static int __devinitdata clk[MAXDEV];
-static char __devinitdata cdr[MAXDEV] = {[0 ... (MAXDEV - 1)] = -1};
-static char __devinitdata ocr[MAXDEV] = {[0 ... (MAXDEV - 1)] = -1};
-static char __devinitdata indirect[MAXDEV] = {[0 ... (MAXDEV - 1)] = -1};
+static unsigned char __devinitdata cdr[MAXDEV] = {[0 ... (MAXDEV - 1)] = 0xff};
+static unsigned char __devinitdata ocr[MAXDEV] = {[0 ... (MAXDEV - 1)] = 0xff};
+static int __devinitdata indirect[MAXDEV] = {[0 ... (MAXDEV - 1)] = -1};
 
 module_param_array(port, ulong, NULL, S_IRUGO);
 MODULE_PARM_DESC(port, "I/O port number");
@@ -54,7 +54,7 @@
 module_param_array(mem, ulong, NULL, S_IRUGO);
 MODULE_PARM_DESC(mem, "I/O memory address");
 
-module_param_array(indirect, byte, NULL, S_IRUGO);
+module_param_array(indirect, int, NULL, S_IRUGO);
 MODULE_PARM_DESC(indirect, "Indirect access via address and data port");
 
 module_param_array(irq, int, NULL, S_IRUGO);
@@ -75,6 +75,8 @@
 #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,26 +117,18 @@
 	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;
 
+	dev_dbg(&pdev->dev, "probing idx=%d: port=%#lx, mem=%#lx, irq=%d\n",
+		idx, port[idx], mem[idx], irq[idx]);
+
 	if (mem[idx]) {
 		if (!request_mem_region(mem[idx], iosize, DRV_NAME)) {
 			err = -EBUSY;
@@ -189,31 +183,31 @@
 	else
 		priv->can.clock.freq = CLK_DEFAULT / 2;
 
-	if (ocr[idx] != -1)
+	if (ocr[idx] != 0xff)
 		priv->ocr = ocr[idx] & 0xff;
-	else if (ocr[0] != -1)
+	else if (ocr[0] != 0xff)
 		priv->ocr = ocr[0] & 0xff;
 	else
 		priv->ocr = OCR_DEFAULT;
 
-	if (cdr[idx] != -1)
+	if (cdr[idx] != 0xff)
 		priv->cdr = cdr[idx] & 0xff;
-	else if (cdr[0] != -1)
+	else if (cdr[0] != 0xff)
 		priv->cdr = cdr[0] & 0xff;
 	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 +223,14 @@
 	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 +246,70 @@
 	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;
+			}
+			pr_debug("%s: platform device %d: port=%#lx, mem=%#lx, "
+				 "irq=%d\n",
+				 DRV_NAME, idx, port[idx], mem[idx], irq[idx]);
+		} else if (idx == 0 || port[idx] || mem[idx]) {
+				pr_err("%s: insufficient parameters supplied\n",
+				       DRV_NAME);
+				err = -EINVAL;
+				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);

[-- 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

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Using sja1000_isa on a 64b system
       [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
  0 siblings, 1 reply; 20+ messages in thread
From: Willy Lambert @ 2011-11-14 15:57 UTC (permalink / raw)
  To: Wolfgang Grandegger
  Cc: socketcan-users-0fE9KPoRgkgATYTw5x5z8w@public.gmane.org,
	linux-can-u79uwXL29TY76Z2rM5mHXA

2011/11/14 Wolfgang Grandegger <wg-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org>:
> On 11/14/2011 03:51 PM, Willy Lambert wrote:
>> 2011/11/14 Wolfgang Grandegger <wg-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org>:
>>> On 11/13/2011 08:31 PM, Wolfgang Grandegger wrote:
>>>> On 11/13/2011 10:15 AM, Willy Lambert wrote:
>>>>> 2011/11/13 Willy Lambert <lambert.willy-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>:
>>>>>> 2011/11/12 Wolfgang Grandegger <wg-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org>:
>>>>>>> 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.
>>>>>>
>>>>>> It's ok now :
>>>>>> ard@ard-host:~/src/linux-2.6.38.8$ patch -p1 < wg_platform.patch
>>>>>> patching file drivers/net/can/sja1000/Kconfig
>>>>>> patching file drivers/net/can/sja1000/sja1000_isa.c
>>>>>>
>>>>>> I must have done something wrong. I am going to test it now
>>>>>>
>>>>>
>>>>> arg, it doesn't compile I had a look a sources but I don't see the error :
>>>>>
>>>>>   CC [M]  drivers/xenomai/can/rtcan_raw_dev.o
>>>>> drivers/net/can/sja1000/sja1000_isa.c: In function ‘sja1000_isa_init’:
>>>>> drivers/net/can/sja1000/sja1000_isa.c:297: error: invalid storage
>>>>> class for function ‘sja1000_isa_exit’
>>>>> drivers/net/can/sja1000/sja1000_isa.c:296: warning: ISO C90 forbids
>>>>> mixed declarations and code
>>>>> drivers/net/can/sja1000/sja1000_isa.c:307: error: invalid storage
>>>>> class for function ‘__inittest’
>>>>> drivers/net/can/sja1000/sja1000_isa.c:307: warning: ‘alias’ attribute ignored
>>>>> drivers/net/can/sja1000/sja1000_isa.c:308: error: invalid storage
>>>>> class for function ‘__exittest’
>>>>> drivers/net/can/sja1000/sja1000_isa.c:308: warning: ISO C90 forbids
>>>>> mixed declarations and code
>>>>> drivers/net/can/sja1000/sja1000_isa.c:308: warning: ‘alias’ attribute ignored
>>>>> drivers/net/can/sja1000/sja1000_isa.c:308: error: expected declaration
>>>>> or statement at end of input
>>>>> make[5]: *** [drivers/net/can/sja1000/sja1000_isa.o] Error 1
>>>>
>>>> Argh, a "}" is missing, sorry. I will test the patch more carefully
>>>> before re-sending.
>>>
>>> See attachment.
>>
>> Thanks, the compilation is now ok, but when I load them on my target I
>> have this in dmesg :
>> CAN device driver interface
>> sja1000 CAN netdevice driver
>> sja1000_isa: insufficient parameters supplied
>>
>> The loading command is :
>> modprobe sja1000_isa irq=10,10 mem=0xD0000,0xD0200 ocr=0x5e,0x5e cdr=0,0
>> And I am sure it is the same than before, so I think there is a
>> problem when you read the parameters
>
> Again, my fault., sorry

Don't be sorry, it is dev aleas and I am glad to have your time for
this feature :)

> Could you please retry with the attached patch.

It seems to work :
CAN device driver interface
sja1000 CAN netdevice driver
sja1000_isa sja1000_isa.0: sja1000_isa device registered
(reg_base=0xc00d0000, irq=10)
sja1000_isa sja1000_isa.1: sja1000_isa device registered
(reg_base=0xc00d0200, irq=10)
Legacy sja1000_isa driver for max. 8 devices registered
sja1000_isa sja1000_isa.0: setting BTR0=0x00 BTR1=0x14
sja1000_isa sja1000_isa.1: setting BTR0=0x00 BTR1=0x14


I did :
cansend can1 000#81.00
cansend can1 000#01.00

My device "Operationnal" Led switch state and candump tells :
 (1321289653.149877)  can1    0  [2] 81 00                     '..'
 (1321289653.177209)  can1  705  [1] 00                        '.'
 (1321289653.177267)  can1  706  [1] 00                        '.'
 (1321289660.349837)  can1    0  [2] 01 00                     '..'
 (1321289660.350785)  can1  186  [2] 00 00                     '..'
 (1321289660.350846)  can1  185  [2] 02 00                     '..'


Do you wish any further tests ?


> Could you please also enable CAN device debugging
> (CONFIG_CAN_DEBUG_DEVICES=y).
>
> Thanks,
>
> Wolfgang.
>

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [Socketcan-users] Using sja1000_isa on a 64b system
  2011-11-14 15:57                                                               ` Willy Lambert
@ 2011-11-15  8:06                                                                 ` Wolfgang Grandegger
       [not found]                                                                   ` <4EC21D95.5070508-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org>
  0 siblings, 1 reply; 20+ messages in thread
From: Wolfgang Grandegger @ 2011-11-15  8:06 UTC (permalink / raw)
  To: Willy Lambert; +Cc: socketcan-users@lists.berlios.de, linux-can

On 11/14/2011 04:57 PM, Willy Lambert wrote:
> 2011/11/14 Wolfgang Grandegger <wg@grandegger.com>:
>> On 11/14/2011 03:51 PM, Willy Lambert wrote:
>>> 2011/11/14 Wolfgang Grandegger <wg@grandegger.com>:
>>>> On 11/13/2011 08:31 PM, Wolfgang Grandegger wrote:
>>>>> On 11/13/2011 10:15 AM, Willy Lambert wrote:
>>>>>> 2011/11/13 Willy Lambert <lambert.willy@gmail.com>:
>>>>>>> 2011/11/12 Wolfgang Grandegger <wg@grandegger.com>:
>>>>>>>> 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.
>>>>>>>
>>>>>>> It's ok now :
>>>>>>> ard@ard-host:~/src/linux-2.6.38.8$ patch -p1 < wg_platform.patch
>>>>>>> patching file drivers/net/can/sja1000/Kconfig
>>>>>>> patching file drivers/net/can/sja1000/sja1000_isa.c
>>>>>>>
>>>>>>> I must have done something wrong. I am going to test it now
>>>>>>>
>>>>>>
>>>>>> arg, it doesn't compile I had a look a sources but I don't see the error :
>>>>>>
>>>>>>   CC [M]  drivers/xenomai/can/rtcan_raw_dev.o
>>>>>> drivers/net/can/sja1000/sja1000_isa.c: In function ‘sja1000_isa_init’:
>>>>>> drivers/net/can/sja1000/sja1000_isa.c:297: error: invalid storage
>>>>>> class for function ‘sja1000_isa_exit’
>>>>>> drivers/net/can/sja1000/sja1000_isa.c:296: warning: ISO C90 forbids
>>>>>> mixed declarations and code
>>>>>> drivers/net/can/sja1000/sja1000_isa.c:307: error: invalid storage
>>>>>> class for function ‘__inittest’
>>>>>> drivers/net/can/sja1000/sja1000_isa.c:307: warning: ‘alias’ attribute ignored
>>>>>> drivers/net/can/sja1000/sja1000_isa.c:308: error: invalid storage
>>>>>> class for function ‘__exittest’
>>>>>> drivers/net/can/sja1000/sja1000_isa.c:308: warning: ISO C90 forbids
>>>>>> mixed declarations and code
>>>>>> drivers/net/can/sja1000/sja1000_isa.c:308: warning: ‘alias’ attribute ignored
>>>>>> drivers/net/can/sja1000/sja1000_isa.c:308: error: expected declaration
>>>>>> or statement at end of input
>>>>>> make[5]: *** [drivers/net/can/sja1000/sja1000_isa.o] Error 1
>>>>>
>>>>> Argh, a "}" is missing, sorry. I will test the patch more carefully
>>>>> before re-sending.
>>>>
>>>> See attachment.
>>>
>>> Thanks, the compilation is now ok, but when I load them on my target I
>>> have this in dmesg :
>>> CAN device driver interface
>>> sja1000 CAN netdevice driver
>>> sja1000_isa: insufficient parameters supplied
>>>
>>> The loading command is :
>>> modprobe sja1000_isa irq=10,10 mem=0xD0000,0xD0200 ocr=0x5e,0x5e cdr=0,0
>>> And I am sure it is the same than before, so I think there is a
>>> problem when you read the parameters
>>
>> Again, my fault., sorry
> 
> Don't be sorry, it is dev aleas and I am glad to have your time for
> this feature :)
> 
>> Could you please retry with the attached patch.
> 
> It seems to work :
> CAN device driver interface
> sja1000 CAN netdevice driver
> sja1000_isa sja1000_isa.0: sja1000_isa device registered
> (reg_base=0xc00d0000, irq=10)
> sja1000_isa sja1000_isa.1: sja1000_isa device registered
> (reg_base=0xc00d0200, irq=10)
> Legacy sja1000_isa driver for max. 8 devices registered
> sja1000_isa sja1000_isa.0: setting BTR0=0x00 BTR1=0x14
> sja1000_isa sja1000_isa.1: setting BTR0=0x00 BTR1=0x14
> 
> 
> I did :
> cansend can1 000#81.00
> cansend can1 000#01.00
> 
> My device "Operationnal" Led switch state and candump tells :
>  (1321289653.149877)  can1    0  [2] 81 00                     '..'
>  (1321289653.177209)  can1  705  [1] 00                        '.'
>  (1321289653.177267)  can1  706  [1] 00                        '.'
>  (1321289660.349837)  can1    0  [2] 01 00                     '..'
>  (1321289660.350785)  can1  186  [2] 00 00                     '..'
>  (1321289660.350846)  can1  185  [2] 02 00                     '..'
> 
> 
> Do you wish any further tests ?

Does the following command work as well?

 modprobe sja1000_isa irq=10,10 mem=0xD0000,0xD0200 ocr=0x5e cdr=0

Does re-loading of the driver work properly?

 rmmod sja1000_isa; insmod sja1000_isa ...

Similar tests on a x86_64 system and with a recent kernel version would
be nice to have.

Thanks,

Wolfgang.


^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Using sja1000_isa on a 64b system
       [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>
  0 siblings, 1 reply; 20+ messages in thread
From: Willy Lambert @ 2011-11-15 12:28 UTC (permalink / raw)
  To: Wolfgang Grandegger
  Cc: socketcan-users-0fE9KPoRgkgATYTw5x5z8w@public.gmane.org,
	linux-can-u79uwXL29TY76Z2rM5mHXA

2011/11/15 Wolfgang Grandegger <wg-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org>:
> On 11/14/2011 04:57 PM, Willy Lambert wrote:
>> 2011/11/14 Wolfgang Grandegger <wg-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org>:
>>> On 11/14/2011 03:51 PM, Willy Lambert wrote:
>>>> 2011/11/14 Wolfgang Grandegger <wg-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org>:
>>>>> On 11/13/2011 08:31 PM, Wolfgang Grandegger wrote:
>>>>>> On 11/13/2011 10:15 AM, Willy Lambert wrote:
>>>>>>> 2011/11/13 Willy Lambert <lambert.willy-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>:
>>>>>>>> 2011/11/12 Wolfgang Grandegger <wg-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org>:
>>>>>>>>> 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.
>>>>>>>>
>>>>>>>> It's ok now :
>>>>>>>> ard@ard-host:~/src/linux-2.6.38.8$ patch -p1 < wg_platform.patch
>>>>>>>> patching file drivers/net/can/sja1000/Kconfig
>>>>>>>> patching file drivers/net/can/sja1000/sja1000_isa.c
>>>>>>>>
>>>>>>>> I must have done something wrong. I am going to test it now
>>>>>>>>
>>>>>>>
>>>>>>> arg, it doesn't compile I had a look a sources but I don't see the error :
>>>>>>>
>>>>>>>   CC [M]  drivers/xenomai/can/rtcan_raw_dev.o
>>>>>>> drivers/net/can/sja1000/sja1000_isa.c: In function ‘sja1000_isa_init’:
>>>>>>> drivers/net/can/sja1000/sja1000_isa.c:297: error: invalid storage
>>>>>>> class for function ‘sja1000_isa_exit’
>>>>>>> drivers/net/can/sja1000/sja1000_isa.c:296: warning: ISO C90 forbids
>>>>>>> mixed declarations and code
>>>>>>> drivers/net/can/sja1000/sja1000_isa.c:307: error: invalid storage
>>>>>>> class for function ‘__inittest’
>>>>>>> drivers/net/can/sja1000/sja1000_isa.c:307: warning: ‘alias’ attribute ignored
>>>>>>> drivers/net/can/sja1000/sja1000_isa.c:308: error: invalid storage
>>>>>>> class for function ‘__exittest’
>>>>>>> drivers/net/can/sja1000/sja1000_isa.c:308: warning: ISO C90 forbids
>>>>>>> mixed declarations and code
>>>>>>> drivers/net/can/sja1000/sja1000_isa.c:308: warning: ‘alias’ attribute ignored
>>>>>>> drivers/net/can/sja1000/sja1000_isa.c:308: error: expected declaration
>>>>>>> or statement at end of input
>>>>>>> make[5]: *** [drivers/net/can/sja1000/sja1000_isa.o] Error 1
>>>>>>
>>>>>> Argh, a "}" is missing, sorry. I will test the patch more carefully
>>>>>> before re-sending.
>>>>>
>>>>> See attachment.
>>>>
>>>> Thanks, the compilation is now ok, but when I load them on my target I
>>>> have this in dmesg :
>>>> CAN device driver interface
>>>> sja1000 CAN netdevice driver
>>>> sja1000_isa: insufficient parameters supplied
>>>>
>>>> The loading command is :
>>>> modprobe sja1000_isa irq=10,10 mem=0xD0000,0xD0200 ocr=0x5e,0x5e cdr=0,0
>>>> And I am sure it is the same than before, so I think there is a
>>>> problem when you read the parameters
>>>
>>> Again, my fault., sorry
>>
>> Don't be sorry, it is dev aleas and I am glad to have your time for
>> this feature :)
>>
>>> Could you please retry with the attached patch.
>>
>> It seems to work :
>> CAN device driver interface
>> sja1000 CAN netdevice driver
>> sja1000_isa sja1000_isa.0: sja1000_isa device registered
>> (reg_base=0xc00d0000, irq=10)
>> sja1000_isa sja1000_isa.1: sja1000_isa device registered
>> (reg_base=0xc00d0200, irq=10)
>> Legacy sja1000_isa driver for max. 8 devices registered
>> sja1000_isa sja1000_isa.0: setting BTR0=0x00 BTR1=0x14
>> sja1000_isa sja1000_isa.1: setting BTR0=0x00 BTR1=0x14
>>
>>
>> I did :
>> cansend can1 000#81.00
>> cansend can1 000#01.00
>>
>> My device "Operationnal" Led switch state and candump tells :
>>  (1321289653.149877)  can1    0  [2] 81 00                     '..'
>>  (1321289653.177209)  can1  705  [1] 00                        '.'
>>  (1321289653.177267)  can1  706  [1] 00                        '.'
>>  (1321289660.349837)  can1    0  [2] 01 00                     '..'
>>  (1321289660.350785)  can1  186  [2] 00 00                     '..'
>>  (1321289660.350846)  can1  185  [2] 02 00                     '..'
>>
>>
>> Do you wish any further tests ?
>
> Does the following command work as well?
>
>  modprobe sja1000_isa irq=10,10 mem=0xD0000,0xD0200 ocr=0x5e cdr=0
>
> Does re-loading of the driver work properly?
>
>  rmmod sja1000_isa; insmod sja1000_isa ...
>

all this is working.

> Similar tests on a x86_64 system and with a recent kernel version would
> be nice to have.
>
> Thanks,

This is not possible a present time, I don't have any 64b img to put
on my board and I don't have the time to create a new one. Sorry.


>
> Wolfgang.
>
>

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Using sja1000_isa on a 64b system
       [not found]                                                                       ` <CAKvQZ_2YrdYiq1_wge1zgyyDQws4+mn02+iZ-E5jgaqTma_3dw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2011-11-15 12:36                                                                         ` Wolfgang Grandegger
  0 siblings, 0 replies; 20+ messages in thread
From: Wolfgang Grandegger @ 2011-11-15 12:36 UTC (permalink / raw)
  To: Willy Lambert
  Cc: socketcan-users-0fE9KPoRgkgATYTw5x5z8w@public.gmane.org,
	linux-can-u79uwXL29TY76Z2rM5mHXA

On 11/15/2011 01:28 PM, Willy Lambert wrote:
> 2011/11/15 Wolfgang Grandegger <wg-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org>:
...
>>> Do you wish any further tests ?
>>
>> Does the following command work as well?
>>
>>  modprobe sja1000_isa irq=10,10 mem=0xD0000,0xD0200 ocr=0x5e cdr=0
>>
>> Does re-loading of the driver work properly?
>>
>>  rmmod sja1000_isa; insmod sja1000_isa ...
>>
> 
> all this is working.

Good.

>> Similar tests on a x86_64 system and with a recent kernel version would
>> be nice to have.
>>
>> Thanks,
> 
> This is not possible a present time, I don't have any 64b img to put
> on my board and I don't have the time to create a new one. Sorry.

OK, no problem. I'm already confident enough to push this patch mainline.

Thanks for your effort.

Wolfgang.

^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2011-11-15 12:36 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [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
2011-11-13  8:42                                         ` [Socketcan-users] " 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

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).