Re: [DVB patch 17/51] flexcop: add big endian register definitions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

On Tue, 28 Jun 2005, Johannes Stezenbach wrote:
+	struct {
+		u32 dma_address0                   :30;
+		u32 dma_0No_update                 : 1;
+		u32 dma_0start                     : 1;
+	} dma_0x0;
...
+
+	struct {
+		u32 dma_0start                     : 1;
+		u32 dma_0No_update                 : 1;
+		u32 dma_address0                   :30;
+	} dma_0x0;

Oh dear.  This is a good demonstration of the downside of trying to use
compiler bitfields to represent hardware registers.  I have vague memories
of writing BFINS and BFEXT in 3c59x to stomp this problem.

I don't think there's any guarantee that the code you have there will work
on all architectures/compiler versions btw.

Also...  The code appears to be assuming that BE architectures will
bit-reverse their bitfields.  Is that right?  I'd expect them to only
byte-reverse them?

Probably the code should use __BIG_ENDIAN_BITFIELD /
__LITTLE_ENDIAN_BITFIELD instead of __BIG_ENDIAN / __LITTLE_ENDIAN?
Anyway, the comment from the CVS commit suggests that it was tested.

According to the user, it is tested and it is running flawlessly for
2 weeks now.

I completely agree that this code is ugly as hell. It was the obvious, simple fix to make the driver work on PowerPC (and a few users happy), though. Rewriting the driver not to use bitfields seems to be quite a bit of work. Blame me for not paying enough attention when the initial flexcop driver was submitted ;-(

It's my fault. The driver (skystar2) which has been replaced by the flexcop-driver was so complicated to read, because of an IMHO abuse of bitmask and bit-shifting. I absolutely wanted to bring more readability to that driver without having the endian-issue in mind (rewrite was possible after the vendor released the data sheets). Sorry for that.

regards,
Patrick.

--
  Mail: [email protected]
  WWW:  http://www.wi-bw.tfh-wildau.de/~pboettch/
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux