openwrtv4/target/linux/ar71xx/patches-4.4/901-phy-mdio-bitbang-prevent-rescheduling-during-command.patch
Gabor Juhos 4045f15a21 ar71xx: fix compiler warnings in mdio-bitbang.c for 4.4
Building Linux 4.4 for ar71xx throws the following warnings in
drivers/net/phy/mdio-bitbang.c:

    CC      drivers/net/phy/mdio-bitbang.o
  In file included from include/linux/irqflags.h:14:0,
                   from drivers/net/phy/mdio-bitbang.c:20:
  drivers/net/phy/mdio-bitbang.c: In function 'mdiobb_read':
  include/linux/typecheck.h:11:18: warning: comparison of distinct pointer types lacks a cast
    (void)(&__dummy == &__dummy2); \
                    ^
  include/linux/irqflags.h:63:3: note: in expansion of macro 'typecheck'
     typecheck(unsigned long, flags); \
     ^
  include/linux/irqflags.h:124:3: note: in expansion of macro 'raw_local_irq_save'
     raw_local_irq_save(flags);   \
     ^
  drivers/net/phy/mdio-bitbang.c:162:2: note: in expansion of macro 'local_irq_save'
    local_irq_save(flags);
    ^
  include/linux/typecheck.h:11:18: warning: comparison of distinct pointer types lacks a cast
    (void)(&__dummy == &__dummy2); \
                    ^
  include/linux/irqflags.h:68:3: note: in expansion of macro 'typecheck'
     typecheck(unsigned long, flags); \
     ^
  include/linux/irqflags.h:126:39: note: in expansion of macro 'raw_local_irq_restore'
   #define local_irq_restore(flags) do { raw_local_irq_restore(flags); } while (0)
                                         ^
  drivers/net/phy/mdio-bitbang.c:175:2: note: in expansion of macro 'local_irq_restore'
    local_irq_restore(flags);
    ^
  drivers/net/phy/mdio-bitbang.c:159:11: warning: unused variable 'i' [-Wunused-variable]
    int ret, i;
             ^
  In file included from include/linux/irqflags.h:14:0,
                   from drivers/net/phy/mdio-bitbang.c:20:
  drivers/net/phy/mdio-bitbang.c: In function 'mdiobb_write':
  include/linux/typecheck.h:11:18: warning: comparison of distinct pointer types lacks a cast
    (void)(&__dummy == &__dummy2); \
                    ^
  include/linux/irqflags.h:63:3: note: in expansion of macro 'typecheck'
     typecheck(unsigned long, flags); \
     ^
  include/linux/irqflags.h:124:3: note: in expansion of macro 'raw_local_irq_save'
     raw_local_irq_save(flags);   \
     ^
  drivers/net/phy/mdio-bitbang.c:185:2: note: in expansion of macro 'local_irq_save'
    local_irq_save(flags);
    ^
  include/linux/typecheck.h:11:18: warning: comparison of distinct pointer types lacks a cast
    (void)(&__dummy == &__dummy2); \
                    ^
  include/linux/irqflags.h:68:3: note: in expansion of macro 'typecheck'
     typecheck(unsigned long, flags); \
     ^
  include/linux/irqflags.h:126:39: note: in expansion of macro 'raw_local_irq_restore'
   #define local_irq_restore(flags) do { raw_local_irq_restore(flags); } while (0)
                                         ^
  drivers/net/phy/mdio-bitbang.c:200:2: note: in expansion of macro 'local_irq_restore'
    local_irq_restore(flags);
    ^

These are caused by the 900-mdio_bitbang_ignore_ta_value and
901-phy-mdio-bitbang-prevent-rescheduling-during-command patches.

The first patch removes some code but it does not remove the variable
which is used by the removed code only.

The second patch adds local_irq_{save,restore} calls. The type of the
argument of these calls must be 'unsigned long', but the patch defines
the variable as 'long'.

Fix both patches to silence the warnings.

Signed-off-by: Gabor Juhos <juhosg@freemail.hu>
2018-01-07 13:05:40 +01:00

61 lines
1.7 KiB
Diff

From 66e584435ac0de6e0abeb6d7166fe4fe25d6bb73 Mon Sep 17 00:00:00 2001
From: Jonas Gorski <jogo@openwrt.org>
Date: Tue, 16 Jun 2015 13:15:08 +0200
Subject: [PATCH] phy/mdio-bitbang: prevent rescheduling during command
It seems some phys have some maximum timings for accessing the MDIO line,
resulting in bit errors under cpu stress. Prevent this from happening by
disabling interrupts when sending commands.
Signed-off-by: Jonas Gorski <jogo@openwrt.org>
---
drivers/net/phy/mdio-bitbang.c | 9 +++++++++
1 file changed, 9 insertions(+)
--- a/drivers/net/phy/mdio-bitbang.c
+++ b/drivers/net/phy/mdio-bitbang.c
@@ -17,6 +17,7 @@
* kind, whether express or implied.
*/
+#include <linux/irqflags.h>
#include <linux/module.h>
#include <linux/mdio-bitbang.h>
#include <linux/types.h>
@@ -156,7 +157,9 @@ static int mdiobb_read(struct mii_bus *b
{
struct mdiobb_ctrl *ctrl = bus->priv;
int ret;
+ unsigned long flags;
+ local_irq_save(flags);
if (reg & MII_ADDR_C45) {
reg = mdiobb_cmd_addr(ctrl, phy, reg);
mdiobb_cmd(ctrl, MDIO_C45_READ, phy, reg);
@@ -169,13 +172,17 @@ static int mdiobb_read(struct mii_bus *b
ret = mdiobb_get_num(ctrl, 16);
mdiobb_get_bit(ctrl);
+ local_irq_restore(flags);
+
return ret;
}
static int mdiobb_write(struct mii_bus *bus, int phy, int reg, u16 val)
{
struct mdiobb_ctrl *ctrl = bus->priv;
+ unsigned long flags;
+ local_irq_save(flags);
if (reg & MII_ADDR_C45) {
reg = mdiobb_cmd_addr(ctrl, phy, reg);
mdiobb_cmd(ctrl, MDIO_C45_WRITE, phy, reg);
@@ -190,6 +197,8 @@ static int mdiobb_write(struct mii_bus *
ctrl->ops->set_mdio_dir(ctrl, 0);
mdiobb_get_bit(ctrl);
+ local_irq_restore(flags);
+
return 0;
}