Message ID | 20190929163028.9665-3-romain.perier@gmail.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Modernize the tasklet API | expand |
On Sun, Sep 29, 2019 at 06:30:14PM +0200, Romain Perier wrote: > Currently, the tasklet and its "tdata" has no relationship. The future > tasklet API, will no longer allow to pass an arbitrary "unsigned long" > data parameter. The tasklet data structure will need to be embedded into > a data structure that will be retrieved from the tasklet handler (most > of the time, it is the driver data structure). This commit prepares the > driver to this change. For doing so, it embeds "tasklet" into "tdata". > Then, "tdata" will be recoverable from its "tasklet" field, with the > tasklet API. > > Signed-off-by: Romain Perier <romain.perier@gmail.com> > --- > drivers/crypto/ccp/ccp-dev.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/drivers/crypto/ccp/ccp-dev.c b/drivers/crypto/ccp/ccp-dev.c > index 73acf0fdb793..d0d180176f45 100644 > --- a/drivers/crypto/ccp/ccp-dev.c > +++ b/drivers/crypto/ccp/ccp-dev.c > @@ -44,6 +44,7 @@ MODULE_PARM_DESC(max_devs, "Maximum number of CCPs to enable (default: all; 0 di > struct ccp_tasklet_data { > struct completion completion; > struct ccp_cmd *cmd; > + struct tasklet_struct tasklet; > }; > > /* Human-readable error strings */ > @@ -436,9 +437,8 @@ int ccp_cmd_queue_thread(void *data) > struct ccp_cmd_queue *cmd_q = (struct ccp_cmd_queue *)data; > struct ccp_cmd *cmd; > struct ccp_tasklet_data tdata; > - struct tasklet_struct tasklet; > > - tasklet_init(&tasklet, ccp_do_cmd_complete, (unsigned long)&tdata); > + tasklet_init(&tdata.tasklet, ccp_do_cmd_complete, (unsigned long)&tdata); Why not switch to tasklet_setup() here to avoid changing this again later? -Kees > > set_current_state(TASK_INTERRUPTIBLE); > while (!kthread_should_stop()) { > @@ -458,7 +458,7 @@ int ccp_cmd_queue_thread(void *data) > /* Schedule the completion callback */ > tdata.cmd = cmd; > init_completion(&tdata.completion); > - tasklet_schedule(&tasklet); > + tasklet_schedule(&tdata.tasklet); > wait_for_completion(&tdata.completion); > } > > -- > 2.23.0 >
diff --git a/drivers/crypto/ccp/ccp-dev.c b/drivers/crypto/ccp/ccp-dev.c index 73acf0fdb793..d0d180176f45 100644 --- a/drivers/crypto/ccp/ccp-dev.c +++ b/drivers/crypto/ccp/ccp-dev.c @@ -44,6 +44,7 @@ MODULE_PARM_DESC(max_devs, "Maximum number of CCPs to enable (default: all; 0 di struct ccp_tasklet_data { struct completion completion; struct ccp_cmd *cmd; + struct tasklet_struct tasklet; }; /* Human-readable error strings */ @@ -436,9 +437,8 @@ int ccp_cmd_queue_thread(void *data) struct ccp_cmd_queue *cmd_q = (struct ccp_cmd_queue *)data; struct ccp_cmd *cmd; struct ccp_tasklet_data tdata; - struct tasklet_struct tasklet; - tasklet_init(&tasklet, ccp_do_cmd_complete, (unsigned long)&tdata); + tasklet_init(&tdata.tasklet, ccp_do_cmd_complete, (unsigned long)&tdata); set_current_state(TASK_INTERRUPTIBLE); while (!kthread_should_stop()) { @@ -458,7 +458,7 @@ int ccp_cmd_queue_thread(void *data) /* Schedule the completion callback */ tdata.cmd = cmd; init_completion(&tdata.completion); - tasklet_schedule(&tasklet); + tasklet_schedule(&tdata.tasklet); wait_for_completion(&tdata.completion); }
Currently, the tasklet and its "tdata" has no relationship. The future tasklet API, will no longer allow to pass an arbitrary "unsigned long" data parameter. The tasklet data structure will need to be embedded into a data structure that will be retrieved from the tasklet handler (most of the time, it is the driver data structure). This commit prepares the driver to this change. For doing so, it embeds "tasklet" into "tdata". Then, "tdata" will be recoverable from its "tasklet" field, with the tasklet API. Signed-off-by: Romain Perier <romain.perier@gmail.com> --- drivers/crypto/ccp/ccp-dev.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)