All of lore.kernel.org
 help / color / mirror / Atom feed
* FAILED: patch "[PATCH] iio: stx104: Unregister IIO device on remove callback" failed to apply to 4.7-stable tree
@ 2016-09-22 13:10 gregkh
  2016-09-22 13:32 ` William Breathitt Gray
  0 siblings, 1 reply; 3+ messages in thread
From: gregkh @ 2016-09-22 13:10 UTC (permalink / raw)
  To: vilhelm.gray, Stable, jic23; +Cc: stable


The patch below does not apply to the 4.7-stable tree.
If someone wants it applied there, or to any other stable or longterm
tree, then please email the backport, including the original git commit
id to <stable@vger.kernel.org>.

thanks,

greg k-h

------------------ original commit in Linus's tree ------------------

>From 45e98152850c36560484f3fa3bb857a4bfe1a419 Mon Sep 17 00:00:00 2001
From: William Breathitt Gray <vilhelm.gray@gmail.com>
Date: Tue, 19 Jul 2016 12:25:00 -0400
Subject: [PATCH] iio: stx104: Unregister IIO device on remove callback

The devm_iio_device_register function should not be used if custom
operations must be performed in the remove callback. This patch replaces
the dem_iio_device_register call with a iio_device_register call and
respective iio_device_unregister call in the remove callback.

Fixes: 765550e4d98d ("iio: stx104: Add GPIO support for the Apex Embedded Systems STX104")
Signed-off-by: William Breathitt Gray <vilhelm.gray@gmail.com>
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>

diff --git a/drivers/iio/dac/stx104.c b/drivers/iio/dac/stx104.c
index 792a97164cb2..bebbd00304ce 100644
--- a/drivers/iio/dac/stx104.c
+++ b/drivers/iio/dac/stx104.c
@@ -65,6 +65,16 @@ struct stx104_gpio {
 	unsigned int out_state;
 };
 
+/**
+ * struct stx104_dev - STX104 device private data structure
+ * @indio_dev:	IIO device
+ * @chip:	instance of the gpio_chip
+ */
+struct stx104_dev {
+	struct iio_dev *indio_dev;
+	struct gpio_chip *chip;
+};
+
 static int stx104_read_raw(struct iio_dev *indio_dev,
 	struct iio_chan_spec const *chan, int *val, int *val2, long mask)
 {
@@ -107,6 +117,7 @@ static const struct iio_chan_spec stx104_channels[STX104_NUM_CHAN] = {
 static int stx104_gpio_get_direction(struct gpio_chip *chip,
 	unsigned int offset)
 {
+	/* GPIO 0-3 are input only, while the rest are output only */
 	if (offset < 4)
 		return 1;
 
@@ -169,6 +180,7 @@ static int stx104_probe(struct device *dev, unsigned int id)
 	struct iio_dev *indio_dev;
 	struct stx104_iio *priv;
 	struct stx104_gpio *stx104gpio;
+	struct stx104_dev *stx104dev;
 	int err;
 
 	indio_dev = devm_iio_device_alloc(dev, sizeof(*priv));
@@ -179,6 +191,10 @@ static int stx104_probe(struct device *dev, unsigned int id)
 	if (!stx104gpio)
 		return -ENOMEM;
 
+	stx104dev = devm_kzalloc(dev, sizeof(*stx104dev), GFP_KERNEL);
+	if (!stx104dev)
+		return -ENOMEM;
+
 	if (!devm_request_region(dev, base[id], STX104_EXTENT,
 		dev_name(dev))) {
 		dev_err(dev, "Unable to lock port addresses (0x%X-0x%X)\n",
@@ -199,12 +215,6 @@ static int stx104_probe(struct device *dev, unsigned int id)
 	outw(0, base[id] + 4);
 	outw(0, base[id] + 6);
 
-	err = devm_iio_device_register(dev, indio_dev);
-	if (err) {
-		dev_err(dev, "IIO device registering failed (%d)\n", err);
-		return err;
-	}
-
 	stx104gpio->chip.label = dev_name(dev);
 	stx104gpio->chip.parent = dev;
 	stx104gpio->chip.owner = THIS_MODULE;
@@ -220,7 +230,9 @@ static int stx104_probe(struct device *dev, unsigned int id)
 
 	spin_lock_init(&stx104gpio->lock);
 
-	dev_set_drvdata(dev, stx104gpio);
+	stx104dev->indio_dev = indio_dev;
+	stx104dev->chip = &stx104gpio->chip;
+	dev_set_drvdata(dev, stx104dev);
 
 	err = gpiochip_add_data(&stx104gpio->chip, stx104gpio);
 	if (err) {
@@ -228,14 +240,22 @@ static int stx104_probe(struct device *dev, unsigned int id)
 		return err;
 	}
 
+	err = iio_device_register(indio_dev);
+	if (err) {
+		dev_err(dev, "IIO device registering failed (%d)\n", err);
+		gpiochip_remove(&stx104gpio->chip);
+		return err;
+	}
+
 	return 0;
 }
 
 static int stx104_remove(struct device *dev, unsigned int id)
 {
-	struct stx104_gpio *const stx104gpio = dev_get_drvdata(dev);
+	struct stx104_dev *const stx104dev = dev_get_drvdata(dev);
 
-	gpiochip_remove(&stx104gpio->chip);
+	iio_device_unregister(stx104dev->indio_dev);
+	gpiochip_remove(stx104dev->chip);
 
 	return 0;
 }


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

* Re: FAILED: patch "[PATCH] iio: stx104: Unregister IIO device on remove callback" failed to apply to 4.7-stable tree
  2016-09-22 13:10 FAILED: patch "[PATCH] iio: stx104: Unregister IIO device on remove callback" failed to apply to 4.7-stable tree gregkh
@ 2016-09-22 13:32 ` William Breathitt Gray
  2016-09-22 19:59   ` Jonathan Cameron
  0 siblings, 1 reply; 3+ messages in thread
From: William Breathitt Gray @ 2016-09-22 13:32 UTC (permalink / raw)
  To: gregkh; +Cc: Stable, jic23

On Thu, Sep 22, 2016 at 03:10:21PM +0200, gregkh@linuxfoundation.org wrote:
>
>The patch below does not apply to the 4.7-stable tree.
>If someone wants it applied there, or to any other stable or longterm
>tree, then please email the backport, including the original git commit
>id to <stable@vger.kernel.org>.
>
>thanks,
>
>greg k-h

This patch fixes an issues introduced in commit 765550e4d98d
("iio: stx104: Add GPIO support for the Apex Embedded Systems STX104").
If I'm not mistaken, commit 765550e4d98d is not in the 4.7-stable tree.
Since the source of the issue is not present, this patch to resolve the
issue should not be merged into 4.7-stable.

Sincerely,

William Breathitt Gray

>------------------ original commit in Linus's tree ------------------
>
>>From 45e98152850c36560484f3fa3bb857a4bfe1a419 Mon Sep 17 00:00:00 2001
>From: William Breathitt Gray <vilhelm.gray@gmail.com>
>Date: Tue, 19 Jul 2016 12:25:00 -0400
>Subject: [PATCH] iio: stx104: Unregister IIO device on remove callback
>
>The devm_iio_device_register function should not be used if custom
>operations must be performed in the remove callback. This patch replaces
>the dem_iio_device_register call with a iio_device_register call and
>respective iio_device_unregister call in the remove callback.
>
>Fixes: 765550e4d98d ("iio: stx104: Add GPIO support for the Apex Embedded Systems STX104")
>Signed-off-by: William Breathitt Gray <vilhelm.gray@gmail.com>
>Cc: <Stable@vger.kernel.org>
>Signed-off-by: Jonathan Cameron <jic23@kernel.org>
>
>diff --git a/drivers/iio/dac/stx104.c b/drivers/iio/dac/stx104.c
>index 792a97164cb2..bebbd00304ce 100644
>--- a/drivers/iio/dac/stx104.c
>+++ b/drivers/iio/dac/stx104.c
>@@ -65,6 +65,16 @@ struct stx104_gpio {
> 	unsigned int out_state;
> };
> 
>+/**
>+ * struct stx104_dev - STX104 device private data structure
>+ * @indio_dev:	IIO device
>+ * @chip:	instance of the gpio_chip
>+ */
>+struct stx104_dev {
>+	struct iio_dev *indio_dev;
>+	struct gpio_chip *chip;
>+};
>+
> static int stx104_read_raw(struct iio_dev *indio_dev,
> 	struct iio_chan_spec const *chan, int *val, int *val2, long mask)
> {
>@@ -107,6 +117,7 @@ static const struct iio_chan_spec stx104_channels[STX104_NUM_CHAN] = {
> static int stx104_gpio_get_direction(struct gpio_chip *chip,
> 	unsigned int offset)
> {
>+	/* GPIO 0-3 are input only, while the rest are output only */
> 	if (offset < 4)
> 		return 1;
> 
>@@ -169,6 +180,7 @@ static int stx104_probe(struct device *dev, unsigned int id)
> 	struct iio_dev *indio_dev;
> 	struct stx104_iio *priv;
> 	struct stx104_gpio *stx104gpio;
>+	struct stx104_dev *stx104dev;
> 	int err;
> 
> 	indio_dev = devm_iio_device_alloc(dev, sizeof(*priv));
>@@ -179,6 +191,10 @@ static int stx104_probe(struct device *dev, unsigned int id)
> 	if (!stx104gpio)
> 		return -ENOMEM;
> 
>+	stx104dev = devm_kzalloc(dev, sizeof(*stx104dev), GFP_KERNEL);
>+	if (!stx104dev)
>+		return -ENOMEM;
>+
> 	if (!devm_request_region(dev, base[id], STX104_EXTENT,
> 		dev_name(dev))) {
> 		dev_err(dev, "Unable to lock port addresses (0x%X-0x%X)\n",
>@@ -199,12 +215,6 @@ static int stx104_probe(struct device *dev, unsigned int id)
> 	outw(0, base[id] + 4);
> 	outw(0, base[id] + 6);
> 
>-	err = devm_iio_device_register(dev, indio_dev);
>-	if (err) {
>-		dev_err(dev, "IIO device registering failed (%d)\n", err);
>-		return err;
>-	}
>-
> 	stx104gpio->chip.label = dev_name(dev);
> 	stx104gpio->chip.parent = dev;
> 	stx104gpio->chip.owner = THIS_MODULE;
>@@ -220,7 +230,9 @@ static int stx104_probe(struct device *dev, unsigned int id)
> 
> 	spin_lock_init(&stx104gpio->lock);
> 
>-	dev_set_drvdata(dev, stx104gpio);
>+	stx104dev->indio_dev = indio_dev;
>+	stx104dev->chip = &stx104gpio->chip;
>+	dev_set_drvdata(dev, stx104dev);
> 
> 	err = gpiochip_add_data(&stx104gpio->chip, stx104gpio);
> 	if (err) {
>@@ -228,14 +240,22 @@ static int stx104_probe(struct device *dev, unsigned int id)
> 		return err;
> 	}
> 
>+	err = iio_device_register(indio_dev);
>+	if (err) {
>+		dev_err(dev, "IIO device registering failed (%d)\n", err);
>+		gpiochip_remove(&stx104gpio->chip);
>+		return err;
>+	}
>+
> 	return 0;
> }
> 
> static int stx104_remove(struct device *dev, unsigned int id)
> {
>-	struct stx104_gpio *const stx104gpio = dev_get_drvdata(dev);
>+	struct stx104_dev *const stx104dev = dev_get_drvdata(dev);
> 
>-	gpiochip_remove(&stx104gpio->chip);
>+	iio_device_unregister(stx104dev->indio_dev);
>+	gpiochip_remove(stx104dev->chip);
> 
> 	return 0;
> }
>

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

* Re: FAILED: patch "[PATCH] iio: stx104: Unregister IIO device on remove callback" failed to apply to 4.7-stable tree
  2016-09-22 13:32 ` William Breathitt Gray
