Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751806AbbDSI4A (ORCPT ); Sun, 19 Apr 2015 04:56:00 -0400 Received: from mail-oi0-f44.google.com ([209.85.218.44]:36548 "EHLO mail-oi0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751053AbbDSIz6 (ORCPT ); Sun, 19 Apr 2015 04:55:58 -0400 MIME-Version: 1.0 In-Reply-To: <55336719.5000301@xs4all.nl> References: <55336719.5000301@xs4all.nl> Date: Sun, 19 Apr 2015 11:55:57 +0300 Message-ID: Subject: Re: On register r/w macros/procedures of drivers/media/pci From: Andrey Utkin To: Hans Verkuil Cc: Linux Media , "kernel-mentors@selenic.com" , "linux-kernel@vger.kernel.org" , "hans.verkuil" , khalasa Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1304 Lines: 33 On Sun, Apr 19, 2015 at 11:28 AM, Hans Verkuil 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@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/