diff mbox series

[v3,33/35] dmaengine: plx_dma: convert tasklets to use new tasklet_setup() API

Message ID 20200831103542.305571-34-allen.lkml@gmail.com (mailing list archive)
State Accepted
Headers show
Series dmaengine: convert tasklets to use new | expand

Commit Message

Allen Aug. 31, 2020, 10:35 a.m. UTC
In preparation for unconditionally passing the
struct tasklet_struct pointer to all tasklet
callbacks, switch to using the new tasklet_setup()
and from_tasklet() to pass the tasklet pointer explicitly.

Signed-off-by: Allen Pais <allen.lkml@gmail.com>
---
 drivers/dma/plx_dma.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

Comments

Logan Gunthorpe Aug. 31, 2020, 3:47 p.m. UTC | #1
On 2020-08-31 4:35 a.m., Allen Pais wrote:
> In preparation for unconditionally passing the
> struct tasklet_struct pointer to all tasklet
> callbacks, switch to using the new tasklet_setup()
> and from_tasklet() to pass the tasklet pointer explicitly.
> 
> Signed-off-by: Allen Pais <allen.lkml@gmail.com>
> ---
>  drivers/dma/plx_dma.c | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/dma/plx_dma.c b/drivers/dma/plx_dma.c
> index db4c5fd453a9..f387c5bbc170 100644
> --- a/drivers/dma/plx_dma.c
> +++ b/drivers/dma/plx_dma.c
> @@ -241,9 +241,9 @@ static void plx_dma_stop(struct plx_dma_dev *plxdev)
>  	rcu_read_unlock();
>  }
>  
> -static void plx_dma_desc_task(unsigned long data)
> +static void plx_dma_desc_task(struct tasklet_struct *t)
>  {
> -	struct plx_dma_dev *plxdev = (void *)data;
> +	struct plx_dma_dev *plxdev = from_tasklet(plxdev, t, desc_task);

The discussion I saw on another thread suggested the private macro
from_tasklet() would be replaced with something generic. So isn't this
patchset a bit premature?

Thanks,

Logan
Allen Aug. 31, 2020, 3:56 p.m. UTC | #2
Logan,
> > In preparation for unconditionally passing the
> > struct tasklet_struct pointer to all tasklet
> > callbacks, switch to using the new tasklet_setup()
> > and from_tasklet() to pass the tasklet pointer explicitly.
> >
> > Signed-off-by: Allen Pais <allen.lkml@gmail.com>
> > ---
> >  drivers/dma/plx_dma.c | 7 +++----
> >  1 file changed, 3 insertions(+), 4 deletions(-)
> >
> > diff --git a/drivers/dma/plx_dma.c b/drivers/dma/plx_dma.c
> > index db4c5fd453a9..f387c5bbc170 100644
> > --- a/drivers/dma/plx_dma.c
> > +++ b/drivers/dma/plx_dma.c
> > @@ -241,9 +241,9 @@ static void plx_dma_stop(struct plx_dma_dev *plxdev)
> >       rcu_read_unlock();
> >  }
> >
> > -static void plx_dma_desc_task(unsigned long data)
> > +static void plx_dma_desc_task(struct tasklet_struct *t)
> >  {
> > -     struct plx_dma_dev *plxdev = (void *)data;
> > +     struct plx_dma_dev *plxdev = from_tasklet(plxdev, t, desc_task);
>
> The discussion I saw on another thread suggested the private macro
> from_tasklet() would be replaced with something generic. So isn't this
> patchset a bit premature?

 Yes, but efforts to replace it with something generic was not well accepted.
We were left with either using a private macro from_tasklet() or use
well known container_of().  I have left it to the maintainers to decide
which one they prefer.
Logan Gunthorpe Aug. 31, 2020, 4:17 p.m. UTC | #3
On 2020-08-31 9:56 a.m., Allen wrote:
> Logan,
>>> In preparation for unconditionally passing the
>>> struct tasklet_struct pointer to all tasklet
>>> callbacks, switch to using the new tasklet_setup()
>>> and from_tasklet() to pass the tasklet pointer explicitly.
>>>
>>> Signed-off-by: Allen Pais <allen.lkml@gmail.com>
>>> ---
>>>  drivers/dma/plx_dma.c | 7 +++----
>>>  1 file changed, 3 insertions(+), 4 deletions(-)
>>>
>>> diff --git a/drivers/dma/plx_dma.c b/drivers/dma/plx_dma.c
>>> index db4c5fd453a9..f387c5bbc170 100644
>>> --- a/drivers/dma/plx_dma.c
>>> +++ b/drivers/dma/plx_dma.c
>>> @@ -241,9 +241,9 @@ static void plx_dma_stop(struct plx_dma_dev *plxdev)
>>>       rcu_read_unlock();
>>>  }
>>>
>>> -static void plx_dma_desc_task(unsigned long data)
>>> +static void plx_dma_desc_task(struct tasklet_struct *t)
>>>  {
>>> -     struct plx_dma_dev *plxdev = (void *)data;
>>> +     struct plx_dma_dev *plxdev = from_tasklet(plxdev, t, desc_task);
>>
>> The discussion I saw on another thread suggested the private macro
>> from_tasklet() would be replaced with something generic. So isn't this
>> patchset a bit premature?
> 
>  Yes, but efforts to replace it with something generic was not well accepted.
> We were left with either using a private macro from_tasklet() or use
> well known container_of().  I have left it to the maintainers to decide
> which one they prefer.

Well my vote would be for using container_of() directly. But I don't
really have much clout here.

Logan
diff mbox series

Patch

diff --git a/drivers/dma/plx_dma.c b/drivers/dma/plx_dma.c
index db4c5fd453a9..f387c5bbc170 100644
--- a/drivers/dma/plx_dma.c
+++ b/drivers/dma/plx_dma.c
@@ -241,9 +241,9 @@  static void plx_dma_stop(struct plx_dma_dev *plxdev)
 	rcu_read_unlock();
 }
 
-static void plx_dma_desc_task(unsigned long data)
+static void plx_dma_desc_task(struct tasklet_struct *t)
 {
-	struct plx_dma_dev *plxdev = (void *)data;
+	struct plx_dma_dev *plxdev = from_tasklet(plxdev, t, desc_task);
 
 	plx_dma_process_desc(plxdev);
 }
@@ -513,8 +513,7 @@  static int plx_dma_create(struct pci_dev *pdev)
 	}
 
 	spin_lock_init(&plxdev->ring_lock);
-	tasklet_init(&plxdev->desc_task, plx_dma_desc_task,
-		     (unsigned long)plxdev);
+	tasklet_setup(&plxdev->desc_task, plx_dma_desc_task);
 
 	RCU_INIT_POINTER(plxdev->pdev, pdev);
 	plxdev->bar = pcim_iomap_table(pdev)[0];