net: sfp: use i2c_get_adapter_by_fwnode()
authorRussell King (Oracle) <rmk+kernel@armlinux.org.uk>
Wed, 18 Jan 2023 10:20:58 +0000 (10:20 +0000)
committerJakub Kicinski <kuba@kernel.org>
Fri, 20 Jan 2023 02:55:30 +0000 (18:55 -0800)
Use the newly introduced i2c_get_adapter_by_fwnode() API, so that we
can retrieve the I2C adapter in a firmware independent manner once we
have the fwnode handle for the adapter.

Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/phy/sfp.c

index 83b99d95b2787ead5169592c20d0a5fd2b4c4746..aa2f7ebbdebc0805449b0563ce1136b056125318 100644 (file)
@@ -2644,10 +2644,8 @@ static void sfp_cleanup(void *data)
 
 static int sfp_i2c_get(struct sfp *sfp)
 {
-       struct acpi_handle *acpi_handle;
        struct fwnode_handle *h;
        struct i2c_adapter *i2c;
-       struct device_node *np;
        int err;
 
        h = fwnode_find_reference(dev_fwnode(sfp->dev), "i2c-bus", 0);
@@ -2656,16 +2654,7 @@ static int sfp_i2c_get(struct sfp *sfp)
                return -ENODEV;
        }
 
-       if (is_acpi_device_node(h)) {
-               acpi_handle = ACPI_HANDLE_FWNODE(h);
-               i2c = i2c_acpi_find_adapter_by_handle(acpi_handle);
-       } else if ((np = to_of_node(h)) != NULL) {
-               i2c = of_find_i2c_adapter_by_node(np);
-       } else {
-               err = -EINVAL;
-               goto put;
-       }
-
+       i2c = i2c_get_adapter_by_fwnode(h);
        if (!i2c) {
                err = -EPROBE_DEFER;
                goto put;