Re: [PATCH 1/5] i2c: core: Pick i2c bus number from ACPI if present

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2022/9/22 下午7:39, Binbin Zhou wrote:

Under LoongARCH based on ACPI(such as Loongson-3A + LS7A), the ls2x i2c
driver obtains the i2c bus number from ACPI table.

Similar to the DT-base system, this is also a static bus number.

Signed-off-by: Huacai Chen <chenhuacai@xxxxxxxxxxx>
Signed-off-by: Binbin Zhou <zhoubinbin@xxxxxxxxxxx>
---
  drivers/i2c/i2c-core-base.c | 10 +++++++++-
  1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c
index 91007558bcb2..ffab4cc2c6ba 100644
--- a/drivers/i2c/i2c-core-base.c
+++ b/drivers/i2c/i2c-core-base.c
@@ -1559,7 +1559,8 @@ static int __i2c_add_numbered_adapter(struct i2c_adapter *adap)
  int i2c_add_adapter(struct i2c_adapter *adapter)
  {
  	struct device *dev = &adapter->dev;
-	int id;
+	acpi_status status;
+	unsigned long long id;
if (dev->of_node) {
  		id = of_alias_get_id(dev->of_node, "i2c");
@@ -1567,6 +1568,13 @@ int i2c_add_adapter(struct i2c_adapter *adapter)
  			adapter->nr = id;
  			return __i2c_add_numbered_adapter(adapter);
  		}
+	} else if (dev->parent->fwnode) {
+		status = acpi_evaluate_integer(ACPI_HANDLE(dev->parent),
+						"_UID", NULL, &id);
+		if (ACPI_SUCCESS(status) && (id >= 0)) {

Hi, Binbin,


Emm, the id is unsigned and it always return true if (id>=0). And I think

you should check the other patches.


Jinyang


+			adapter->nr = id;
+			return __i2c_add_numbered_adapter(adapter);
+		}
  	}
mutex_lock(&core_lock);




[Index of Archives]     [Linux IBM ACPI]     [Linux Power Management]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]     [Linux Resources]

  Powered by Linux