aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/tty
diff options
context:
space:
mode:
authorPetr Mladek <pmladek@suse.com>2016-10-11 16:55:20 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2016-10-11 18:06:33 -0400
commit3989144f863ac576e6efba298d24b0b02a10d4bb (patch)
treed9892a66501c0ab30d583ac5e1f609d66d842156 /drivers/tty
parente700591ae03896c16974d4e1ab58eb296aaa5f59 (diff)
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.c22
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)
708{ 708{
709 struct sc16is7xx_port *s = (struct sc16is7xx_port *)dev_id; 709 struct sc16is7xx_port *s = (struct sc16is7xx_port *)dev_id;
710 710
711 queue_kthread_work(&s->kworker, &s->irq_work); 711 kthread_queue_work(&s->kworker, &s->irq_work);
712 712
713 return IRQ_HANDLED; 713 return IRQ_HANDLED;
714} 714}
@@ -784,7 +784,7 @@ static void sc16is7xx_ier_clear(struct uart_port *port, u8 bit)
784 784
785 one->config.flags |= SC16IS7XX_RECONF_IER; 785 one->config.flags |= SC16IS7XX_RECONF_IER;
786 one->config.ier_clear |= bit; 786 one->config.ier_clear |= bit;
787 queue_kthread_work(&s->kworker, &one->reg_work); 787 kthread_queue_work(&s->kworker, &one->reg_work);
788} 788}
789 789
790static void sc16is7xx_stop_tx(struct uart_port *port) 790static void sc16is7xx_stop_tx(struct uart_port *port)
@@ -802,7 +802,7 @@ static void sc16is7xx_start_tx(struct uart_port *port)
802 struct sc16is7xx_port *s = dev_get_drvdata(port->dev); 802 struct sc16is7xx_port *s = dev_get_drvdata(port->dev);
803 struct sc16is7xx_one *one = to_sc16is7xx_one(port, port); 803 struct sc16is7xx_one *one = to_sc16is7xx_one(port, port);
804 804
805 queue_kthread_work(&s->kworker, &one->tx_work); 805 kthread_queue_work(&s->kworker, &one->tx_work);
806} 806}
807 807
808static unsigned int sc16is7xx_tx_empty(struct uart_port *port) 808static 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)
828 struct sc16is7xx_one *one = to_sc16is7xx_one(port, port); 828 struct sc16is7xx_one *one = to_sc16is7xx_one(port, port);
829 829
830 one->config.flags |= SC16IS7XX_RECONF_MD; 830 one->config.flags |= SC16IS7XX_RECONF_MD;
831 queue_kthread_work(&s->kworker, &one->reg_work); 831 kthread_queue_work(&s->kworker, &one->reg_work);
832} 832}
833 833
834static void sc16is7xx_break_ctl(struct uart_port *port, int break_state) 834static void sc16is7xx_break_ctl(struct uart_port *port, int break_state)
@@ -957,7 +957,7 @@ static int sc16is7xx_config_rs485(struct uart_port *port,
957 957
958 port->rs485 = *rs485; 958 port->rs485 = *rs485;
959 one->config.flags |= SC16IS7XX_RECONF_RS485; 959 one->config.flags |= SC16IS7XX_RECONF_RS485;
960 queue_kthread_work(&s->kworker, &one->reg_work); 960 kthread_queue_work(&s->kworker, &one->reg_work);
961 961
962 return 0; 962 return 0;
963} 963}
@@ -1030,7 +1030,7 @@ static void sc16is7xx_shutdown(struct uart_port *port)
1030 1030
1031 sc16is7xx_power(port, 0); 1031 sc16is7xx_power(port, 0);
1032 1032
1033 flush_kthread_worker(&s->kworker); 1033 kthread_flush_worker(&s->kworker);
1034} 1034}
1035 1035
1036static const char *sc16is7xx_type(struct uart_port *port) 1036static const char *sc16is7xx_type(struct uart_port *port)
@@ -1176,8 +1176,8 @@ static int sc16is7xx_probe(struct device *dev,
1176 s->devtype = devtype; 1176 s->devtype = devtype;
1177 dev_set_drvdata(dev, s); 1177 dev_set_drvdata(dev, s);
1178 1178
1179 init_kthread_worker(&s->kworker); 1179 kthread_init_worker(&s->kworker);
1180 init_kthread_work(&s->irq_work, sc16is7xx_ist); 1180 kthread_init_work(&s->irq_work, sc16is7xx_ist);
1181 s->kworker_task = kthread_run(kthread_worker_fn, &s->kworker, 1181 s->kworker_task = kthread_run(kthread_worker_fn, &s->kworker,
1182 "sc16is7xx"); 1182 "sc16is7xx");
1183 if (IS_ERR(s->kworker_task)) { 1183 if (IS_ERR(s->kworker_task)) {
@@ -1234,8 +1234,8 @@ static int sc16is7xx_probe(struct device *dev,
1234 SC16IS7XX_EFCR_RXDISABLE_BIT | 1234 SC16IS7XX_EFCR_RXDISABLE_BIT |
1235 SC16IS7XX_EFCR_TXDISABLE_BIT); 1235 SC16IS7XX_EFCR_TXDISABLE_BIT);
1236 /* Initialize kthread work structs */ 1236 /* Initialize kthread work structs */
1237 init_kthread_work(&s->p[i].tx_work, sc16is7xx_tx_proc); 1237 kthread_init_work(&s->p[i].tx_work, sc16is7xx_tx_proc);
1238 init_kthread_work(&s->p[i].reg_work, sc16is7xx_reg_proc); 1238 kthread_init_work(&s->p[i].reg_work, sc16is7xx_reg_proc);
1239 /* Register port */ 1239 /* Register port */
1240 uart_add_one_port(&sc16is7xx_uart, &s->p[i].port); 1240 uart_add_one_port(&sc16is7xx_uart, &s->p[i].port);
1241 1241
@@ -1301,7 +1301,7 @@ static int sc16is7xx_remove(struct device *dev)
1301 sc16is7xx_power(&s->p[i].port, 0); 1301 sc16is7xx_power(&s->p[i].port, 0);
1302 } 1302 }
1303 1303
1304 flush_kthread_worker(&s->kworker); 1304 kthread_flush_worker(&s->kworker);
1305 kthread_stop(s->kworker_task); 1305 kthread_stop(s->kworker_task);
1306 1306
1307 if (!IS_ERR(s->clk)) 1307 if (!IS_ERR(s->clk))