mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-26 13:44:15 +08:00
i2c: amd-mp2-plat: 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 <andriy.shevchenko@linux.intel.com> Acked-by: Wolfram Sang <wsa@kernel.org> Reviewed-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
This commit is contained in:
parent
197a5aeaf6
commit
f4c6752df9
@ -244,14 +244,18 @@ static const struct i2c_adapter_quirks amd_i2c_dev_quirks = {
|
||||
|
||||
static int i2c_amd_probe(struct platform_device *pdev)
|
||||
{
|
||||
struct device *dev = &pdev->dev;
|
||||
int ret;
|
||||
struct amd_i2c_dev *i2c_dev;
|
||||
struct acpi_device *adev = ACPI_COMPANION(&pdev->dev);
|
||||
struct amd_mp2_dev *mp2_dev;
|
||||
const char *uid;
|
||||
u64 uid;
|
||||
|
||||
if (!adev)
|
||||
return -ENODEV;
|
||||
ret = acpi_dev_uid_to_integer(ACPI_COMPANION(dev), &uid);
|
||||
if (ret)
|
||||
return dev_err_probe(dev, ret, "missing UID/bus id!\n");
|
||||
if (uid >= 2)
|
||||
return dev_err_probe(dev, -EINVAL, "incorrect UID/bus id \"%llu\"!\n", uid);
|
||||
dev_dbg(dev, "bus id is %llu\n", uid);
|
||||
|
||||
/* The ACPI namespace doesn't contain information about which MP2 PCI
|
||||
* device an AMDI0011 ACPI device is related to, so assume that there's
|
||||
@ -266,6 +270,7 @@ static int i2c_amd_probe(struct platform_device *pdev)
|
||||
if (!i2c_dev)
|
||||
return -ENOMEM;
|
||||
|
||||
i2c_dev->common.bus_id = uid;
|
||||
i2c_dev->common.mp2_dev = mp2_dev;
|
||||
i2c_dev->pdev = pdev;
|
||||
platform_set_drvdata(pdev, i2c_dev);
|
||||
@ -276,20 +281,6 @@ static int i2c_amd_probe(struct platform_device *pdev)
|
||||
i2c_dev->common.resume = &i2c_amd_resume;
|
||||
#endif
|
||||
|
||||
uid = adev->pnp.unique_id;
|
||||
if (!uid) {
|
||||
dev_err(&pdev->dev, "missing UID/bus id!\n");
|
||||
return -EINVAL;
|
||||
} else if (strcmp(uid, "0") == 0) {
|
||||
i2c_dev->common.bus_id = 0;
|
||||
} else if (strcmp(uid, "1") == 0) {
|
||||
i2c_dev->common.bus_id = 1;
|
||||
} else {
|
||||
dev_err(&pdev->dev, "incorrect UID/bus id \"%s\"!\n", uid);
|
||||
return -EINVAL;
|
||||
}
|
||||
dev_dbg(&pdev->dev, "bus id is %u\n", i2c_dev->common.bus_id);
|
||||
|
||||
/* Register the adapter */
|
||||
amd_mp2_pm_runtime_get(mp2_dev);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user