lkml.org 
[lkml]   [2020]   [Jan]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH 4.19 309/639] hwmon: (w83627hf) Use request_muxed_region for Super-IO accesses
From
Date
On 1/25/20 10:59 AM, Pavel Machek wrote:
> Hi!
>> [ Upstream commit e95fd518d05bfc087da6fcdea4900a57cfb083bd ]
>>
>> Super-IO accesses may fail on a system with no or unmapped LPC bus.
>>
>> Also, other drivers may attempt to access the LPC bus at the same time,
>> resulting in undefined behavior.
>>
>> Use request_muxed_region() to ensure that IO access on the requested
>> address space is supported, and to ensure that access by multiple drivers
>> is synchronized.
>>
>
>> @@ -1644,9 +1654,21 @@ static int w83627thf_read_gpio5(struct platform_device *pdev)
>> struct w83627hf_sio_data *sio_data = dev_get_platdata(&pdev->dev);
>> int res = 0xff, sel;
>>
>> - superio_enter(sio_data);
>> + if (superio_enter(sio_data)) {
>> + /*
>> + * Some other driver reserved the address space for itself.
>> + * We don't want to fail driver instantiation because of that,
>> + * so display a warning and keep going.
>> + */
>> + dev_warn(&pdev->dev,
>> + "Can not read VID data: Failed to enable SuperIO access\n");
>> + return res;
>> + }
>> +
>> superio_select(sio_data, W83627HF_LD_GPIO5);
>>
>> + res = 0xff;
>> +
>
> This is strange. res is not actually assigned in the code above, so we
> have res = 0xff twice. Can we remove one of the initializations and do
> 'return 0xff' directly to make code more clear?
>
>
>> @@ -1677,7 +1699,17 @@ static int w83687thf_read_vid(struct platform_device *pdev)
>> struct w83627hf_sio_data *sio_data = dev_get_platdata(&pdev->dev);
>> int res = 0xff;
>>
>> - superio_enter(sio_data);
>> + if (superio_enter(sio_data)) {
>> + /*
>> + * Some other driver reserved the address space for itself.
>> + * We don't want to fail driver instantiation because of that,
>> + * so display a warning and keep going.
>> + */
>> + dev_warn(&pdev->dev,
>> + "Can not read VID data: Failed to enable SuperIO access\n");
>> + return res;
>> + }
>
> Direct "return 0xff" would make more sense here, too.
>

Please feel free to submit a patch to improve the upstream code.

Thanks,
Guenter

\
 
 \ /
  Last update: 2020-01-25 20:16    [W:0.304 / U:0.032 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site