Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1305911
| From | "Yu, Xiangliang" <Xiangliang.Yu@amd.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | RE: [PATCH V2 1/3] NTB: Add AMD PCI-Express NTB driver |
| Date | 2016-01-11 08:30 +0100 |
| Message-ID | <qPF5o-7yx-7@gated-at.bofh.it> (permalink) |
| References | <qINU6-7NH-5@gated-at.bofh.it> <qNXSO-2Of-19@gated-at.bofh.it> <qO8XT-1Eh-1@gated-at.bofh.it> <qOGPU-8rM-39@gated-at.bofh.it> <qOHsC-gc-27@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
> From: Jon Mason <jdmason@kudzu.us> > > On Wed, Jan 6, 2016 at 9:50 PM, Yu, Xiangliang <Xiangliang.Yu@amd.com> > > wrote: > > >> > +#define NTB_READ_REG(base, r) (ioread32(base + AMD_ ## r ## > > >> _OFFSET)) > > >> > +#define NTB_WRITE_REG(base, val, r) (iowrite32(val, base + \ > > >> > + AMD_ ## r ## > > _OFFSET)) > > >> > +#define NTB_READ_OFFSET(base, r, of) (ioread32(base + of + > > \ > > >> > + AMD_ ## r ## > > _OFFSET)) > > >> > +#define NTB_WRITE_OFFSET(base, val, r, of) (iowrite32(val, base > > >> > ++ > > \ > > >> > + of + AMD_ ## r ## > > _OFFSET)) > > >> > > >> Please do not use marcos to hide ioread/iowrite. Call > > >> iorwad/iowrite > > directly. > > > > > > I don't see any wrong to hide ioread/iowrite, and I think the macros > > can make code readable and easy to maintain. > > > > I disagree. It is an unnecessary layer and can add to confusion. > > Please make the change. > > I don't like AMD_##r##_OFFSET in these macros. It hides the use of a > globally named constant like AMD_FOO_OFFSET, since one would read only > FOO in the code. It makes cross referencing difficult, since the reader needs > to know FOO is really AMD_FOO_OFFSET. This would defeat automatic cross > referencing like cscope and lxr. > > #define AMD_FOO_OFFSET 0xc0ff33 > vs > NTB_READ_OFFSET(dev->foo_base, FOO, offset_in_foo) // Where is FOO > defined? > > This macro would have at least been better written without ##; so cross > referencing would still work. > > NTB_READ_OFFSET(dev->foo_base, FOO, offset_in_foo) vs > NTB_READ_OFFSET(dev->foo_base, AMD_FOO_OFFSET, offset_in_foo) // > AMD_FOO_OFFSET is 0xcoff33 (obviously) > > But without ##, the macro is just the addition of its parameters. Change the > commas to addition, and the macro to ioread, and you'll see there is no > benefit for having this macro any more. > > NTB_READ_OFFSET(dev->foo_base, AMD_FOO_OFFSET, offset_in_foo) vs > ioread32(dev->foo_base + AMD_FOO_OFFSET + offset_in_foo) > > I second Jon's opinion. Please make the change. This would be better as > simply ioread/write in the code. The main aim of these macros is to focuses on the name of register (FOO), not the whole macros of register. and I see there are lots of these style in kernel. If your guys still can't accept the style, I can change it. And I'll change ioread/iowrite to readl/writel because it only access mmio space.
Back to linux.kernel | Previous | Next — Previous in thread | Find similar | Unroll thread
RE: [PATCH V2 1/3] NTB: Add AMD PCI-Express NTB driver "Yu, Xiangliang" <Xiangliang.Yu@amd.com> - 2016-01-07 04:00 +0100
Re: [PATCH V2 1/3] NTB: Add AMD PCI-Express NTB driver Jon Mason <jdmason@kudzu.us> - 2016-01-08 16:10 +0100
RE: [PATCH V2 1/3] NTB: Add AMD PCI-Express NTB driver "Allen Hubbe" <Allen.Hubbe@emc.com> - 2016-01-08 16:50 +0100
RE: [PATCH V2 1/3] NTB: Add AMD PCI-Express NTB driver "Yu, Xiangliang" <Xiangliang.Yu@amd.com> - 2016-01-11 08:30 +0100
csiph-web