Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <mpe@ellerman.id.au>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Jakub Kicinski <kuba@kernel.org>
Cc: Frank Rowand <frowand.list@gmail.com>
Cc: Patrice Chotard <patrice.chotard@st.com>
Cc: Felipe Balbi <balbi@kernel.org>
Cc: Julia Lawall <Julia.Lawall@inria.fr>
Cc: Gilles Muller <Gilles.Muller@inria.fr>
Cc: Nicolas Palix <nicolas.palix@imag.fr>
Cc: Michal Marek <michal.lkml@markovi.net>
Cc: linuxppc-dev@lists.ozlabs.org
Cc: netdev@vger.kernel.org
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-usb@vger.kernel.org
Cc: cocci@systeme.lip6.fr
Signed-off-by: Rob Herring <robh@kernel.org>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Link: https://lore.kernel.org/r/20210211232745.1498137-2-robh@kernel.org

+14 -38
+2 -2
arch/powerpc/platforms/pseries/ibmebus.c
··· 355 355 if (!drv->probe) 356 356 return error; 357 357 358 - of_dev_get(of_dev); 358 + get_device(dev); 359 359 360 360 if (of_driver_match_device(dev, dev->driver)) 361 361 error = drv->probe(of_dev); 362 362 if (error) 363 - of_dev_put(of_dev); 363 + put_device(dev); 364 364 365 365 return error; 366 366 }
+8 -7
drivers/net/ethernet/ibm/emac/core.c
··· 38 38 #include <linux/of_irq.h> 39 39 #include <linux/of_net.h> 40 40 #include <linux/of_mdio.h> 41 + #include <linux/platform_device.h> 41 42 #include <linux/slab.h> 42 43 43 44 #include <asm/processor.h> ··· 2391 2390 2392 2391 static void emac_put_deps(struct emac_instance *dev) 2393 2392 { 2394 - of_dev_put(dev->mal_dev); 2395 - of_dev_put(dev->zmii_dev); 2396 - of_dev_put(dev->rgmii_dev); 2397 - of_dev_put(dev->mdio_dev); 2398 - of_dev_put(dev->tah_dev); 2393 + platform_device_put(dev->mal_dev); 2394 + platform_device_put(dev->zmii_dev); 2395 + platform_device_put(dev->rgmii_dev); 2396 + platform_device_put(dev->mdio_dev); 2397 + platform_device_put(dev->tah_dev); 2399 2398 } 2400 2399 2401 2400 static int emac_of_bus_notify(struct notifier_block *nb, unsigned long action, ··· 2436 2435 for (i = 0; i < EMAC_DEP_COUNT; i++) { 2437 2436 of_node_put(deps[i].node); 2438 2437 if (err) 2439 - of_dev_put(deps[i].ofdev); 2438 + platform_device_put(deps[i].ofdev); 2440 2439 } 2441 2440 if (err == 0) { 2442 2441 dev->mal_dev = deps[EMAC_DEP_MAL_IDX].ofdev; ··· 2445 2444 dev->tah_dev = deps[EMAC_DEP_TAH_IDX].ofdev; 2446 2445 dev->mdio_dev = deps[EMAC_DEP_MDIO_IDX].ofdev; 2447 2446 } 2448 - of_dev_put(deps[EMAC_DEP_PREV_IDX].ofdev); 2447 + platform_device_put(deps[EMAC_DEP_PREV_IDX].ofdev); 2449 2448 return err; 2450 2449 } 2451 2450
-21
drivers/of/device.c
··· 33 33 } 34 34 EXPORT_SYMBOL(of_match_device); 35 35 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 - 57 36 int of_device_add(struct platform_device *ofdev) 58 37 { 59 38 BUG_ON(ofdev->dev.of_node == NULL);
+2 -2
drivers/of/platform.c
··· 687 687 pdev_parent = of_find_device_by_node(rd->dn->parent); 688 688 pdev = of_platform_device_create(rd->dn, NULL, 689 689 pdev_parent ? &pdev_parent->dev : NULL); 690 - of_dev_put(pdev_parent); 690 + platform_device_put(pdev_parent); 691 691 692 692 if (pdev == NULL) { 693 693 pr_err("%s: failed to create for '%pOF'\n", ··· 712 712 of_platform_device_destroy(&pdev->dev, &children_left); 713 713 714 714 /* and put the reference of the find */ 715 - of_dev_put(pdev); 715 + platform_device_put(pdev); 716 716 break; 717 717 } 718 718
+1 -1
drivers/of/unittest.c
··· 1286 1286 unittest(pdev, 1287 1287 "Could not create device for node '%pOFn'\n", 1288 1288 grandchild); 1289 - of_dev_put(pdev); 1289 + platform_device_put(pdev); 1290 1290 } 1291 1291 } 1292 1292
+1 -1
drivers/usb/dwc3/dwc3-st.c
··· 274 274 275 275 dwc3_data->dr_mode = usb_get_dr_mode(&child_pdev->dev); 276 276 of_node_put(child); 277 - of_dev_put(child_pdev); 277 + platform_device_put(child_pdev); 278 278 279 279 /* 280 280 * Configure the USB port as device or host according to the static
-3
include/linux/of_device.h
··· 26 26 return of_match_device(drv->of_match_table, dev) != NULL; 27 27 } 28 28 29 - extern struct platform_device *of_dev_get(struct platform_device *dev); 30 - extern void of_dev_put(struct platform_device *dev); 31 - 32 29 extern int of_device_add(struct platform_device *pdev); 33 30 extern int of_device_register(struct platform_device *ofdev); 34 31 extern void of_device_unregister(struct platform_device *ofdev);
-1
scripts/coccinelle/free/put_device.cocci
··· 21 21 if (id == NULL || ...) { ... return ...; } 22 22 ... when != put_device(&id->dev) 23 23 when != platform_device_put(id) 24 - when != of_dev_put(id) 25 24 when != if (id) { ... put_device(&id->dev) ... } 26 25 when != e1 = (T)id 27 26 when != e1 = (T)(&id->dev)