public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 3/4] Fix remaining big endian issue of hfcmulti
@ 2008-08-02 14:35 Karsten Keil
  2008-08-04 12:03 ` David Woodhouse
  2008-08-05  4:29 ` Benjamin Herrenschmidt
  0 siblings, 2 replies; 20+ messages in thread
From: Karsten Keil @ 2008-08-02 14:35 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: linux-kernel, isdn4linux

The driver was not so bad at big endian at all, only the optimised fifo
read/write functions need a fix, with this fix the driver works on
a pegasus PPC machine.

Signed-off-by: Karsten Keil <kkeil@suse.de>
---
 drivers/isdn/hardware/mISDN/hfcmulti.c |   27 +++++++++++++--------------
 1 files changed, 13 insertions(+), 14 deletions(-)

diff --git a/drivers/isdn/hardware/mISDN/hfcmulti.c b/drivers/isdn/hardware/mISDN/hfcmulti.c
index 10144e8..e36360a 100644
--- a/drivers/isdn/hardware/mISDN/hfcmulti.c
+++ b/drivers/isdn/hardware/mISDN/hfcmulti.c
@@ -140,7 +140,7 @@
  * #define HFC_REGISTER_DEBUG
  */
 
-static const char *hfcmulti_revision = "2.00";
+static const char *hfcmulti_revision = "2.01";
 
 #include <linux/module.h>
 #include <linux/pci.h>
