Skip to content

Commit 83c4a4e

Browse files
committed
of: Remove of_dev_{get,put}()
of_dev_get() and of_dev_put are just wrappers for get_device()/put_device() on a platform_device. There's also already platform_device_{get,put}() wrappers for this purpose. Let's update the few users and remove of_dev_{get,put}(). Cc: Michael Ellerman <[email protected]> Cc: Benjamin Herrenschmidt <[email protected]> Cc: Paul Mackerras <[email protected]> Cc: "David S. Miller" <[email protected]> Cc: Jakub Kicinski <[email protected]> Cc: Frank Rowand <[email protected]> Cc: Patrice Chotard <[email protected]> Cc: Felipe Balbi <[email protected]> Cc: Julia Lawall <[email protected]> Cc: Gilles Muller <[email protected]> Cc: Nicolas Palix <[email protected]> Cc: Michal Marek <[email protected]> Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Signed-off-by: Rob Herring <[email protected]> Reviewed-by: Greg Kroah-Hartman <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 7cbe893 commit 83c4a4e

File tree

8 files changed

+14
-38
lines changed

8 files changed

+14
-38
lines changed

arch/powerpc/platforms/pseries/ibmebus.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -355,12 +355,12 @@ static int ibmebus_bus_device_probe(struct device *dev)
355355
if (!drv->probe)
356356
return error;
357357

358-
of_dev_get(of_dev);
358+
get_device(dev);
359359

360360
if (of_driver_match_device(dev, dev->driver))
361361
error = drv->probe(of_dev);
362362
if (error)
363-
of_dev_put(of_dev);
363+
put_device(dev);
364364

365365
return error;
366366
}

drivers/net/ethernet/ibm/emac/core.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
#include <linux/of_irq.h>
3939
#include <linux/of_net.h>
4040
#include <linux/of_mdio.h>
41+
#include <linux/platform_device.h>
4142
#include <linux/slab.h>
4243

4344
#include <asm/processor.h>
@@ -2390,11 +2391,11 @@ static int emac_check_deps(struct emac_instance *dev,
23902391

23912392
static void emac_put_deps(struct emac_instance *dev)
23922393
{
2393-
of_dev_put(dev->mal_dev);
2394-
of_dev_put(dev->zmii_dev);
2395-
of_dev_put(dev->rgmii_dev);
2396-
of_dev_put(dev->mdio_dev);
2397-
of_dev_put(dev->tah_dev);
2394+
platform_device_put(dev->mal_dev);
2395+
platform_device_put(dev->zmii_dev);
2396+
platform_device_put(dev->rgmii_dev);
2397+
platform_device_put(dev->mdio_dev);
2398+
platform_device_put(dev->tah_dev);
23982399
}
23992400

24002401
static int emac_of_bus_notify(struct notifier_block *nb, unsigned long action,
@@ -2435,7 +2436,7 @@ static int emac_wait_deps(struct emac_instance *dev)
24352436
for (i = 0; i < EMAC_DEP_COUNT; i++) {
24362437
of_node_put(deps[i].node);
24372438
if (err)
2438-
of_dev_put(deps[i].ofdev);
2439+
platform_device_put(deps[i].ofdev);
24392440
}
24402441
if (err == 0) {
24412442
dev->mal_dev = deps[EMAC_DEP_MAL_IDX].ofdev;
@@ -2444,7 +2445,7 @@ static int emac_wait_deps(struct emac_instance *dev)
24442445
dev->tah_dev = deps[EMAC_DEP_TAH_IDX].ofdev;
24452446
dev->mdio_dev = deps[EMAC_DEP_MDIO_IDX].ofdev;
24462447
}
2447-
of_dev_put(deps[EMAC_DEP_PREV_IDX].ofdev);
2448+
platform_device_put(deps[EMAC_DEP_PREV_IDX].ofdev);
24482449
return err;
24492450
}
24502451

drivers/of/device.c

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -33,27 +33,6 @@ const struct of_device_id *of_match_device(const struct of_device_id *matches,
3333
}
3434
EXPORT_SYMBOL(of_match_device);
3535

36-
struct platform_device *of_dev_get(struct platform_device *dev)
37-
{
38-
struct device *tmp;
39-
40-
if (!dev)
41-
return NULL;
42-
tmp = get_device(&dev->dev);
43-
if (tmp)
44-
return to_platform_device(tmp);
45-
else
46-
return NULL;
47-
}
48-
EXPORT_SYMBOL(of_dev_get);
49-
50-
void of_dev_put(struct platform_device *dev)
51-
{
52-
if (dev)
53-
put_device(&dev->dev);
54-
}
55-
EXPORT_SYMBOL(of_dev_put);
56-
5736
int of_device_add(struct platform_device *ofdev)
5837
{
5938
BUG_ON(ofdev->dev.of_node == NULL);

drivers/of/platform.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -687,7 +687,7 @@ static int of_platform_notify(struct notifier_block *nb,
687687
pdev_parent = of_find_device_by_node(rd->dn->parent);
688688
pdev = of_platform_device_create(rd->dn, NULL,
689689
pdev_parent ? &pdev_parent->dev : NULL);
690-
of_dev_put(pdev_parent);
690+
platform_device_put(pdev_parent);
691691

692692
if (pdev == NULL) {
693693
pr_err("%s: failed to create for '%pOF'\n",
@@ -712,7 +712,7 @@ static int of_platform_notify(struct notifier_block *nb,
712712
of_platform_device_destroy(&pdev->dev, &children_left);
713713

714714
/* and put the reference of the find */
715-
of_dev_put(pdev);
715+
platform_device_put(pdev);
716716
break;
717717
}
718718

drivers/of/unittest.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1286,7 +1286,7 @@ static void __init of_unittest_platform_populate(void)
12861286
unittest(pdev,
12871287
"Could not create device for node '%pOFn'\n",
12881288
grandchild);
1289-
of_dev_put(pdev);
1289+
platform_device_put(pdev);
12901290
}
12911291
}
12921292

drivers/usb/dwc3/dwc3-st.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ static int st_dwc3_probe(struct platform_device *pdev)
274274

275275
dwc3_data->dr_mode = usb_get_dr_mode(&child_pdev->dev);
276276
of_node_put(child);
277-
of_dev_put(child_pdev);
277+
platform_device_put(child_pdev);
278278

279279
/*
280280
* Configure the USB port as device or host according to the static

include/linux/of_device.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@ static inline int of_driver_match_device(struct device *dev,
2626
return of_match_device(drv->of_match_table, dev) != NULL;
2727
}
2828

29-
extern struct platform_device *of_dev_get(struct platform_device *dev);
30-
extern void of_dev_put(struct platform_device *dev);
31-
3229
extern int of_device_add(struct platform_device *pdev);
3330
extern int of_device_register(struct platform_device *ofdev);
3431
extern void of_device_unregister(struct platform_device *ofdev);

scripts/coccinelle/free/put_device.cocci

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ id = of_find_device_by_node@p1(x)
2121
if (id == NULL || ...) { ... return ...; }
2222
... when != put_device(&id->dev)
2323
when != platform_device_put(id)
24-
when != of_dev_put(id)
2524
when != if (id) { ... put_device(&id->dev) ... }
2625
when != e1 = (T)id
2726
when != e1 = (T)(&id->dev)

0 commit comments

Comments
 (0)