Skip to content

Commit 3ddaf13

Browse files
andy-shevrafaeljw
authored andcommitted
i2c: mlxbf: Refactor _UID handling to use acpi_dev_uid_to_integer()
ACPI utils provide acpi_dev_uid_to_integer() helper to extract _UID as an integer. Use it instead of custom approach. Signed-off-by: Andy Shevchenko <[email protected]> Acked-by: Wolfram Sang <[email protected]> Reviewed-by: Hans de Goede <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent f4c6752 commit 3ddaf13

File tree

1 file changed

+6
-14
lines changed

1 file changed

+6
-14
lines changed

drivers/i2c/busses/i2c-mlxbf.c

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2229,35 +2229,27 @@ MODULE_DEVICE_TABLE(acpi, mlxbf_i2c_acpi_ids);
22292229
static int mlxbf_i2c_acpi_probe(struct device *dev, struct mlxbf_i2c_priv *priv)
22302230
{
22312231
const struct acpi_device_id *aid;
2232-
struct acpi_device *adev;
2233-
unsigned long bus_id = 0;
2234-
const char *uid;
2232+
u64 bus_id;
22352233
int ret;
22362234

22372235
if (acpi_disabled)
22382236
return -ENOENT;
22392237

2240-
adev = ACPI_COMPANION(dev);
2241-
if (!adev)
2242-
return -ENXIO;
2243-
22442238
aid = acpi_match_device(mlxbf_i2c_acpi_ids, dev);
22452239
if (!aid)
22462240
return -ENODEV;
22472241

22482242
priv->chip = (struct mlxbf_i2c_chip_info *)aid->driver_data;
22492243

2250-
uid = acpi_device_uid(adev);
2251-
if (!uid || !(*uid)) {
2244+
ret = acpi_dev_uid_to_integer(ACPI_COMPANION(dev), &bus_id);
2245+
if (ret) {
22522246
dev_err(dev, "Cannot retrieve UID\n");
2253-
return -ENODEV;
2247+
return ret;
22542248
}
22552249

2256-
ret = kstrtoul(uid, 0, &bus_id);
2257-
if (!ret)
2258-
priv->bus = bus_id;
2250+
priv->bus = bus_id;
22592251

2260-
return ret;
2252+
return 0;
22612253
}
22622254
#else
22632255
static int mlxbf_i2c_acpi_probe(struct device *dev, struct mlxbf_i2c_priv *priv)

0 commit comments

Comments
 (0)