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

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

 



Hi,

On 6/13/23 10:10, Ilpo Järvinen wrote:
> On Mon, 12 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.
>>
>> Signed-off-by: Hans de Goede <hdegoede@xxxxxxxxxx>
>> ---
>>  drivers/platform/x86/intel/int3472/discrete.c | 10 +++++++++-
>>  1 file changed, 9 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/platform/x86/intel/int3472/discrete.c b/drivers/platform/x86/intel/int3472/discrete.c
>> index 4ef60883154d..c1132bbbff41 100644
>> --- a/drivers/platform/x86/intel/int3472/discrete.c
>> +++ b/drivers/platform/x86/intel/int3472/discrete.c
>> @@ -149,8 +149,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;
>> @@ -174,10 +174,18 @@ static int skl_int3472_handle_gpio_resources(struct acpi_resource *ares,
>>  		return 1;
>>  	}
>>  
>> +	/* Bits 7-0 contain the type/function of the pin */
>>  	type = obj->integer.value & 0xff;
>>  
>>  	int3472_get_func_and_polarity(type, &func, &polarity);
>>  
>> +	/* Bits 15-8 contain the pin-number on the GPIO chip */
>> +	pin = (obj->integer.value >> 8) & 0xff;
>> +	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]);
>> +
>>  	/* If bits 31-24 of the _DSM entry are all 0 then the signal is inverted */
>>  	active_value = (obj->integer.value >> 24) & 0xff;
>>  	if (!active_value)
>>
> 
> These changes made me wonder why there aren't defines for the fields? 
> And then FIELD_GET() used to read the field. Most of those comments 
> would be documented by the define name itself.

That is a good idea for v2 I'll add a new 1/2 adding defines + switching
the existing cases to FIELD_GET() and I'll also switch to FIELD_GET()
here for v2.

Regards,

Hans







[Index of Archives]     [Linux Input]     [Video for Linux]     [Gstreamer Embedded]     [Mplayer Users]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux