linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] iio: adc: ti_am335x_adc: do not free the kfifo twice
@ 2013-10-23 17:00 Sebastian Andrzej Siewior
  2013-10-23 17:00 ` [PATCH 2 / 2] iio: ti_am335x_adc: adjust the closing bracket in tiadc_read_raw() Sebastian Andrzej Siewior
  2013-10-23 19:36 ` [PATCH 1/2 v2] iio: adc: ti_am335x_adc: do not free the kfifo twice Sebastian Andrzej Siewior
  0 siblings, 2 replies; 4+ messages in thread
From: Sebastian Andrzej Siewior @ 2013-10-23 17:00 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: Felipe Balbi, linux-iio, Sebastian Andrzej Siewior,
	Lars-Peter Clausen

Since commit 9e69c9 ("iio: Add reference counting for buffers") the iio
core frees the buffer. So if the driver does it as well then bad things
will happen.

Cc: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---

By no means I am the expert here but the other users of iio_kfifo_free() like

drivers/iio/industrialio-triggered-buffer.c:    iio_kfifo_free(indio_dev->buffer);
drivers/iio/industrialio-triggered-buffer.c:    iio_kfifo_free(indio_dev->buffer);

are probably wrong, too. Not to mention staging. So *I* think iio_kfifo_free()
should vanish from the tree.

 drivers/iio/adc/ti_am335x_adc.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/iio/adc/ti_am335x_adc.c b/drivers/iio/adc/ti_am335x_adc.c
index f974dea..3d70f09 100644
--- a/drivers/iio/adc/ti_am335x_adc.c
+++ b/drivers/iio/adc/ti_am335x_adc.c
@@ -254,8 +254,6 @@ static int tiadc_iio_buffered_hardware_setup(struct iio_dev *indio_dev,
 
 error_free_irq:
 	free_irq(irq, indio_dev);
-error_kfifo_free:
-	iio_kfifo_free(indio_dev->buffer);
 	return ret;
 }
 
@@ -264,7 +262,6 @@ static void tiadc_iio_buffered_hardware_remove(struct iio_dev *indio_dev)
 	struct tiadc_device *adc_dev = iio_priv(indio_dev);
 
 	free_irq(adc_dev->mfd_tscadc->irq, indio_dev);
-	iio_kfifo_free(indio_dev->buffer);
 	iio_buffer_unregister(indio_dev);
 }
 
-- 
1.8.4.rc3


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

* [PATCH 2 / 2] iio: ti_am335x_adc: adjust the closing bracket in tiadc_read_raw()
  2013-10-23 17:00 [PATCH 1/2] iio: adc: ti_am335x_adc: do not free the kfifo twice Sebastian Andrzej Siewior
@ 2013-10-23 17:00 ` Sebastian Andrzej Siewior
  2013-10-23 19:36 ` [PATCH 1/2 v2] iio: adc: ti_am335x_adc: do not free the kfifo twice Sebastian Andrzej Siewior
  1 sibling, 0 replies; 4+ messages in thread
From: Sebastian Andrzej Siewior @ 2013-10-23 17:00 UTC (permalink / raw)
  To: Jonathan Cameron; +Cc: Felipe Balbi, linux-iio, Sebastian Andrzej Siewior

It somehow looks like the ending bracket belongs to the if statement but
it does belong to the while loop. This patch moves the bracket where it
belongs.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
 drivers/iio/adc/ti_am335x_adc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/iio/adc/ti_am335x_adc.c b/drivers/iio/adc/ti_am335x_adc.c
