linux: Convert timer/workqueue stubs to static inline functions

Convert most of the stub macros in timer.h and workqueue.h to static
inline functions for better type checking. Keep macros for functions
that take callback pointers (setup_timer, timer_setup, INIT_WORK,
INIT_DELAYED_WORK, del_timer_sync) since some callers pass functions
that are conditionally compiled out.

Fixes: 3b4667ed88 ("ext4l: Add super.c to build")

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Simon Glass
2025-12-20 15:48:28 -07:00
parent e43b787bec
commit b074a781fc
2 changed files with 95 additions and 23 deletions

View File

@@ -15,14 +15,36 @@ struct timer_list {
#define DEFINE_TIMER(name, func) \
struct timer_list name = { .function = func }
#define setup_timer(timer, func, data) do { (void)(func); } while (0)
#define timer_setup(timer, func, flags) do { (void)(func); } while (0)
#define init_timer(timer) do { } while (0)
#define add_timer(timer) do { } while (0)
#define del_timer(timer) ({ (void)(timer); 0; })
#define del_timer_sync(timer) do { (void)(timer); } while (0)
#define mod_timer(timer, expires) do { (void)(timer); (void)(expires); } while (0)
#define timer_pending(timer) ({ (void)(timer); 0; })
/* Use macros for functions taking callback pointers to avoid requiring
* the callback to be declared (some callers have them in #ifdef blocks)
*/
#define setup_timer(timer, func, data) do { } while (0)
#define timer_setup(timer, func, flags) do { } while (0)
static inline void init_timer(struct timer_list *timer)
{
}
static inline void add_timer(struct timer_list *timer)
{
}
static inline int del_timer(struct timer_list *timer)
{
return 0;
}
#define del_timer_sync(timer) do { } while (0)
static inline int mod_timer(struct timer_list *timer, unsigned long expires)
{
return 0;
}
static inline int timer_pending(struct timer_list *timer)
{
return 0;
}
#define from_timer(var, callback_timer, timer_fieldname) \
container_of(callback_timer, typeof(*var), timer_fieldname)
@@ -30,7 +52,12 @@ struct timer_list {
#define timer_container_of(var, callback_timer, timer_fieldname) \
container_of(callback_timer, typeof(*var), timer_fieldname)
#define timer_shutdown_sync(timer) do { } while (0)
#define timer_delete_sync(timer) do { (void)(timer); } while (0)
static inline void timer_shutdown_sync(struct timer_list *timer)
{
}
static inline void timer_delete_sync(struct timer_list *timer)
{
}
#endif /* _LINUX_TIMER_H */

View File

@@ -16,22 +16,67 @@ struct delayed_work {
struct work_struct work;
};
#define INIT_WORK(work, func) do { (void)(func); } while (0)
#define INIT_DELAYED_WORK(work, func) do { (void)(func); } while (0)
#define schedule_work(work) do { } while (0)
#define schedule_delayed_work(work, delay) 0
#define cancel_work_sync(work) 0
#define cancel_delayed_work(work) 0
#define cancel_delayed_work_sync(work) 0
#define flush_work(work) ({ (void)(work); 0; })
#define flush_delayed_work(work) 0
#define queue_work(wq, work) 0
#define queue_delayed_work(wq, work, delay) 0
struct workqueue_struct;
/* Use macros for functions taking callback pointers to avoid requiring
* the callback to be declared (some callers have them in #ifdef blocks)
*/
#define INIT_WORK(work, func) do { } while (0)
#define INIT_DELAYED_WORK(work, func) do { } while (0)
static inline void schedule_work(struct work_struct *work)
{
}
static inline int schedule_delayed_work(struct delayed_work *work,
unsigned long delay)
{
return 0;
}
static inline int cancel_work_sync(struct work_struct *work)
{
return 0;
}
static inline int cancel_delayed_work(struct delayed_work *work)
{
return 0;
}
static inline int cancel_delayed_work_sync(struct delayed_work *work)
{
return 0;
}
static inline int flush_work(struct work_struct *work)
{
return 0;
}
static inline int flush_delayed_work(struct delayed_work *work)
{
return 0;
}
static inline int queue_work(struct workqueue_struct *wq,
struct work_struct *work)
{
return 0;
}
static inline int queue_delayed_work(struct workqueue_struct *wq,
struct delayed_work *work,
unsigned long delay)
{
return 0;
}
#define alloc_workqueue(fmt, flags, max, ...) ((struct workqueue_struct *)1)
#define create_singlethread_workqueue(name) ((struct workqueue_struct *)1)
#define destroy_workqueue(wq) do { } while (0)
struct workqueue_struct;
static inline void destroy_workqueue(struct workqueue_struct *wq)
{
}
#endif /* _LINUX_WORKQUEUE_H */