linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* find_child_device() on ACPI node works only once
@ 2016-09-19 18:08 Timur Tabi
  0 siblings, 0 replies; only message in thread
From: Timur Tabi @ 2016-09-19 18:08 UTC (permalink / raw)
  To: linux-arm-kernel

I need help getting my ACPI table parsing code to work correctly.  My 
driver fails to find the child device in a node when the driver is 
unloaded and reloaded.  I suspect that I'm not freeing a resource correctly.

Here is my ACPI table (trimmed):

Device (MAC0) {
	Name (_HID, "QCOM8070")
	Name (_UID, 0)
	Method (_CRS, 0x0, Serialized) {
		Name (RBUF, ResourceTemplate() {
			...
			Return (RBUF)
		}
	}
	Device (IPHY) {
		Name (_HID, "QCOM8071")

		Method (_CRS, 0x0, Serialized) {
			Name (RBUF, ResourceTemplate () {
				...
			Return (RBUF)
		}
	}


So QCOM8071 is a child device for QCOM8070.  The driver probes on 
QCOM8070 and then manually instantiates QCOM8071.

static const struct acpi_device_id emac_acpi_match[] = {
	{
		.id = "QCOM8070",
	},
	{}
};
MODULE_DEVICE_TABLE(acpi, emac_acpi_match);

static struct platform_driver emac_platform_driver = {
	.probe	= emac_probe,
	.remove	= emac_remove,
	.driver = {
		.name		= "qcom-emac",
		.acpi_match_table = ACPI_PTR(emac_acpi_match),
	},
};

In emac_probe, I do this:

struct device *dev;

dev = device_find_child(&pdev->dev, NULL, emac_sgmii_acpi_match);
adpt->sgmii_pdev = to_platform_device(dev);

And here's emac_sgmii_acpi_match:

> static int emac_sgmii_acpi_match(struct device *dev, void *data)
> {
> 	static const struct acpi_device_id match_table[] = {
> 		{
> 			.id = "QCOM8071",
> 		},
> 		{}
> 	};
> 	const struct acpi_device_id *id = acpi_match_device(match_table, dev);
>
> 	return !!id;
> }

When my driver exits, I call

	platform_device_unregister(adpt->sgmii_pdev);

So here's the problem: the second time my driver is loaded, 
emac_sgmii_acpi_match() always returns false.  The QCOM8071 child node 
no longer exists.  It's apparently hidden in some way.

I've been trying for several days to debug this, and I'm at my wits' 
end.  I'm assuming that I'm not freeing the resource properly, but other 
than calling platform_device_unregister(), what else should I do?

-- 
Qualcomm Datacenter Technologies, Inc. as an affiliate of Qualcomm
Technologies, Inc.  Qualcomm Technologies, Inc. is a member of the
Code Aurora Forum, a Linux Foundation Collaborative Project.

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2016-09-19 18:08 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-09-19 18:08 find_child_device() on ACPI node works only once Timur Tabi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).