diff mbox series

[2/2] platform/x86: int3472: discrete: Log a warning if the pin-numbers don't match

Message ID 20230613110810.240193-2-hdegoede@redhat.com (mailing list archive)
State New, archived
Headers show
Series [1/2] platform/x86: int3472: discrete: Use FIELD_GET() on the GPIO _DSM return value | expand

Commit Message

Hans de Goede June 13, 2023, 11:08 a.m. UTC
The INT3472 discrete code assumes that the ACPI GPIO resources are
in the same order as the pin-info _DSM entries.

The returned pin-info includes the pin-number in bits 15-8. Add a check
that this matches with the ACPI GPIO resource pin-number in case
the assumption is not true with some ACPI tables.

Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 drivers/platform/x86/intel/int3472/discrete.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

Comments

Ilpo Järvinen June 13, 2023, 11:17 a.m. UTC | #1
On Tue, 13 Jun 2023, Hans de Goede wrote:

> The INT3472 discrete code assumes that the ACPI GPIO resources are
> in the same order as the pin-info _DSM entries.
> 
> The returned pin-info includes the pin-number in bits 15-8. Add a check
> that this matches with the ACPI GPIO resource pin-number in case
> the assumption is not true with some ACPI tables.
> 
> Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com>
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
> ---
>  drivers/platform/x86/intel/int3472/discrete.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/platform/x86/intel/int3472/discrete.c b/drivers/platform/x86/intel/int3472/discrete.c
> index a31964076883..850f306214c7 100644
> --- a/drivers/platform/x86/intel/int3472/discrete.c
> +++ b/drivers/platform/x86/intel/int3472/discrete.c
> @@ -154,8 +154,8 @@ static int skl_int3472_handle_gpio_resources(struct acpi_resource *ares,
>  {
>  	struct int3472_discrete_device *int3472 = data;
>  	struct acpi_resource_gpio *agpio;
> +	u8 active_value, pin, type;
>  	union acpi_object *obj;
> -	u8 active_value, type;
>  	const char *err_msg;
>  	const char *func;
>  	u32 polarity;
> @@ -183,6 +183,12 @@ static int skl_int3472_handle_gpio_resources(struct acpi_resource *ares,
>  
>  	int3472_get_func_and_polarity(type, &func, &polarity);
>  
> +	pin = FIELD_GET(INT3472_GPIO_DSM_PIN, obj->integer.value);
> +	if (pin != agpio->pin_table[0])
> +		dev_warn(int3472->dev, "%s %s pin number mismatch _DSM %d resource %d\n",
> +			 func, agpio->resource_source.string_ptr, pin,
> +			 agpio->pin_table[0]);
> +
>  	active_value = FIELD_GET(INT3472_GPIO_DSM_SENSOR_ON_VAL, obj->integer.value);
>  	if (!active_value)
>  		polarity ^= GPIO_ACTIVE_LOW;

For both 1 and 2,

Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>


--
 i.
Hans de Goede June 15, 2023, 12:38 p.m. UTC | #2
Hi,

On 6/13/23 13:17, Ilpo Järvinen wrote:
> On Tue, 13 Jun 2023, Hans de Goede wrote:
> 
>> The INT3472 discrete code assumes that the ACPI GPIO resources are
>> in the same order as the pin-info _DSM entries.
>>
>> The returned pin-info includes the pin-number in bits 15-8. Add a check
>> that this matches with the ACPI GPIO resource pin-number in case
>> the assumption is not true with some ACPI tables.
>>
>> Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com>
>> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
>> ---
>>  drivers/platform/x86/intel/int3472/discrete.c | 8 +++++++-
>>  1 file changed, 7 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/platform/x86/intel/int3472/discrete.c b/drivers/platform/x86/intel/int3472/discrete.c
>> index a31964076883..850f306214c7 100644
>> --- a/drivers/platform/x86/intel/int3472/discrete.c
>> +++ b/drivers/platform/x86/intel/int3472/discrete.c
>> @@ -154,8 +154,8 @@ static int skl_int3472_handle_gpio_resources(struct acpi_resource *ares,
>>  {
>>  	struct int3472_discrete_device *int3472 = data;
>>  	struct acpi_resource_gpio *agpio;
>> +	u8 active_value, pin, type;
>>  	union acpi_object *obj;
>> -	u8 active_value, type;
>>  	const char *err_msg;
>>  	const char *func;
>>  	u32 polarity;
>> @@ -183,6 +183,12 @@ static int skl_int3472_handle_gpio_resources(struct acpi_resource *ares,
>>  
>>  	int3472_get_func_and_polarity(type, &func, &polarity);
>>  
>> +	pin = FIELD_GET(INT3472_GPIO_DSM_PIN, obj->integer.value);
>> +	if (pin != agpio->pin_table[0])
>> +		dev_warn(int3472->dev, "%s %s pin number mismatch _DSM %d resource %d\n",
>> +			 func, agpio->resource_source.string_ptr, pin,
>> +			 agpio->pin_table[0]);
>> +
>>  	active_value = FIELD_GET(INT3472_GPIO_DSM_SENSOR_ON_VAL, obj->integer.value);
>>  	if (!active_value)
>>  		polarity ^= GPIO_ACTIVE_LOW;
> 
> For both 1 and 2,
> 
> Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>

Thank you.

I've added this to my review-hans (soon to be for-next) branch now.

Regards,

Hans
diff mbox series

Patch

diff --git a/drivers/platform/x86/intel/int3472/discrete.c b/drivers/platform/x86/intel/int3472/discrete.c
index a31964076883..850f306214c7 100644
--- a/drivers/platform/x86/intel/int3472/discrete.c
+++ b/drivers/platform/x86/intel/int3472/discrete.c
@@ -154,8 +154,8 @@  static int skl_int3472_handle_gpio_resources(struct acpi_resource *ares,
 {
 	struct int3472_discrete_device *int3472 = data;
 	struct acpi_resource_gpio *agpio;
+	u8 active_value, pin, type;
 	union acpi_object *obj;
-	u8 active_value, type;
 	const char *err_msg;
 	const char *func;
 	u32 polarity;
@@ -183,6 +183,12 @@  static int skl_int3472_handle_gpio_resources(struct acpi_resource *ares,
 
 	int3472_get_func_and_polarity(type, &func, &polarity);
 
+	pin = FIELD_GET(INT3472_GPIO_DSM_PIN, obj->integer.value);
+	if (pin != agpio->pin_table[0])
+		dev_warn(int3472->dev, "%s %s pin number mismatch _DSM %d resource %d\n",
+			 func, agpio->resource_source.string_ptr, pin,
+			 agpio->pin_table[0]);
+
 	active_value = FIELD_GET(INT3472_GPIO_DSM_SENSOR_ON_VAL, obj->integer.value);
 	if (!active_value)
 		polarity ^= GPIO_ACTIVE_LOW;