diff options
author | Petr Mladek <pmladek@suse.com> | 2016-10-11 13:55:20 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2016-10-11 15:06:33 -0700 |
commit | 3989144f863ac576e6efba298d24b0b02a10d4bb (patch) | |
tree | d9892a66501c0ab30d583ac5e1f609d66d842156 /drivers/tty | |
parent | e700591ae03896c16974d4e1ab58eb296aaa5f59 (diff) | |
download | lwn-3989144f863ac576e6efba298d24b0b02a10d4bb.tar.gz lwn-3989144f863ac576e6efba298d24b0b02a10d4bb.zip |
kthread: kthread worker API cleanup
A good practice is to prefix the names of functions by the name
of the subsystem.
The kthread worker API is a mix of classic kthreads and workqueues. Each
worker has a dedicated kthread. It runs a generic function that process
queued works. It is implemented as part of the kthread subsystem.
This patch renames the existing kthread worker API to use
the corresponding name from the workqueues API prefixed by
kthread_:
__init_kthread_worker() -> __kthread_init_worker()
init_kthread_worker() -> kthread_init_worker()
init_kthread_work() -> kthread_init_work()
insert_kthread_work() -> kthread_insert_work()
queue_kthread_work() -> kthread_queue_work()
flush_kthread_work() -> kthread_flush_work()
flush_kthread_worker() -> kthread_flush_worker()
Note that the names of DEFINE_KTHREAD_WORK*() macros stay
as they are. It is common that the "DEFINE_" prefix has
precedence over the subsystem names.
Note that INIT() macros and init() functions use different
naming scheme. There is no good solution. There are several
reasons for this solution:
+ "init" in the function names stands for the verb "initialize"
aka "initialize worker". While "INIT" in the macro names
stands for the noun "INITIALIZER" aka "worker initializer".
+ INIT() macros are used only in DEFINE() macros
+ init() functions are used close to the other kthread()
functions. It looks much better if all the functions
use the same scheme.
+ There will be also kthread_destroy_worker() that will
be used close to kthread_cancel_work(). It is related
to the init() function. Again it looks better if all
functions use the same naming scheme.
+ there are several precedents for such init() function
names, e.g. amd_iommu_init_device(), free_area_init_node(),
jump_label_init_type(), regmap_init_mmio_clk(),
+ It is not an argument but it was inconsistent even before.
[arnd@arndb.de: fix linux-next merge conflict]
Link: http://lkml.kernel.org/r/20160908135724.1311726-1-arnd@arndb.de
Link: http://lkml.kernel.org/r/1470754545-17632-3-git-send-email-pmladek@suse.com
Suggested-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Petr Mladek <pmladek@suse.com>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Tejun Heo <tj@kernel.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
Cc: Josh Triplett <josh@joshtriplett.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Jiri Kosina <jkosina@suse.cz>
Cc: Borislav Petkov <bp@suse.de>
Cc: Michal Hocko <mhocko@suse.cz>
Cc: Vlastimil Babka <vbabka@suse.cz>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/tty')
-rw-r--r-- | drivers/tty/serial/sc16is7xx.c | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/drivers/tty/serial/sc16is7xx.c b/drivers/tty/serial/sc16is7xx.c index a9d94f7cf683..2675792a8f59 100644 --- a/drivers/tty/serial/sc16is7xx.c +++ b/drivers/tty/serial/sc16is7xx.c @@ -708,7 +708,7 @@ static irqreturn_t sc16is7xx_irq(int irq, void *dev_id) { struct sc16is7xx_port *s = (struct sc16is7xx_port *)dev_id; - queue_kthread_work(&s->kworker, &s->irq_work); + kthread_queue_work(&s->kworker, &s->irq_work); return IRQ_HANDLED; } @@ -784,7 +784,7 @@ static void sc16is7xx_ier_clear(struct uart_port *port, u8 bit) one->config.flags |= SC16IS7XX_RECONF_IER; one->config.ier_clear |= bit; - queue_kthread_work(&s->kworker, &one->reg_work); + kthread_queue_work(&s->kworker, &one->reg_work); } static void sc16is7xx_stop_tx(struct uart_port *port) @@ -802,7 +802,7 @@ static void sc16is7xx_start_tx(struct uart_port *port) struct sc16is7xx_port *s = dev_get_drvdata(port->dev); struct sc16is7xx_one *one = to_sc16is7xx_one(port, port); - queue_kthread_work(&s->kworker, &one->tx_work); + kthread_queue_work(&s->kworker, &one->tx_work); } static unsigned int sc16is7xx_tx_empty(struct uart_port *port) @@ -828,7 +828,7 @@ static void sc16is7xx_set_mctrl(struct uart_port *port, unsigned int mctrl) struct sc16is7xx_one *one = to_sc16is7xx_one(port, port); one->config.flags |= SC16IS7XX_RECONF_MD; - queue_kthread_work(&s->kworker, &one->reg_work); + kthread_queue_work(&s->kworker, &one->reg_work); } static void sc16is7xx_break_ctl(struct uart_port *port, int break_state) @@ -957,7 +957,7 @@ static int sc16is7xx_config_rs485(struct uart_port *port, port->rs485 = *rs485; one->config.flags |= SC16IS7XX_RECONF_RS485; - queue_kthread_work(&s->kworker, &one->reg_work); + kthread_queue_work(&s->kworker, &one->reg_work); return 0; } @@ -1030,7 +1030,7 @@ static void sc16is7xx_shutdown(struct uart_port *port) sc16is7xx_power(port, 0); - flush_kthread_worker(&s->kworker); + kthread_flush_worker(&s->kworker); } static const char *sc16is7xx_type(struct uart_port *port) @@ -1176,8 +1176,8 @@ static int sc16is7xx_probe(struct device *dev, s->devtype = devtype; dev_set_drvdata(dev, s); - init_kthread_worker(&s->kworker); - init_kthread_work(&s->irq_work, sc16is7xx_ist); + kthread_init_worker(&s->kworker); + kthread_init_work(&s->irq_work, sc16is7xx_ist); s->kworker_task = kthread_run(kthread_worker_fn, &s->kworker, "sc16is7xx"); if (IS_ERR(s->kworker_task)) { @@ -1234,8 +1234,8 @@ static int sc16is7xx_probe(struct device *dev, SC16IS7XX_EFCR_RXDISABLE_BIT | SC16IS7XX_EFCR_TXDISABLE_BIT); /* Initialize kthread work structs */ - init_kthread_work(&s->p[i].tx_work, sc16is7xx_tx_proc); - init_kthread_work(&s->p[i].reg_work, sc16is7xx_reg_proc); + kthread_init_work(&s->p[i].tx_work, sc16is7xx_tx_proc); + kthread_init_work(&s->p[i].reg_work, sc16is7xx_reg_proc); /* Register port */ uart_add_one_port(&sc16is7xx_uart, &s->p[i].port); @@ -1301,7 +1301,7 @@ static int sc16is7xx_remove(struct device *dev) sc16is7xx_power(&s->p[i].port, 0); } - flush_kthread_worker(&s->kworker); + kthread_flush_worker(&s->kworker); kthread_stop(s->kworker_task); if (!IS_ERR(s->clk)) |