lkml.org 
[lkml]   [2020]   [Jan]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: [PATCH 4.19 309/639] hwmon: (w83627hf) Use request_muxed_region for Super-IO accesses
    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.

    Best regards,
    Pavel
    --
    (english) http://www.livejournal.com/~pavelmachek
    (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
    [unhandled content-type:application/pgp-signature]
    \
     
     \ /
      Last update: 2020-01-25 20:00    [W:4.051 / U:0.008 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site