@ 2016-09-22 19:59   ` Jonathan Cameron
  0 siblings, 0 replies; 3+ messages in thread
From: Jonathan Cameron @ 2016-09-22 19:59 UTC (permalink / raw)
  To: William Breathitt Gray, gregkh; +Cc: Stable, jic23



On 22 September 2016 14:32:32 BST, William Breathitt Gray <vilhelm.gray@gmail.com> wrote:
>On Thu, Sep 22, 2016 at 03:10:21PM +0200, gregkh@linuxfoundation.org
>wrote:
>>
>>The patch below does not apply to the 4.7-stable tree.
>>If someone wants it applied there, or to any other stable or longterm
>>tree, then please email the backport, including the original git
>commit
>>id to <stable@vger.kernel.org>.
>>
>>thanks,
>>
>>greg k-h
>
>This patch fixes an issues introduced in commit 765550e4d98d
>("iio: stx104: Add GPIO support for the Apex Embedded Systems STX104").
>If I'm not mistaken, commit 765550e4d98d is not in the 4.7-stable tree.
>Since the source of the issue is not present, this patch to resolve the
>issue should not be merged into 4.7-stable.
>
>Sincerely,
>
>William Breathitt Gray
Another wrong tag from me. Sorry!
>
>>------------------ original commit in Linus's tree ------------------
>>
>>>From 45e98152850c36560484f3fa3bb857a4bfe1a419 Mon Sep 17 00:00:00 2001
>>From: William Breathitt Gray <vilhelm.gray@gmail.com>
>>Date: Tue, 19 Jul 2016 12:25:00 -0400
>>Subject: [PATCH] iio: stx104: Unregister IIO device on remove callback
>>
>>The devm_iio_device_register function should not be used if custom
>>operations must be performed in the remove callback. This patch
>replaces
>>the dem_iio_device_register call with a iio_device_register call and
>>respective iio_device_unregister call in the remove callback.
>>
>>Fixes: 765550e4d98d ("iio: stx104: Add GPIO support for the Apex
>Embedded Systems STX104")
>>Signed-off-by: William Breathitt Gray <vilhelm.gray@gmail.com>
>>Cc: <Stable@vger.kernel.org>
>>Signed-off-by: Jonathan Cameron <jic23@kernel.org>
>>
>>diff --git a/drivers/iio/dac/stx104.c b/drivers/iio/dac/stx104.c
>>index 792a97164cb2..bebbd00304ce 100644
>>--- a/drivers/iio/dac/stx104.c
>>+++ b/drivers/iio/dac/stx104.c
>>@@ -65,6 +65,16 @@ struct stx104_gpio {
>> 	unsigned int out_state;
>> };
>> 
>>+/**
>>+ * struct stx104_dev - STX104 device private data structure
>>+ * @indio_dev:	IIO device
>>+ * @chip:	instance of the gpio_chip
>>+ */
>>+struct stx104_dev {
>>+	struct iio_dev *indio_dev;
>>+	struct gpio_chip *chip;
>>+};
>>+
>> static int stx104_read_raw(struct iio_dev *indio_dev,
>> 	struct iio_chan_spec const *chan, int *val, int *val2, long mask)
>> {
>>@@ -107,6 +117,7 @@ static const struct iio_chan_spec
>stx104_channels[STX104_NUM_CHAN] = {
>> static int stx104_gpio_get_direction(struct gpio_chip *chip,
>> 	unsigned int offset)
>> {
>>+	/* GPIO 0-3 are input only, while the rest are output only */
>> 	if (offset < 4)
>> 		return 1;
>> 
>>@@ -169,6 +180,7 @@ static int stx104_probe(struct device *dev,
>unsigned int id)
>> 	struct iio_dev *indio_dev;
>> 	struct stx104_iio *priv;
>> 	struct stx104_gpio *stx104gpio;
>>+	struct stx104_dev *stx104dev;
>> 	int err;
>> 
>> 	indio_dev = devm_iio_device_alloc(dev, sizeof(*priv));
>>@@ -179,6 +191,10 @@ static int stx104_probe(struct device *dev,
>unsigned int id)
>> 	if (!stx104gpio)
>> 		return -ENOMEM;
>> 
>>+	stx104dev = devm_kzalloc(dev, sizeof(*stx104dev), GFP_KERNEL);
>>+	if (!stx104dev)
>>+		return -ENOMEM;
>>+
>> 	if (!devm_request_region(dev, base[id], STX104_EXTENT,
>> 		dev_name(dev))) {
>> 		dev_err(dev, "Unable to lock port addresses (0x%X-0x%X)\n",
>>@@ -199,12 +215,6 @@ static int stx104_probe(struct device *dev,
>unsigned int id)
>> 	outw(0, base[id] + 4);
>> 	outw(0, base[id] + 6);
>> 
>>-	err = devm_iio_device_register(dev, indio_dev);
>>-	if (err) {
>>-		dev_err(dev, "IIO device registering failed (%d)\n", err);
>>-		return err;
>>-	}
>>-
>> 	stx104gpio->chip.label = dev_name(dev);
>> 	stx104gpio->chip.parent = dev;
>> 	stx104gpio->chip.owner = THIS_MODULE;
>>@@ -220,7 +230,9 @@ static int stx104_probe(struct device *dev,
>unsigned int id)
>> 
>> 	spin_lock_init(&stx104gpio->lock);
>> 
>>-	dev_set_drvdata(dev, stx104gpio);
>>+	stx104dev->indio_dev = indio_dev;
>>+	stx104dev->chip = &stx104gpio->chip;
>>+	dev_set_drvdata(dev, stx104dev);
>> 
>> 	err = gpiochip_add_data(&stx104gpio->chip, stx104gpio);
>> 	if (err) {
>>@@ -228,14 +240,22 @@ static int stx104_probe(struct device *dev,
>unsigned int id)
>> 		return err;
>> 	}
>> 
>>+	err = iio_device_register(indio_dev);
>>+	if (err) {
>>+		dev_err(dev, "IIO device registering failed (%d)\n", err);
>>+		gpiochip_remove(&stx104gpio->chip);
>>+		return err;
>>+	}
>>+
>> 	return 0;
>> }
>> 
>> static int stx104_remove(struct device *dev, unsigned int id)
>> {
>>-	struct stx104_gpio *const stx104gpio = dev_get_drvdata(dev);
>>+	struct stx104_dev *const stx104dev = dev_get_drvdata(dev);
>> 
>>-	gpiochip_remove(&stx104gpio->chip);
>>+	iio_device_unregister(stx104dev->indio_dev);
>>+	gpiochip_remove(stx104dev->chip);
>> 
>> 	return 0;
>> }
>>

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

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

end of thread, other threads:[~2016-09-22 19:59 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-22 13:10 FAILED: patch "[PATCH] iio: stx104: Unregister IIO device on remove callback" failed to apply to 4.7-stable tree gregkh
2016-09-22 13:32 ` William Breathitt Gray
2016-09-22 19:59   ` Jonathan Cameron

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.