index ef54d8a..c9b487f 100644
--- a/drivers/iio/adc/ti_am335x_adc.c
+++ b/drivers/iio/adc/ti_am335x_adc.c
@@ -338,7 +338,7 @@ static int tiadc_read_raw(struct iio_dev *indio_dev,
 	while (tiadc_readl(adc_dev, REG_ADCFSM) & SEQ_STATUS) {
 		if (time_after(jiffies, timeout))
 			return -EAGAIN;
-		}
+	}
 	map_val = chan->channel + TOTAL_CHANNELS;
 
 	/*
-- 
1.8.4.rc3

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

* [PATCH 1/2 v2] iio: adc: ti_am335x_adc: do not free the kfifo twice
  2013-10-23 17:00 [PATCH 1/2] iio: adc: ti_am335x_adc: do not free the kfifo twice Sebastian Andrzej Siewior
  2013-10-23 17:00 ` [PATCH 2 / 2] iio: ti_am335x_adc: adjust the closing bracket in tiadc_read_raw() Sebastian Andrzej Siewior
@ 2013-10-23 19:36 ` Sebastian Andrzej Siewior
  2013-10-23 23:04   ` Jonathan Cameron
  1 sibling, 1 reply; 4+ messages in thread
From: Sebastian Andrzej Siewior @ 2013-10-23 19:36 UTC (permalink / raw)
  To: Jonathan Cameron; +Cc: Felipe Balbi, linux-iio, Lars-Peter Clausen

Since commit 9e69c9 ("iio: Add reference counting for buffers") the iio
core frees the buffer. So if the driver does it as well then bad things
will happen.

Cc: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
v1=E2=80=A6v2: make it compile after removal of error_kfifo_free label. Grm=
l.
       I tested it before I removed the same thing from
       tiadc_iio_buffered_hardware_setup()

 drivers/iio/adc/ti_am335x_adc.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/iio/adc/ti_am335x_adc.c b/drivers/iio/adc/ti_am335x_ad=
c.c
index f974dea..4f6e0ce 100644
--- a/drivers/iio/adc/ti_am335x_adc.c
+++ b/drivers/iio/adc/ti_am335x_adc.c
@@ -239,7 +239,7 @@ static int tiadc_iio_buffered_hardware_setup(struct iio=
_dev *indio_dev,
 	ret =3D request_threaded_irq(irq,	pollfunc_th, pollfunc_bh,
 				flags, indio_dev->name, indio_dev);
 	if (ret)
-		goto error_kfifo_free;
+		return ret;
=20
 	indio_dev->setup_ops =3D setup_ops;
 	indio_dev->modes |=3D INDIO_BUFFER_HARDWARE;
@@ -254,8 +254,6 @@ static int tiadc_iio_buffered_hardware_setup(struct iio=
_dev *indio_dev,
=20
 error_free_irq:
 	free_irq(irq, indio_dev);
-error_kfifo_free:
-	iio_kfifo_free(indio_dev->buffer);
 	return ret;
 }
=20
@@ -264,7 +262,6 @@ static void tiadc_iio_buffered_hardware_remove(struct i=
io_dev *indio_dev)
 	struct tiadc_device *adc_dev =3D iio_priv(indio_dev);
=20
 	free_irq(adc_dev->mfd_tscadc->irq, indio_dev);
-	iio_kfifo_free(indio_dev->buffer);
 	iio_buffer_unregister(indio_dev);
 }
=20
--=20
1.8.4.rc3

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

* Re: [PATCH 1/2 v2] iio: adc: ti_am335x_adc: do not free the kfifo twice
  2013-10-23 19:36 ` [PATCH 1/2 v2] iio: adc: ti_am335x_adc: do not free the kfifo twice Sebastian Andrzej Siewior
@ 2013-10-23 23:04   ` Jonathan Cameron
  0 siblings, 0 replies; 4+ messages in thread
From: Jonathan Cameron @ 2013-10-23 23:04 UTC (permalink / raw)
  To: Sebastian Andrzej Siewior; +Cc: Felipe Balbi, linux-iio, Lars-Peter Clausen



Sebastian Andrzej Siewior <bigeasy@linutronix.de> wrote:
>Since commit 9e69c9 ("iio: Add reference counting for buffers") the iio
>core frees the buffer. So if the driver does it as well then bad things
>will happen.

It is late and I haven't looked at this in much detail but I suspect that this is a reference count issue as the allocation of indio_dev->buffer is directly rather than via iio_buffer_activate. Lars?
>
>Cc: Lars-Peter Clausen <lars@metafoo.de>
>Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
>---
>v1…v2: make it compile after removal of error_kfifo_free label. Grml.
>       I tested it before I removed the same thing from
>       tiadc_iio_buffered_hardware_setup()
>
> drivers/iio/adc/ti_am335x_adc.c | 5 +----
> 1 file changed, 1 insertion(+), 4 deletions(-)
>
>diff --git a/drivers/iio/adc/ti_am335x_adc.c
>b/drivers/iio/adc/ti_am335x_adc.c
>index f974dea..4f6e0ce 100644
>--- a/drivers/iio/adc/ti_am335x_adc.c
>+++ b/drivers/iio/adc/ti_am335x_adc.c
>@@ -239,7 +239,7 @@ static int tiadc_iio_buffered_hardware_setup(struct
>iio_dev *indio_dev,
> 	ret = request_threaded_irq(irq,	pollfunc_th, pollfunc_bh,
> 				flags, indio_dev->name, indio_dev);
> 	if (ret)
>-		goto error_kfifo_free;
>+		return ret;
> 
> 	indio_dev->setup_ops = setup_ops;
> 	indio_dev->modes |= INDIO_BUFFER_HARDWARE;
>@@ -254,8 +254,6 @@ static int tiadc_iio_buffered_hardware_setup(struct
>iio_dev *indio_dev,
> 
> error_free_irq:
> 	free_irq(irq, indio_dev);
>-error_kfifo_free:
>-	iio_kfifo_free(indio_dev->buffer);
> 	return ret;
> }
> 
>@@ -264,7 +262,6 @@ static void
>tiadc_iio_buffered_hardware_remove(struct iio_dev *indio_dev)
> 	struct tiadc_device *adc_dev = iio_priv(indio_dev);
> 
> 	free_irq(adc_dev->mfd_tscadc->irq, indio_dev);
>-	iio_kfifo_free(indio_dev->buffer);
> 	iio_buffer_unregister(indio_dev);
> }
> 

-- 
Sent from my Android phone with K-9 Mail. Please excuse my brevity.

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

end of thread, other threads:[~2013-10-23 23:04 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-10-23 17:00 [PATCH 1/2] iio: adc: ti_am335x_adc: do not free the kfifo twice Sebastian Andrzej Siewior
2013-10-23 17:00 ` [PATCH 2 / 2] iio: ti_am335x_adc: adjust the closing bracket in tiadc_read_raw() Sebastian Andrzej Siewior
2013-10-23 19:36 ` [PATCH 1/2 v2] iio: adc: ti_am335x_adc: do not free the kfifo twice Sebastian Andrzej Siewior
2013-10-23 23:04   ` Jonathan Cameron

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).