Re: [net-next,v3 2/2] net: phy: sfp: enable i2c-bus detection on ACPI based systems

From
Mika Westerberg <mika.westerberg@linux.intel.com>
Date
2019-05-28 10:42:14
Also in
linux-acpi, linux-i2c, lkml
Reply to
Ruslan Babayev, 2019-05-28
On Mon, May 27, 2019 at 08:22:13PM -0700, Ruslan Babayev wrote:
+	} else if (ACPI_COMPANION(&pdev->dev)) {
You can also use has_acpi_companion() here.
quoted hunk ↗ jump to hunk
+		struct acpi_device *adev = ACPI_COMPANION(&pdev->dev);
+		struct fwnode_handle *fw = acpi_fwnode_handle(adev);
+		struct fwnode_reference_args args;
+		struct acpi_handle *acpi_handle;
+		int ret;
+
+		ret = acpi_node_get_property_reference(fw, "i2c-bus", 0, &args);
+		if (ACPI_FAILURE(ret) || !is_acpi_device_node(args.fwnode)) {
+			dev_err(&pdev->dev, "missing 'i2c-bus' property\n");
+			return -ENODEV;
 		}
+
+		acpi_handle = ACPI_HANDLE_FWNODE(args.fwnode);
+		i2c = i2c_acpi_find_adapter_by_handle(acpi_handle);
+	}
+
+	if (!i2c)
+		return -EPROBE_DEFER;
+
+	err = sfp_i2c_configure(sfp, i2c);
+	if (err < 0) {
+		i2c_put_adapter(i2c);
+		return err;
Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Thread (6 messages) 6 messages, 3 authors, last reply 2019-05-28
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help