Skip to content

Commit fb76642

Browse files
lunndavem330
authored andcommitted
net: phy: mdio-gpio: Move allocation for bitbanging data
Moving the allocation of this structure to the probe function is a step towards making it the core data structure of the driver. Signed-off-by: Andrew Lunn <andrew@lunn.ch> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent c82fc48 commit fb76642

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

drivers/net/phy/mdio-gpio.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -115,15 +115,11 @@ static const struct mdiobb_ops mdio_gpio_ops = {
115115
};
116116

117117
static struct mii_bus *mdio_gpio_bus_init(struct device *dev,
118+
struct mdio_gpio_info *bitbang,
118119
struct mdio_gpio_platform_data *pdata,
119120
int bus_id)
120121
{
121122
struct mii_bus *new_bus;
122-
struct mdio_gpio_info *bitbang;
123-
124-
bitbang = devm_kzalloc(dev, sizeof(*bitbang), GFP_KERNEL);
125-
if (!bitbang)
126-
return NULL;
127123

128124
bitbang->ctrl.ops = &mdio_gpio_ops;
129125
bitbang->mdc = pdata->mdc;
@@ -165,9 +161,14 @@ static void mdio_gpio_bus_destroy(struct device *dev)
165161
static int mdio_gpio_probe(struct platform_device *pdev)
166162
{
167163
struct mdio_gpio_platform_data *pdata;
164+
struct mdio_gpio_info *bitbang;
168165
struct mii_bus *new_bus;
169166
int ret, bus_id;
170167

168+
bitbang = devm_kzalloc(&pdev->dev, sizeof(*bitbang), GFP_KERNEL);
169+
if (!bitbang)
170+
return -ENOMEM;
171+
171172
if (pdev->dev.of_node) {
172173
pdata = mdio_gpio_of_get_data(&pdev->dev);
173174
bus_id = of_alias_get_id(pdev->dev.of_node, "mdio-gpio");
@@ -183,7 +184,7 @@ static int mdio_gpio_probe(struct platform_device *pdev)
183184
if (!pdata)
184185
return -ENODEV;
185186

186-
new_bus = mdio_gpio_bus_init(&pdev->dev, pdata, bus_id);
187+
new_bus = mdio_gpio_bus_init(&pdev->dev, bitbang, pdata, bus_id);
187188
if (!new_bus)
188189
return -ENODEV;
189190

0 commit comments

Comments
 (0)