summaryrefslogtreecommitdiffstats
path: root/common/poller.c
Commit message (Collapse)AuthorAgeFilesLines
* common: move workqueue handling from poller_call() to sched()Ahmad Fatoum2021-06-251-15/+8
| | | | | | | | | | | | | | | Workqueues are run out of poller_call, not because of a dependency, but because when they were added, poller_call was directly called from is_timeout. With the addition of bthreads, there is now a general resched() function that runs pollers and switches between bthreads. It makes sense to move workqueue handling there as well to keep scheduling matter contained in a single function. Do so. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20210622082617.18011-4-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* common: replace license statements with SPDX-License-IdentifiersAhmad Fatoum2020-11-271-3/+1
| | | | | | | | | | | | | For all files in common/ that already have a license text: - Replace with appropriate SPDX-License-Identifier - Remove empty comment lines around replacement - remove comment completely if only thing remaining is name of file without description Reviewed-by: Roland Hieber <rhi@pengutronix.de> Reviewed-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fs: Warn when filesystem operations are called from a pollerSascha Hauer2020-08-191-1/+1
| | | | | | | | | Filesystem operations possibly call into arbitrary devices, so shouldn't be used from a poller. This patch sprinkles some WARN_ONCE() when this happens. One exception is when the file which is accessed is on ramfs which doesn't have any dependencies to devices. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Add workqueuesSascha Hauer2020-08-131-0/+9
| | | | | | | | | | | | | | | | | | | Some code wants to run arbitrary code in the background, examples are fastboot and ratp. Currently this is implemented in pollers. The problem with this is that pollers are executed whenever is_timeout() is called which may happen anywhere in the code. With this we can never tell which resources are currently in use when the poller is executed. This adds a work queue interface which is specifically designed to trigger doing work in a context where it's safe to run arbitrary commands. Code in pollers can attach work to a work queue which is at that time only queued up. A new slice, the command slice, is added which by default is acquired. It is only released at places where the shell waits for input. When during this time pollers are executed the queued up works are done before running the registered pollers. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* poller: Add a poller commandSascha Hauer2020-05-201-0/+71
| | | | | | | The poller command allows to print which pollers are registered and also how many times we can run the registered pollers in one second. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* poller: Give pollers a nameSascha Hauer2020-05-201-3/+5
| | | | | | It helps debugging when pollers have a name, so give them one. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* poller: Fix async pollerSascha Hauer2016-01-131-4/+22
| | | | | | | | | | | | | | | The async poller does not work as expected since it can happen that the async poller is removed from the list of pollers while we are iterating over the list. Even list_for_each_entry_safe does not help here since we may remove the next list element, but list_for_each_entry_safe only allows to remove the current list element. Rework the async poller so that it is registered with the poller framework on registration and then is only marked as active with poller_call_async(). This way we do not have to do list manipulations while running the pollers. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* poller: Allow to call functions asynchronouslySascha Hauer2013-12-181-0/+58
| | | | | | | | | Sometimes execution of a function has to be delayed, for example when a backlight can only be turned on when the picture has stabilized. To help in such situations add a convenience function around the poller stuff to call a function after a delay. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Add generic poll infrastructureMarc Kleine-Budde2010-12-201-0/+45
Barebox does not have interrupt functionality. Nevertheless it's sometimes useful to periodically call functions, like for example a heartbeat LED or watchdog reset. Instead of cluttering the code with calls to these functions this patch adds a generic polling infrastructure. Code which might run for longer now can call poller_call() periodically which in turn will call all registered pollers. This patch adds a call to poller_call in two generic pathes. First of them is getc() which covers waiting for uart input. Second is ctrlc() which should be called anyway from code which might run for longer. So instead adding poller_call directly to your code, consider checking ctrlc instead which also gives additional convenience to the user. The poller code is safe against reentrancy which means that it's safe to call poller_call inside a poller. Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>