Skip to content

Commit c4ebde3

Browse files
sudeep-hollakuba-moo
authored andcommitted
net: phy: fixed_phy: transition to the faux device interface
The net fixed phy driver does not require the creation of a platform device. Originally, this approach was chosen for simplicity when the driver was first implemented. With the introduction of the lightweight faux device interface, we now have a more appropriate alternative. Migrate the device to utilize the faux bus, given that the platform device it previously created was not a real one anyway. This will get rid of the fake platform device. Cc: Andrew Lunn <[email protected]> Signed-off-by: Sudeep Holla <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 8112d5f commit c4ebde3

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

drivers/net/phy/fixed_phy.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
#include <linux/kernel.h>
1212
#include <linux/module.h>
13-
#include <linux/platform_device.h>
13+
#include <linux/device/faux.h>
1414
#include <linux/list.h>
1515
#include <linux/mii.h>
1616
#include <linux/phy.h>
@@ -40,7 +40,7 @@ struct fixed_phy {
4040
struct gpio_desc *link_gpiod;
4141
};
4242

43-
static struct platform_device *pdev;
43+
static struct faux_device *fdev;
4444
static struct fixed_mdio_bus platform_fmb = {
4545
.phys = LIST_HEAD_INIT(platform_fmb.phys),
4646
};
@@ -337,9 +337,9 @@ static int __init fixed_mdio_bus_init(void)
337337
struct fixed_mdio_bus *fmb = &platform_fmb;
338338
int ret;
339339

340-
pdev = platform_device_register_simple("Fixed MDIO bus", 0, NULL, 0);
341-
if (IS_ERR(pdev))
342-
return PTR_ERR(pdev);
340+
fdev = faux_device_create("Fixed MDIO bus", NULL, NULL);
341+
if (!fdev)
342+
return -ENODEV;
343343

344344
fmb->mii_bus = mdiobus_alloc();
345345
if (fmb->mii_bus == NULL) {
@@ -350,7 +350,7 @@ static int __init fixed_mdio_bus_init(void)
350350
snprintf(fmb->mii_bus->id, MII_BUS_ID_SIZE, "fixed-0");
351351
fmb->mii_bus->name = "Fixed MDIO Bus";
352352
fmb->mii_bus->priv = fmb;
353-
fmb->mii_bus->parent = &pdev->dev;
353+
fmb->mii_bus->parent = &fdev->dev;
354354
fmb->mii_bus->read = &fixed_mdio_read;
355355
fmb->mii_bus->write = &fixed_mdio_write;
356356
fmb->mii_bus->phy_mask = ~0;
@@ -364,7 +364,7 @@ static int __init fixed_mdio_bus_init(void)
364364
err_mdiobus_alloc:
365365
mdiobus_free(fmb->mii_bus);
366366
err_mdiobus_reg:
367-
platform_device_unregister(pdev);
367+
faux_device_destroy(fdev);
368368
return ret;
369369
}
370370
module_init(fixed_mdio_bus_init);
@@ -376,7 +376,7 @@ static void __exit fixed_mdio_bus_exit(void)
376376

377377
mdiobus_unregister(fmb->mii_bus);
378378
mdiobus_free(fmb->mii_bus);
379-
platform_device_unregister(pdev);
379+
faux_device_destroy(fdev);
380380

381381
list_for_each_entry_safe(fp, tmp, &fmb->phys, node) {
382382
list_del(&fp->node);

0 commit comments

Comments
 (0)