lkml.org 
[lkml]   [2020]   [Jan]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    From
    Date
    SubjectRe: [PATCH 2/4] alarmtimer: Make alarmtimer platform device child of RTC device
    Hi,

    On Thu, Jan 9, 2020 at 7:59 AM Stephen Boyd <swboyd@chromium.org> wrote:
    >
    > The alarmtimer_suspend() function will fail if an RTC device is on a bus
    > such as SPI or i2c and that RTC device registers and probes after
    > alarmtimer_init() registers and probes the 'alarmtimer' platform device.
    > This is because system wide suspend suspends devices in the reverse
    > order of their probe. When alarmtimer_suspend() attempts to program the
    > RTC for a wakeup it will try to program an RTC device on a bus that has
    > already been suspended.
    >
    > Let's move the alarmtimer device registration to be when the RTC we use
    > for wakeup is registered. Register the 'alarmtimer' platform device as a
    > child of the RTC device too, so that we can be guaranteed that the RTC
    > device won't be suspended when alarmtimer_suspend() is called.
    >
    > Reported-by: Douglas Anderson <dianders@chromium.org>
    > Signed-off-by: Stephen Boyd <swboyd@chromium.org>
    > ---
    > kernel/time/alarmtimer.c | 15 +++++----------
    > 1 file changed, 5 insertions(+), 10 deletions(-)
    >
    > diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c
    > index 4b11f0309eee..ccb6aea4f1d4 100644
    > --- a/kernel/time/alarmtimer.c
    > +++ b/kernel/time/alarmtimer.c
    > @@ -88,6 +88,7 @@ static int alarmtimer_rtc_add_device(struct device *dev,
    > unsigned long flags;
    > struct rtc_device *rtc = to_rtc_device(dev);
    > struct wakeup_source *__ws;
    > + struct platform_device *pdev;
    > int ret = 0;
    >
    > if (rtcdev)
    > @@ -99,6 +100,7 @@ static int alarmtimer_rtc_add_device(struct device *dev,
    > return -1;
    >
    > __ws = wakeup_source_register(dev, "alarmtimer");
    > + pdev = platform_device_register_data(dev, "alarmtimer", -1, NULL, 0);

    Don't you need to check for an error here? If pdev is an error you'll
    continue on your merry way. Before your patch if you got an error
    registering the device it would have caused probe to fail.

    I guess you'd only want it to be an error if "rtcdev" is NULL?

    Otherwise (though I'm no expert on this code), it looks sane to me.


    -Doug

    \
     
     \ /
      Last update: 2020-01-15 04:41    [W:6.252 / U:0.080 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site