diff options
author | Viresh Kumar <viresh.kumar@linaro.org> | 2015-07-07 04:14:35 -0400 |
---|---|---|
committer | Thomas Gleixner <tglx@linutronix.de> | 2015-07-07 04:44:45 -0400 |
commit | 7c4a976cd55972b68c75a978f171b6db5df4ce66 (patch) | |
tree | 269c05a4c91fefe5f1e5d10fd21940169c41f9de | |
parent | 747d34e7313034768aac83d679db43cedc5ab778 (diff) |
clockevents: Allow set-state callbacks to be optional
Its mandatory for the drivers to provide set_state_{oneshot|periodic}()
(only if related modes are supported) and set_state_shutdown() callbacks
today, if they are implementing the new set-state interface.
But this leads to unnecessary noop callbacks for drivers which don't
want to implement them. Over that, it will lead to a full function call
for nothing really useful.
Lets make all set-state callbacks optional.
Suggested-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Link: http://lkml.kernel.org/r/1436256875-15562-1-git-send-email-daniel.lezcano@linaro.org
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
-rw-r--r-- | kernel/time/clockevents.c | 24 |
1 files changed, 9 insertions, 15 deletions
diff --git a/kernel/time/clockevents.c b/kernel/time/clockevents.c index 08ccc3da3ca0..50eb107f1198 100644 --- a/kernel/time/clockevents.c +++ b/kernel/time/clockevents.c | |||
@@ -120,19 +120,25 @@ static int __clockevents_switch_state(struct clock_event_device *dev, | |||
120 | /* The clockevent device is getting replaced. Shut it down. */ | 120 | /* The clockevent device is getting replaced. Shut it down. */ |
121 | 121 | ||
122 | case CLOCK_EVT_STATE_SHUTDOWN: | 122 | case CLOCK_EVT_STATE_SHUTDOWN: |
123 | return dev->set_state_shutdown(dev); | 123 | if (dev->set_state_shutdown) |
124 | return dev->set_state_shutdown(dev); | ||
125 | return 0; | ||
124 | 126 | ||
125 | case CLOCK_EVT_STATE_PERIODIC: | 127 | case CLOCK_EVT_STATE_PERIODIC: |
126 | /* Core internal bug */ | 128 | /* Core internal bug */ |
127 | if (!(dev->features & CLOCK_EVT_FEAT_PERIODIC)) | 129 | if (!(dev->features & CLOCK_EVT_FEAT_PERIODIC)) |
128 | return -ENOSYS; | 130 | return -ENOSYS; |
129 | return dev->set_state_periodic(dev); | 131 | if (dev->set_state_periodic) |
132 | return dev->set_state_periodic(dev); | ||
133 | return 0; | ||
130 | 134 | ||
131 | case CLOCK_EVT_STATE_ONESHOT: | 135 | case CLOCK_EVT_STATE_ONESHOT: |
132 | /* Core internal bug */ | 136 | /* Core internal bug */ |
133 | if (!(dev->features & CLOCK_EVT_FEAT_ONESHOT)) | 137 | if (!(dev->features & CLOCK_EVT_FEAT_ONESHOT)) |
134 | return -ENOSYS; | 138 | return -ENOSYS; |
135 | return dev->set_state_oneshot(dev); | 139 | if (dev->set_state_oneshot) |
140 | return dev->set_state_oneshot(dev); | ||
141 | return 0; | ||
136 | 142 | ||
137 | case CLOCK_EVT_STATE_ONESHOT_STOPPED: | 143 | case CLOCK_EVT_STATE_ONESHOT_STOPPED: |
138 | /* Core internal bug */ | 144 | /* Core internal bug */ |
@@ -471,18 +477,6 @@ static int clockevents_sanity_check(struct clock_event_device *dev) | |||
471 | if (dev->features & CLOCK_EVT_FEAT_DUMMY) | 477 | if (dev->features & CLOCK_EVT_FEAT_DUMMY) |
472 | return 0; | 478 | return 0; |
473 | 479 | ||
474 | /* New state-specific callbacks */ | ||
475 | if (!dev->set_state_shutdown) | ||
476 | return -EINVAL; | ||
477 | |||
478 | if ((dev->features & CLOCK_EVT_FEAT_PERIODIC) && | ||
479 | !dev->set_state_periodic) | ||
480 | return -EINVAL; | ||
481 | |||
482 | if ((dev->features & CLOCK_EVT_FEAT_ONESHOT) && | ||
483 | !dev->set_state_oneshot) | ||
484 | return -EINVAL; | ||
485 | |||
486 | return 0; | 480 | return 0; |
487 | } | 481 | } |
488 | 482 | ||