@@ -427,12 +427,12 @@ write_fifo_regio(struct hfc_multi *hc, u_char *data, int len)
 {
 	outb(A_FIFO_DATA0, (hc->pci_iobase)+4);
 	while (len>>2) {
-		outl(*(u32 *)data, hc->pci_iobase);
+		outl(cpu_to_le32(*(u32 *)data), hc->pci_iobase);
 		data += 4;
 		len -= 4;
 	}
 	while (len>>1) {
-		outw(*(u16 *)data, hc->pci_iobase);
+		outw(cpu_to_le16(*(u16 *)data), hc->pci_iobase);
 		data += 2;
 		len -= 2;
 	}
@@ -447,17 +447,19 @@ void
 write_fifo_pcimem(struct hfc_multi *hc, u_char *data, int len)
 {
 	while (len>>2) {
-		writel(*(u32 *)data, (hc->pci_membase)+A_FIFO_DATA0);
+		writel(cpu_to_le32(*(u32 *)data),
+			hc->pci_membase + A_FIFO_DATA0);
 		data += 4;
 		len -= 4;
 	}
 	while (len>>1) {
-		writew(*(u16 *)data, (hc->pci_membase)+A_FIFO_DATA0);
+		writew(cpu_to_le16(*(u16 *)data),
+			hc->pci_membase + A_FIFO_DATA0);
 		data += 2;
 		len -= 2;
 	}
 	while (len) {
-		writeb(*data, (hc->pci_membase)+A_FIFO_DATA0);
+		writeb(*data, hc->pci_membase + A_FIFO_DATA0);
 		data++;
 		len--;
 	}
@@ -468,12 +470,12 @@ read_fifo_regio(struct hfc_multi *hc, u_char *data, int len)
 {
 	outb(A_FIFO_DATA0, (hc->pci_iobase)+4);
 	while (len>>2) {
-		*(u32 *)data = inl(hc->pci_iobase);
+		*(u32 *)data = le32_to_cpu(inl(hc->pci_iobase));
 		data += 4;
 		len -= 4;
 	}
 	while (len>>1) {
-		*(u16 *)data = inw(hc->pci_iobase);
+		*(u16 *)data = le16_to_cpu(inw(hc->pci_iobase));
 		data += 2;
 		len -= 2;
 	}
@@ -490,18 +492,18 @@ read_fifo_pcimem(struct hfc_multi *hc, u_char *data, int len)
 {
 	while (len>>2) {
 		*(u32 *)data =
-			readl((hc->pci_membase)+A_FIFO_DATA0);
+			le32_to_cpu(readl(hc->pci_membase + A_FIFO_DATA0));
 		data += 4;
 		len -= 4;
 	}
 	while (len>>1) {
 		*(u16 *)data =
-			readw((hc->pci_membase)+A_FIFO_DATA0);
+			le16_to_cpu(readw(hc->pci_membase + A_FIFO_DATA0));
 		data += 2;
 		len -= 2;
 	}
 	while (len) {
-		*data = readb((hc->pci_membase)+A_FIFO_DATA0);
+		*data = readb(hc->pci_membase + A_FIFO_DATA0);
 		data++;
 		len--;
 	}
@@ -5251,9 +5253,6 @@ HFCmulti_init(void)
 	if (debug & DEBUG_HFCMULTI_INIT)
 		printk(KERN_DEBUG "%s: init entered\n", __func__);
 
-#ifdef __BIG_ENDIAN
-#error "not running on big endian machines now"
-#endif
 	hfc_interrupt = symbol_get(ztdummy_extern_interrupt);
 	register_interrupt = symbol_get(ztdummy_register_interrupt);
 	unregister_interrupt = symbol_get(ztdummy_unregister_interrupt);
-- 
1.5.6.4


^ permalink raw reply related	[flat|nested] 20+ messages in thread
* AW: [PATCH 3/4] Fix remaining big endian issue of hfcmulti
@ 2008-08-07 11:01 Andreas.Eversberg
  2008-08-07 13:46 ` Karsten Keil
  0 siblings, 1 reply; 20+ messages in thread
From: Andreas.Eversberg @ 2008-08-07 11:01 UTC (permalink / raw)
  To: benh, Karsten Keil
  Cc: Sean MacLennan, Linus Torvalds, isdn4linux, linux-kernel

please note that some cards require MEMIO. disabling it means disabling card types. if there are other future access modes and bridges, they can be implemented and then be selected by the vendor and device ids. read, write and fifo read, write are functions,  assigned to pointers at runtime. also wrapping (slightly) different hardware access is possible in the future. i think we should leave it like it is.

also note:  reading or writing fifos via PIO is optimized and almost as fast as MEMIO, since io-address byte never changes during fifo access. (auto-incemented after access).

-----Ursprüngliche Nachricht-----
Von: Benjamin Herrenschmidt [mailto:benh@kernel.crashing.org] 
Gesendet: Mittwoch, 6. August 2008 02:34
An: Karsten Keil
Cc: Sean MacLennan; Linus Torvalds; Andreas.Eversberg; isdn4linux@listserv.isdn4linux.de; linux-kernel@vger.kernel.org
Betreff: Re: [PATCH 3/4] Fix remaining big endian issue of hfcmulti

On Wed, 2008-08-06 at 02:18 +0200, Karsten Keil wrote:
> 
> For the xhfc this may be a differnt choice, to select the access method on
> compile time, because the chip is mainly used for embedded systems, so it
> do not need to have a generic driver, the kerne is usually configured
> exactly for the hardware. On the other side, if you look into the xhfc
> chip and documentation, it is not so different from the HFC 4/8S, so maybe
> it would be possible to integrate it in hfcmulti as well.
> 
> And maybe here is a third way, to have a tristate CONFIG MEMIO,PIO,BOTH,
> which could be imlemented in the none indirect call version without
> overhead. I think I like this idea.

That's probably the best way. On powerpc, we have done a lot of work
to make it possible to have kernels support multiple platforms
even in the embedded space. You don't have to do it, but we found it
important to allow for it.

It forces to keep the code cleaner, but also makes it possible for
somebody release a range of products based on different designs to
support/release single binary images for the entire product range
(at least provided it's the same CPU core "family", we don't currently
support single binaries mixing for example 44x and 8xx processor
support). What to actually do at runtime being decided based on the
content of a "device-tree" passed to the kernel by the firmware or the
boot wrapper.

Thus, I find it a good idea to allow the option even for embedded
drivers to be built with runtime detection of access method.

Cheers,
Ben.



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

end of thread, other threads:[~2008-08-07 13:46 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-08-02 14:35 [PATCH 3/4] Fix remaining big endian issue of hfcmulti Karsten Keil
2008-08-04 12:03 ` David Woodhouse
2008-08-04 14:29   ` Karsten Keil
2008-08-05  4:29 ` Benjamin Herrenschmidt
2008-08-05 11:31   ` Karsten Keil
2008-08-05 13:04     ` Benjamin Herrenschmidt
2008-08-05 17:25       ` Karsten Keil
2008-08-05 18:42         ` Linus Torvalds
2008-08-05 21:02           ` Karsten Keil
2008-08-05 21:23             ` Sean MacLennan
2008-08-05 21:37               ` Linus Torvalds
2008-08-05 21:59                 ` Sean MacLennan
2008-08-05 23:04                   ` Benjamin Herrenschmidt
2008-08-05 23:38                     ` Sean MacLennan
2008-08-06  0:18                   ` Karsten Keil
2008-08-06  0:33                     ` Benjamin Herrenschmidt
2008-08-05 21:46               ` Benjamin Herrenschmidt
2008-08-05 21:45             ` Benjamin Herrenschmidt
2008-08-05 21:43         ` Benjamin Herrenschmidt
  -- strict thread matches above, loose matches on Subject: below --
2008-08-07 11:01 AW: " Andreas.Eversberg
2008-08-07 13:46 ` Karsten Keil

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox