Skip to contentSkip to conversation

staging:iio:ad799x fix error_free_irq, use devm_request_threaded_irq

PATCH Applied Hartmut Knaack 3 participants 4 messages Jan 1, 2014 – Feb 15, 2014

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH v2 2/2 staging:iio:ad799x fix error_free_irq, use devm_request_threaded_irq

Move to devm_request_threaded_irq to make device-removal easier.

---

drivers/staging/iio/adc/ad799x_core.c +9 -13
index 3deb390..bc886f6 100644
@@ -573,25 +573,23 @@ static int ad799x_probe(struct i2c_client *client,
 		goto error_disable_reg;
 
 	if (client->irq > 0) {
-		ret = request_threaded_irq(client->irq,
-					   NULL,
-					   ad799x_event_handler,
-					   IRQF_TRIGGER_FALLING |
-					   IRQF_ONESHOT,
-					   client->name,
-					   indio_dev);
+		ret = devm_request_threaded_irq(&client->dev,
+						client->irq,
+						NULL,
+						ad799x_event_handler,
+						IRQF_TRIGGER_FALLING |
+						IRQF_ONESHOT,
+						client->name,
+						indio_dev);
 		if (ret)
 			goto error_cleanup_ring;
 	}
 	ret = iio_device_register(indio_dev);
 	if (ret)
-		goto error_free_irq;
+		goto error_cleanup_ring;
 
 	return 0;
 
-error_free_irq:
-	if (client->irq > 0)
-		free_irq(client->irq, indio_dev);
 error_cleanup_ring:
 	ad799x_ring_cleanup(indio_dev);
 error_disable_reg:
@@ -607,8 +605,6 @@ static int ad799x_remove(struct i2c_client *client)
 	struct ad799x_state *st = iio_priv(indio_dev);
 
 	iio_device_unregister(indio_dev);
-	if (client->irq > 0)
-		free_irq(client->irq, indio_dev);
 
 	ad799x_ring_cleanup(indio_dev);
 	if (!IS_ERR(st->reg))
Acked-by on v2 2/2
#1 lore raw
Quoted 3 lines · Hartmut Knaack

Move to devm_request_threaded_irq to make device-removal easier.

I'm not a fan of devm_request_threaded_irq() since it makes it easy to get things wrong. But well.

Quoted 54 lines

---

drivers/staging/iio/adc/ad799x_core.c +9 -14
index 3deb390..bc886f6 100644
@@ -573,25 +573,23 @@ static int ad799x_probe(struct i2c_client *client,
 		goto error_disable_reg;
 
 	if (client->irq > 0) {
-		ret = request_threaded_irq(client->irq,
-					   NULL,
-					   ad799x_event_handler,
-					   IRQF_TRIGGER_FALLING |
-					   IRQF_ONESHOT,
-					   client->name,
-					   indio_dev);
+		ret = devm_request_threaded_irq(&client->dev,
+						client->irq,
+						NULL,
+						ad799x_event_handler,
+						IRQF_TRIGGER_FALLING |
+						IRQF_ONESHOT,
+						client->name,
+						indio_dev);
 		if (ret)
 			goto error_cleanup_ring;
 	}
 	ret = iio_device_register(indio_dev);
 	if (ret)
-		goto error_free_irq;
+		goto error_cleanup_ring;
 
 	return 0;
 
-error_free_irq:
-	if (client->irq > 0)
-		free_irq(client->irq, indio_dev);
 error_cleanup_ring:
 	ad799x_ring_cleanup(indio_dev);
 error_disable_reg:
@@ -607,8 +605,6 @@ static int ad799x_remove(struct i2c_client *client)
 	struct ad799x_state *st = iio_priv(indio_dev);
 
 	iio_device_unregister(indio_dev);
-	if (client->irq > 0)
-		free_irq(client->irq, indio_dev);
 
 	ad799x_ring_cleanup(indio_dev);
 	if (!IS_ERR(st->reg))
--

To unsubscribe from this list: send the line "unsubscribe linux-iio" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

maintainer
#2 lore raw
Quoted 9 lines · Lars-Peter Clausen
Quoted 3 lines · Hartmut Knaack

Move to devm_request_threaded_irq to make device-removal easier.

I'm not a fan of devm_request_threaded_irq() since it makes it easy to get things wrong. But well.

I'll hold this one until patch 1 has made it into staging-next via linus' tree.

Thanks,

Jonathan

Quoted 61 lines
Quoted 51 lines

---

drivers/staging/iio/adc/ad799x_core.c +9 -14
index 3deb390..bc886f6 100644
@@ -573,25 +573,23 @@ static int ad799x_probe(struct i2c_client *client,
  		goto error_disable_reg;
 
  	if (client->irq > 0) {
-		ret = request_threaded_irq(client->irq,
-					   NULL,
-					   ad799x_event_handler,
-					   IRQF_TRIGGER_FALLING |
-					   IRQF_ONESHOT,
-					   client->name,
-					   indio_dev);
+		ret = devm_request_threaded_irq(&client->dev,
+						client->irq,
+						NULL,
+						ad799x_event_handler,
+						IRQF_TRIGGER_FALLING |
+						IRQF_ONESHOT,
+						client->name,
+						indio_dev);
  		if (ret)
  			goto error_cleanup_ring;
  	}
  	ret = iio_device_register(indio_dev);
  	if (ret)
-		goto error_free_irq;
+		goto error_cleanup_ring;
 
  	return 0;
 
-error_free_irq:
-	if (client->irq > 0)
-		free_irq(client->irq, indio_dev);
  error_cleanup_ring:
  	ad799x_ring_cleanup(indio_dev);
  error_disable_reg:
@@ -607,8 +605,6 @@ static int ad799x_remove(struct i2c_client *client)
  	struct ad799x_state *st = iio_priv(indio_dev);
 
  	iio_device_unregister(indio_dev);
-	if (client->irq > 0)
-		free_irq(client->irq, indio_dev);
 
  	ad799x_ring_cleanup(indio_dev);
  	if (!IS_ERR(st->reg))
--
Quoted 4 lines

To unsubscribe from this list: send the line "unsubscribe linux-iio" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

--
To unsubscribe from this list: send the line "unsubscribe linux-iio" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

maintainer Applied
#3 lore raw
In reply to Hartmut Knaack
Quoted 3 lines · Hartmut Knaack

Move to devm_request_threaded_irq to make device-removal easier.

Applied to the togreg branch of iio.git

I took the short description above and used it as the patch title as it was more accurate after the patch split up.

Quoted 54 lines

---

drivers/staging/iio/adc/ad799x_core.c +9 -14
index 3deb390..bc886f6 100644
@@ -573,25 +573,23 @@ static int ad799x_probe(struct i2c_client *client,
  		goto error_disable_reg;
 
  	if (client->irq > 0) {
-		ret = request_threaded_irq(client->irq,
-					   NULL,
-					   ad799x_event_handler,
-					   IRQF_TRIGGER_FALLING |
-					   IRQF_ONESHOT,
-					   client->name,
-					   indio_dev);
+		ret = devm_request_threaded_irq(&client->dev,
+						client->irq,
+						NULL,
+						ad799x_event_handler,
+						IRQF_TRIGGER_FALLING |
+						IRQF_ONESHOT,
+						client->name,
+						indio_dev);
  		if (ret)
  			goto error_cleanup_ring;
  	}
  	ret = iio_device_register(indio_dev);
  	if (ret)
-		goto error_free_irq;
+		goto error_cleanup_ring;
 
  	return 0;
 
-error_free_irq:
-	if (client->irq > 0)
-		free_irq(client->irq, indio_dev);
  error_cleanup_ring:
  	ad799x_ring_cleanup(indio_dev);
  error_disable_reg:
@@ -607,8 +605,6 @@ static int ad799x_remove(struct i2c_client *client)
  	struct ad799x_state *st = iio_priv(indio_dev);
 
  	iio_device_unregister(indio_dev);
-	if (client->irq > 0)
-		free_irq(client->irq, indio_dev);
 
  	ad799x_ring_cleanup(indio_dev);
  	if (!IS_ERR(st->reg))
--

To unsubscribe from this list: send the line "unsubscribe linux-iio" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html