[PATCH 18/27] x86: Simplify acpi_device_infer_name()

Simon Glass sjg at chromium.org
Mon Nov 30 02:53:53 CET 2020


There is no-longer any need to check if sequence numbers are valid, since
this is ensured by driver model. Drop the unwanted logic.

Signed-off-by: Simon Glass <sjg at chromium.org>
---

 lib/acpi/acpi_device.c | 27 +++------------------------
 test/dm/acpi.c         |  6 +-----
 2 files changed, 4 insertions(+), 29 deletions(-)

diff --git a/lib/acpi/acpi_device.c b/lib/acpi/acpi_device.c
index c3439a59883..ba0e6bf9ea8 100644
--- a/lib/acpi/acpi_device.c
+++ b/lib/acpi/acpi_device.c
@@ -784,16 +784,6 @@ static const char *acpi_name_from_id(enum uclass_id id)
 	}
 }
 
-static int acpi_check_seq(const struct udevice *dev)
-{
-	if (dev->req_seq == -1) {
-		log_warning("Device '%s' has no seq\n", dev->name);
-		return log_msg_ret("no seq", -ENXIO);
-	}
-
-	return dev->req_seq;
-}
-
 /* If you change this function, add test cases to dm_test_acpi_get_name() */
 int acpi_device_infer_name(const struct udevice *dev, char *out_name)
 {
@@ -826,29 +816,18 @@ int acpi_device_infer_name(const struct udevice *dev, char *out_name)
 		}
 	}
 	if (!name) {
-		int num;
-
 		switch (id) {
 		/* DSDT: acpi/lpss.asl */
 		case UCLASS_SERIAL:
-			num = acpi_check_seq(dev);
-			if (num < 0)
-				return num;
-			sprintf(out_name, "URT%d", num);
+			sprintf(out_name, "URT%d", dev_seq(dev));
 			name = out_name;
 			break;
 		case UCLASS_I2C:
-			num = acpi_check_seq(dev);
-			if (num < 0)
-				return num;
-			sprintf(out_name, "I2C%d", num);
+			sprintf(out_name, "I2C%d", dev_seq(dev));
 			name = out_name;
 			break;
 		case UCLASS_SPI:
-			num = acpi_check_seq(dev);
-			if (num < 0)
-				return num;
-			sprintf(out_name, "SPI%d", num);
+			sprintf(out_name, "SPI%d", dev_seq(dev));
 			name = out_name;
 			break;
 		default:
diff --git a/test/dm/acpi.c b/test/dm/acpi.c
index f5eddac10d0..021f776845e 100644
--- a/test/dm/acpi.c
+++ b/test/dm/acpi.c
@@ -123,7 +123,7 @@ UCLASS_DRIVER(testacpi) = {
 static int dm_test_acpi_get_name(struct unit_test_state *uts)
 {
 	char name[ACPI_NAME_MAX];
-	struct udevice *dev, *dev2, *i2c, *spi, *serial, *timer, *sound;
+	struct udevice *dev, *dev2, *i2c, *spi, *timer, *sound;
 	struct udevice *pci, *root;
 
 	/* Test getting the name from the driver */
@@ -146,10 +146,6 @@ static int dm_test_acpi_get_name(struct unit_test_state *uts)
 	ut_assertok(acpi_get_name(spi, name));
 	ut_asserteq_str("SPI0", name);
 
-	/* The uart has no sequence number, so this should fail */
-	ut_assertok(uclass_first_device(UCLASS_SERIAL, &serial));
-	ut_asserteq(-ENXIO, acpi_get_name(serial, name));
-
 	/* ACPI doesn't know about the timer */
 	ut_assertok(uclass_first_device(UCLASS_TIMER, &timer));
 	ut_asserteq(-ENOENT, acpi_get_name(timer, name));
-- 
2.29.2.454.gaff20da3a2-goog



More information about the U-Boot mailing list