From d1494a2d8c65546861ffa3b61e409a8f44317ea1 Mon Sep 17 00:00:00 2001 From: Juhyung Park Date: Tue, 28 May 2024 12:00:06 +0900 Subject: [PATCH] media: i2c: ov02c10/ov2740: add a debug print for module name This should come in handy when debugging module-specific issues. Signed-off-by: Juhyung Park Signed-off-by: Hao Yao --- drivers/media/i2c/ov02c10.c | 15 ++++++++------- drivers/media/i2c/ov2740.c | 1 + 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/drivers/media/i2c/ov02c10.c b/drivers/media/i2c/ov02c10.c index 7c794b6814d1..40865f8e3d98 100644 --- a/drivers/media/i2c/ov02c10.c +++ b/drivers/media/i2c/ov02c10.c @@ -1597,9 +1597,9 @@ static int ov02c10_read_module_name(struct ov02c10 *ov02c10) { struct i2c_client *client = v4l2_get_subdevdata(&ov02c10->sd); struct device *dev = &client->dev; - int i = 0; union acpi_object *obj; struct acpi_device *adev = ACPI_COMPANION(dev); + int i; ov02c10->module_name_index = 0; if (!adev) @@ -1608,13 +1608,14 @@ static int ov02c10_read_module_name(struct ov02c10 *ov02c10) obj = acpi_evaluate_dsm_typed(adev->handle, &cio2_sensor_module_guid, 0x00, 0x01, NULL, ACPI_TYPE_STRING); + if (!obj) + return 0; - if (obj && obj->string.type == ACPI_TYPE_STRING) { - for (i = 1; i < ARRAY_SIZE(ov02c10_module_names); i++) { - if (!strcmp(ov02c10_module_names[i], obj->string.pointer)) { - ov02c10->module_name_index = i; - break; - } + dev_dbg(dev, "module name: %s", obj->string.pointer); + for (i = 1; i < ARRAY_SIZE(ov02c10_module_names); i++) { + if (!strcmp(ov02c10_module_names[i], obj->string.pointer)) { + ov02c10->module_name_index = i; + break; } } ACPI_FREE(obj); diff --git a/drivers/media/i2c/ov2740.c b/drivers/media/i2c/ov2740.c index 2b2fbf2d98e0..c5ae1ad0c968 100644 --- a/drivers/media/i2c/ov2740.c +++ b/drivers/media/i2c/ov2740.c @@ -1467,6 +1467,7 @@ static int ov2740_read_module_name(struct ov2740 *ov2740) 0x01, NULL, ACPI_TYPE_STRING); if (obj && obj->string.type == ACPI_TYPE_STRING) { + dev_dbg(dev, "module name: %s", obj->string.pointer); for (i = 1; i < ARRAY_SIZE(ov2740_module_names); i++) { if (!strcmp(ov2740_module_names[i], obj->string.pointer)) { ov2740->module_name_index = i;