mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2 1/2] iio: adc: ina2xx: Make use of the helper macro kthread_run()
@ 2021-10-21 12:42 Cai Huoqing
  2021-10-21 12:42 ` [PATCH v2 2/2] iio: adc: ina2xx: Avoid double reference counting from get_task_struct/put_task_struct() Cai Huoqing
  2021-10-28 16:06 ` [PATCH v2 1/2] iio: adc: ina2xx: Make use of the helper macro kthread_run() Jonathan Cameron
  0 siblings, 2 replies; 3+ messages in thread
From: Cai Huoqing @ 2021-10-21 12:42 UTC (permalink / raw)
  To: lars; +Cc: Cai Huoqing, Jonathan Cameron, linux-iio, linux-kernel

Repalce kthread_create/wake_up_process() with kthread_run()
to simplify the code.

Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Cai Huoqing <caihuoqing@baidu.com>
---
v1->v2: Sort with [2/2] patch as a series.

 drivers/iio/adc/ina2xx-adc.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/iio/adc/ina2xx-adc.c b/drivers/iio/adc/ina2xx-adc.c
index a4b2ff9e0dd5..360d7a00f60d 100644
--- a/drivers/iio/adc/ina2xx-adc.c
+++ b/drivers/iio/adc/ina2xx-adc.c
@@ -842,15 +842,14 @@ static int ina2xx_buffer_enable(struct iio_dev *indio_dev)
 	dev_dbg(&indio_dev->dev, "Async readout mode: %d\n",
 		chip->allow_async_readout);
 
-	task = kthread_create(ina2xx_capture_thread, (void *)indio_dev,
-			      "%s:%d-%uus", indio_dev->name,
-			      iio_device_id(indio_dev),
-			      sampling_us);
+	task = kthread_run(ina2xx_capture_thread, (void *)indio_dev,
+			   "%s:%d-%uus", indio_dev->name,
+			   iio_device_id(indio_dev),
+			   sampling_us);
 	if (IS_ERR(task))
 		return PTR_ERR(task);
 
 	get_task_struct(task);
-	wake_up_process(task);
 	chip->task = task;
 
 	return 0;
-- 
2.25.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH v2 2/2] iio: adc: ina2xx: Avoid double reference counting from get_task_struct/put_task_struct()
  2021-10-21 12:42 [PATCH v2 1/2] iio: adc: ina2xx: Make use of the helper macro kthread_run() Cai Huoqing
@ 2021-10-21 12:42 ` Cai Huoqing
  2021-10-28 16:06 ` [PATCH v2 1/2] iio: adc: ina2xx: Make use of the helper macro kthread_run() Jonathan Cameron
  1 sibling, 0 replies; 3+ messages in thread
From: Cai Huoqing @ 2021-10-21 12:42 UTC (permalink / raw)
  To: lars; +Cc: Cai Huoqing, Jonathan Cameron, linux-iio, linux-kernel

kthread_run() and kthread_stop() already do reference
counting of the task, so remove get_task_struct/put_task_struct()
to avoid double reference counting.

Signed-off-by: Cai Huoqing <caihuoqing@baidu.com>
---
 drivers/iio/adc/ina2xx-adc.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/iio/adc/ina2xx-adc.c b/drivers/iio/adc/ina2xx-adc.c
index 360d7a00f60d..352f27657238 100644
--- a/drivers/iio/adc/ina2xx-adc.c
+++ b/drivers/iio/adc/ina2xx-adc.c
@@ -849,7 +849,6 @@ static int ina2xx_buffer_enable(struct iio_dev *indio_dev)
 	if (IS_ERR(task))
 		return PTR_ERR(task);
 
-	get_task_struct(task);
 	chip->task = task;
 
 	return 0;
@@ -861,7 +860,6 @@ static int ina2xx_buffer_disable(struct iio_dev *indio_dev)
 
 	if (chip->task) {
 		kthread_stop(chip->task);
-		put_task_struct(chip->task);
 		chip->task = NULL;
 	}
 
-- 
2.25.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2 1/2] iio: adc: ina2xx: Make use of the helper macro kthread_run()
  2021-10-21 12:42 [PATCH v2 1/2] iio: adc: ina2xx: Make use of the helper macro kthread_run() Cai Huoqing
  2021-10-21 12:42 ` [PATCH v2 2/2] iio: adc: ina2xx: Avoid double reference counting from get_task_struct/put_task_struct() Cai Huoqing
@ 2021-10-28 16:06 ` Jonathan Cameron
  1 sibling, 0 replies; 3+ messages in thread
From: Jonathan Cameron @ 2021-10-28 16:06 UTC (permalink / raw)
  To: Cai Huoqing; +Cc: lars, linux-iio, linux-kernel

On Thu, 21 Oct 2021 20:42:53 +0800
Cai Huoqing <caihuoqing@baidu.com> wrote:

> Repalce kthread_create/wake_up_process() with kthread_run()
> to simplify the code.
> 
> Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
> Signed-off-by: Cai Huoqing <caihuoqing@baidu.com>

Series applied to the togreg branch of iio.git which is pushed out initially
as testing for 0-day to see if it can find any problems we missed.

Thanks,

Jonathan

> ---
> v1->v2: Sort with [2/2] patch as a series.
> 
>  drivers/iio/adc/ina2xx-adc.c | 9 ++++-----
>  1 file changed, 4 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/iio/adc/ina2xx-adc.c b/drivers/iio/adc/ina2xx-adc.c
> index a4b2ff9e0dd5..360d7a00f60d 100644
> --- a/drivers/iio/adc/ina2xx-adc.c
> +++ b/drivers/iio/adc/ina2xx-adc.c
> @@ -842,15 +842,14 @@ static int ina2xx_buffer_enable(struct iio_dev *indio_dev)
>  	dev_dbg(&indio_dev->dev, "Async readout mode: %d\n",
>  		chip->allow_async_readout);
>  
> -	task = kthread_create(ina2xx_capture_thread, (void *)indio_dev,
> -			      "%s:%d-%uus", indio_dev->name,
> -			      iio_device_id(indio_dev),
> -			      sampling_us);
> +	task = kthread_run(ina2xx_capture_thread, (void *)indio_dev,
> +			   "%s:%d-%uus", indio_dev->name,
> +			   iio_device_id(indio_dev),
> +			   sampling_us);
>  	if (IS_ERR(task))
>  		return PTR_ERR(task);
>  
>  	get_task_struct(task);
> -	wake_up_process(task);
>  	chip->task = task;
>  
>  	return 0;


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-10-28 16:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-21 12:42 [PATCH v2 1/2] iio: adc: ina2xx: Make use of the helper macro kthread_run() Cai Huoqing
2021-10-21 12:42 ` [PATCH v2 2/2] iio: adc: ina2xx: Avoid double reference counting from get_task_struct/put_task_struct() Cai Huoqing
2021-10-28 16:06 ` [PATCH v2 1/2] iio: adc: ina2xx: Make use of the helper macro kthread_run() Jonathan Cameron

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®