Skip to content

Commit fb78a95

Browse files
lunndavem330
authored andcommitted
net: phy: mdio-gpio: Add #defines for the GPIO index's
The GPIOs are described in device tree using a list, without names. Add defines to indicate what each index in the list means. These defines should also be used by platform devices passing GPIOs via a GPIO lookup table. Signed-off-by: Andrew Lunn <andrew@lunn.ch> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 4029ea3 commit fb78a95

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

drivers/net/phy/mdio-gpio.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
#include <linux/slab.h>
2525
#include <linux/interrupt.h>
2626
#include <linux/platform_device.h>
27+
#include <linux/mdio-bitbang.h>
28+
#include <linux/mdio-gpio.h>
2729
#include <linux/gpio.h>
2830
#include <linux/platform_data/mdio-gpio.h>
2931

@@ -38,15 +40,17 @@ struct mdio_gpio_info {
3840
static int mdio_gpio_get_data(struct device *dev,
3941
struct mdio_gpio_info *bitbang)
4042
{
41-
bitbang->mdc = devm_gpiod_get_index(dev, NULL, 0, GPIOD_OUT_LOW);
43+
bitbang->mdc = devm_gpiod_get_index(dev, NULL, MDIO_GPIO_MDC,
44+
GPIOD_OUT_LOW);
4245
if (IS_ERR(bitbang->mdc))
4346
return PTR_ERR(bitbang->mdc);
4447

45-
bitbang->mdio = devm_gpiod_get_index(dev, NULL, 1, GPIOD_IN);
48+
bitbang->mdio = devm_gpiod_get_index(dev, NULL, MDIO_GPIO_MDIO,
49+
GPIOD_IN);
4650
if (IS_ERR(bitbang->mdio))
4751
return PTR_ERR(bitbang->mdio);
4852

49-
bitbang->mdo = devm_gpiod_get_index_optional(dev, NULL, 2,
53+
bitbang->mdo = devm_gpiod_get_index_optional(dev, NULL, MDIO_GPIO_MDO,
5054
GPIOD_OUT_LOW);
5155
return PTR_ERR_OR_ZERO(bitbang->mdo);
5256
}

include/linux/mdio-gpio.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/* SPDX-License-Identifier: GPL-2.0 */
2+
#ifndef __LINUX_MDIO_GPIO_H
3+
#define __LINUX_MDIO_GPIO_H
4+
5+
#define MDIO_GPIO_MDC 0
6+
#define MDIO_GPIO_MDIO 1
7+
#define MDIO_GPIO_MDO 2
8+
9+
#endif

0 commit comments

Comments
 (0)