Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1207905

Re: [PATCH 3/5] net: add Hisilicon Network Subsystem MDIO support

From Arnd Bergmann <arnd@arndb.de>
Newsgroups linux.kernel
Subject Re: [PATCH 3/5] net: add Hisilicon Network Subsystem MDIO support
Date 2015-08-14 23:00 +0200
Message-ID <pXuf0-4RW-19@gated-at.bofh.it> (permalink)
References <pXkpk-7IY-5@gated-at.bofh.it> <pXkpk-7IY-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Friday 14 August 2015 18:30:20 Kenneth Lee wrote:

> +#define MDIO_BASE_ADDR                 0x403C0000

Does not belong in here (and is not used)

> +#define MDIO_COMMAND_REG               0x0
> +#define MDIO_ADDR_REG                  0x4
> +#define MDIO_WDATA_REG                 0x8
> +#define MDIO_RDATA_REG                 0xc
> +#define MDIO_STA_REG                   0x10

These look suspiciously similar to definitions from
drivers/net/ethernet/hisilicon/hip04_mdio.c.

Could the hardware be related? If so, please try to share
the common parts.

> +static inline void mdio_write_reg(void *base, u32 reg, u32 value)
> +{
> +       u8 __iomem *reg_addr = ACCESS_ONCE(base);
> +
> +       writel(value, reg_addr + reg);
> +}
> +
> +#define MDIO_WRITE_REG(a, reg, value) \
> +       mdio_write_reg((a)->vbase, (reg), (value))
> 

Something seems wrong here: why do you have an ACCESS_ONCE() on a
local variable? Doesn't this just make the code less efficient
without providing lockless access to shared variables?

The types are inconsistent here, you should get a warning from
running this through 'make C=1' because of the missing __iomem
annotation of the pointer.

Also, why both a macro and an inline function? Just use an inline
function.

	Arnd
--
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/

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 3/5] net: add Hisilicon Network Subsystem MDIO support Kenneth Lee <liguozhu@hisilicon.com> - 2015-08-14 12:30 +0200
  Re: [PATCH 3/5] net: add Hisilicon Network Subsystem MDIO support Arnd Bergmann <arnd@arndb.de> - 2015-08-14 23:00 +0200
    Re: [PATCH 3/5] net: add Hisilicon Network Subsystem MDIO support Kenneth Lee <liguozhu@hisilicon.com> - 2015-08-17 11:20 +0200

csiph-web