Re: On register r/w macros/procedures of drivers/media/pci

From: Andrey Utkin
Date: Sun Apr 19 2015 - 04:56:13 EST


On Sun, Apr 19, 2015 at 11:28 AM, Hans Verkuil <hverkuil@xxxxxxxxx> wrote:
> Check the types of llmio and bbmio:
>
> u32 __iomem *lmmio;
> u8 __iomem *bmmio;
>
> So the values of the pointers are the same, but the types are not.
>
> So 'lmmio + 1' == 'bmmio + sizeof(u32)' == 'bbmio + 4'.
>
> Since all the registers are defined as byte offsets relative to the start
> of the memory map you cannot just do 'lmmio + reg' since that would be a
> factor 4 off. Instead you have to divide by 4 to get it back in line.
>
> Frankly, I don't think lmmio is necessary at all since readl/writel don't
> need a u32 pointer at all since they use void pointers. I never noticed
> that when I cleaned up the tw68 driver. Using 'void __iomem *mmio' instead
> of lmmio/bmmio and dropping the shifts in the tw_ macros would work just
> as well.

>
> Hope this helps,

Oh, indeed, I have forgot this basic thing of pointer arithmetics.
Thanks a lot for elaboration and the proposed solution.

--
Bluecherry developer.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/