Commit 83c4a4ee authored by Rob Herring's avatar Rob Herring
Browse files

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: default avatarRob Herring <robh@kernel.org>
Reviewed-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Link: https://lore.kernel.org/r/20210211232745.1498137-2-robh@kernel.org
parent 7cbe8939
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -355,12 +355,12 @@ static int ibmebus_bus_device_probe(struct device *dev)
	if (!drv->probe)
		return error;

	of_dev_get(of_dev);
	get_device(dev);

	if (of_driver_match_device(dev, dev->driver))
		error = drv->probe(of_dev);
	if (error)
		of_dev_put(of_dev);
		put_device(dev);

	return error;
}
+8 −7
Original line number Diff line number Diff line
@@ -38,6 +38,7 @@
#include <linux/of_irq.h>
#include <linux/of_net.h>
#include <linux/of_mdio.h>
#include <linux/platform_device.h>
#include <linux/slab.h>

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

static void emac_put_deps(struct emac_instance *dev)
{
	of_dev_put(dev->mal_dev);
	of_dev_put(dev->zmii_dev);
	of_dev_put(dev->rgmii_dev);
	of_dev_put(dev->mdio_dev);
	of_dev_put(dev->tah_dev);
	platform_device_put(dev->mal_dev);
	platform_device_put(dev->zmii_dev);
	platform_device_put(dev->rgmii_dev);
	platform_device_put(dev->mdio_dev);
	platform_device_put(dev->tah_dev);
}

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)
	for (i = 0; i < EMAC_DEP_COUNT; i++) {
		of_node_put(deps[i].node);
		if (err)
			of_dev_put(deps[i].ofdev);
			platform_device_put(deps[i].ofdev);
	}
	if (err == 0) {
		dev->mal_dev = deps[EMAC_DEP_MAL_IDX].ofdev;
@@ -2444,7 +2445,7 @@ static int emac_wait_deps(struct emac_instance *dev)
		dev->tah_dev = deps[EMAC_DEP_TAH_IDX].ofdev;
		dev->mdio_dev = deps[EMAC_DEP_MDIO_IDX].ofdev;
	}
	of_dev_put(deps[EMAC_DEP_PREV_IDX].ofdev);
	platform_device_put(deps[EMAC_DEP_PREV_IDX].ofdev);
	return err;
}

+0 −21
Original line number Diff line number Diff line
@@ -33,27 +33,6 @@ const struct of_device_id *of_match_device(const struct of_device_id *matches,
}
EXPORT_SYMBOL(of_match_device);

struct platform_device *of_dev_get(struct platform_device *dev)
{
	struct device *tmp;

	if (!dev)
		return NULL;
	tmp = get_device(&dev->dev);
	if (tmp)
		return to_platform_device(tmp);
	else
		return NULL;
}
EXPORT_SYMBOL(of_dev_get);

void of_dev_put(struct platform_device *dev)
{
	if (dev)
		put_device(&dev->dev);
}
EXPORT_SYMBOL(of_dev_put);

int of_device_add(struct platform_device *ofdev)
{
	BUG_ON(ofdev->dev.of_node == NULL);
+2 −2
Original line number Diff line number Diff line
@@ -687,7 +687,7 @@ static int of_platform_notify(struct notifier_block *nb,
		pdev_parent = of_find_device_by_node(rd->dn->parent);
		pdev = of_platform_device_create(rd->dn, NULL,
				pdev_parent ? &pdev_parent->dev : NULL);
		of_dev_put(pdev_parent);
		platform_device_put(pdev_parent);

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

		/* and put the reference of the find */
		of_dev_put(pdev);
		platform_device_put(pdev);
		break;
	}

+1 −1
Original line number Diff line number Diff line
@@ -1286,7 +1286,7 @@ static void __init of_unittest_platform_populate(void)
			unittest(pdev,
				 "Could not create device for node '%pOFn'\n",
				 grandchild);
			of_dev_put(pdev);
			platform_device_put(pdev);
		}
	}

Loading