Skip to content

Commit

Permalink
net: mdio-gpio: support access that may sleep
Browse files Browse the repository at this point in the history
Some systems using mdio-gpio may use gpio on message based busses, which
require sleeping (e.g. gpio from an I2C I/O expander).

Since this driver does not use IRQ handler, it is safe to use the
_cansleep suffixed gpio accessors.

Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
vivien authored and davem330 committed Apr 24, 2015
1 parent b357a36 commit 2d6c909
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions drivers/net/phy/mdio-gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ static void mdio_dir(struct mdiobb_ctrl *ctrl, int dir)
* assume the pin serves as pull-up. If direction is
* output, the default value is high.
*/
gpio_set_value(bitbang->mdo, 1 ^ bitbang->mdo_active_low);
gpio_set_value_cansleep(bitbang->mdo,
1 ^ bitbang->mdo_active_low);
return;
}

Expand All @@ -96,7 +97,8 @@ static int mdio_get(struct mdiobb_ctrl *ctrl)
struct mdio_gpio_info *bitbang =
container_of(ctrl, struct mdio_gpio_info, ctrl);

return gpio_get_value(bitbang->mdio) ^ bitbang->mdio_active_low;
return gpio_get_value_cansleep(bitbang->mdio) ^
bitbang->mdio_active_low;
}

static void mdio_set(struct mdiobb_ctrl *ctrl, int what)
Expand All @@ -105,17 +107,19 @@ static void mdio_set(struct mdiobb_ctrl *ctrl, int what)
container_of(ctrl, struct mdio_gpio_info, ctrl);

if (bitbang->mdo)
gpio_set_value(bitbang->mdo, what ^ bitbang->mdo_active_low);
gpio_set_value_cansleep(bitbang->mdo,
what ^ bitbang->mdo_active_low);
else
gpio_set_value(bitbang->mdio, what ^ bitbang->mdio_active_low);
gpio_set_value_cansleep(bitbang->mdio,
what ^ bitbang->mdio_active_low);
}

static void mdc_set(struct mdiobb_ctrl *ctrl, int what)
{
struct mdio_gpio_info *bitbang =
container_of(ctrl, struct mdio_gpio_info, ctrl);

gpio_set_value(bitbang->mdc, what ^ bitbang->mdc_active_low);
gpio_set_value_cansleep(bitbang->mdc, what ^ bitbang->mdc_active_low);
}

static struct mdiobb_ops mdio_gpio_ops = {
Expand Down

0 comments on commit 2d6c909

Please sign in to comment.