Re: [PATCH 1/2] ahci: imx: use macros to define registers and bits

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

 



Hello,

On Wed, Apr 16, 2014 at 02:35:12PM +0800, Shawn Guo wrote:
> I'm seeing a lot of ata drivers use defines though.  And I'm not sure I
> understand the advantages of using enums over defines in ahci_imx
> driver, where register offset and bit position are defined in the same
> 'enum' without a particular enum type.
> 
> enum {
> 	PORT_PHY_CTL = 0x178,			/* Port0 PHY Control */
> 	PORT_PHY_CTL_PDDQ_LOC = 0x100000,	/* PORT_PHY_CTL bits */
> 	HOST_TIMER1MS = 0xe0,			/* Timer 1-ms */
> };
> 
> To me it's a misuse of enum.

The difference isn't that significant but enums have the advantages of
the definitions being evaluated once rather than each time it's used
which prevents things like missing parentheses subtly messing up the
containing expressions and the compiler, and thus the debugger, being
aware of the constants in use.

The technical advantages not being enormous, it's a good bike shedding
material and argue about it back and forth forever without being
productive at all, so, please just stick with enums.

Thanks.

-- 
tejun
--
To unsubscribe from this list: send the line "unsubscribe linux-ide" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Filesystems]     [Linux SCSI]     [Linux RAID]     [Git]     [Kernel Newbies]     [Linux Newbie]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Samba]     [Device Mapper]

  Powered by Linux