Skip to contentSkip to conversation

Being more anal about iospace accesses..

DISCUSSION [email protected] 1 participant 1 message Sep 15, 2004

lore
Share & tools
lore
#0 lore raw
Quoted 25 lines

Nice.

But it still leaves me confused. Before I had this code:

	struct regs {
		uint32_t status;
		...
	}

	...

	struct regs *regs = ioremap(...);
	uint32_t status = regs->status;
	...

So now I should do it like this:

	#define REG_STATUS 0

	...

	void __iomem *regs = ioremap(...);
	uint32_t status = readl(regs + REG_STATUS);
	...
Quoted 4 lines

But wait, that only works when long is 32bit wide. Plus I could be stupid enough and "#define REG_STATUS 64" while the register space is just 64 bytes long. It solves the confusion about address spaces, agreed, but overall I'm more confused now. Hope it's just temporary.

No, you should do:

	struct regs {
	      uint32_t status;
	      ...
	}

	...

	struct regs __iomem *regs = ioremap(...);
	uint32_t status = ioread32(&regs->status);