Skip to contentSkip to conversation

gpio: eic-sprd: use devm_atomic_notifier_chain_register()

PATCH Superseded Eliav Farber 3 participants 6 messages Jul 23 – Jul 27

Subsystems (7)
ACPI HID GPIO IIO +3 more subsystems

v1 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

PATCH 10/12 gpio: eic-sprd: use devm_atomic_notifier_chain_register()

Replace the atomic_notifier_chain_register() + devm_add_action_or_reset() pattern with a single call to devm_atomic_notifier_chain_register(), removing the sprd_eic_unregister_notifier() callback.

---
 drivers/gpio/gpio-eic-sprd.c | 17 ++---------------
 1 file changed, 2 insertions(+), 15 deletions(-)
drivers/gpio/gpio-eic-sprd.c +2 -15
index 3b7ebcf12fe7..86eb9624d38a 100644
@@ -601,13 +601,6 @@ static const struct irq_chip sprd_eic_irq = {
 	GPIOCHIP_IRQ_RESOURCE_HELPERS,
 };
 
-static void sprd_eic_unregister_notifier(void *data)
-{
-	struct notifier_block *nb = data;
-
-	atomic_notifier_chain_unregister(&sprd_eic_irq_notifier, nb);
-}
-
 static int sprd_eic_probe(struct platform_device *pdev)
 {
 	const struct sprd_eic_variant_data *pdata;
@@ -690,14 +683,8 @@ static int sprd_eic_probe(struct platform_device *pdev)
 	}
 
 	sprd_eic->irq_nb.notifier_call = sprd_eic_irq_notify;
-	ret = atomic_notifier_chain_register(&sprd_eic_irq_notifier,
-					     &sprd_eic->irq_nb);
-	if (ret)
-		return dev_err_probe(dev, ret,
-				     "Failed to register with the interrupt notifier");
-
-	return devm_add_action_or_reset(dev, sprd_eic_unregister_notifier,
-					&sprd_eic->irq_nb);
+	return devm_atomic_notifier_chain_register(dev, &sprd_eic_irq_notifier,
+						   &sprd_eic->irq_nb);
 }
 
 static const struct of_device_id sprd_eic_of_match[] = {
Signature · 1 line
2.47.3
#1 lore raw

PATCH 11/12 gpio: gpiolib-kunit: use devm_blocking_notifier_chain_register()

Replace the blocking_notifier_chain_register() + devm_add_action_or_reset() pattern with a single call to devm_blocking_notifier_chain_register(), removing the gpio_unbind_unregister_notifier() callback.

---
 drivers/gpio/gpiolib-kunit.c | 14 ++------------
 1 file changed, 2 insertions(+), 12 deletions(-)
drivers/gpio/gpiolib-kunit.c +2 -12
index 380b68f879e5..8ce9acc89e29 100644
@@ -237,13 +237,6 @@ static int gpio_unbind_notify(struct notifier_block *nb, unsigned long action,
 	return NOTIFY_OK;
 }
 
-static void gpio_unbind_unregister_notifier(void *data)
-{
-	struct notifier_block *nb = data;
-
-	blocking_notifier_chain_unregister(&gpio_unbind_notifier, nb);
-}
-
 static int gpio_unbind_consumer_probe(struct platform_device *pdev)
 {
 	struct gpio_unbind_consumer_drvdata *data;
@@ -261,11 +254,8 @@ static int gpio_unbind_consumer_probe(struct platform_device *pdev)
 		return PTR_ERR(data->desc);
 
 	data->nb.notifier_call = gpio_unbind_notify;
-	ret = blocking_notifier_chain_register(&gpio_unbind_notifier, &data->nb);
-	if (ret)
-		return ret;
-
-	ret = devm_add_action_or_reset(dev, gpio_unbind_unregister_notifier, &data->nb);
+	ret = devm_blocking_notifier_chain_register(dev, &gpio_unbind_notifier,
+						    &data->nb);
 	if (ret)
 		return ret;
 
Signature · 1 line
2.47.3
#3 lore raw

PATCH 12/12 reboot: use devm_blocking_notifier_chain_register()

In reply to Eliav Farber

Replace the blocking_notifier_chain_register() + devm_add_action_or_reset() pattern with a single call to devm_blocking_notifier_chain_register(), removing the devm_unregister_reboot_notifier() callback.

---
 kernel/reboot.c | 24 ++----------------------
 1 file changed, 2 insertions(+), 22 deletions(-)
kernel/reboot.c +2 -22
index 695c33e75efd..557609419989 100644
@@ -136,30 +136,10 @@ int unregister_reboot_notifier(struct notifier_block *nb)
 }
 EXPORT_SYMBOL(unregister_reboot_notifier);
 
-static void devm_unregister_reboot_notifier(struct device *dev, void *res)
-{
-	WARN_ON(unregister_reboot_notifier(*(struct notifier_block **)res));
-}
-
 int devm_register_reboot_notifier(struct device *dev, struct notifier_block *nb)
 {
-	struct notifier_block **rcnb;
-	int ret;
-
-	rcnb = devres_alloc(devm_unregister_reboot_notifier,
-			    sizeof(*rcnb), GFP_KERNEL);
-	if (!rcnb)
-		return -ENOMEM;
-
-	ret = register_reboot_notifier(nb);
-	if (!ret) {
-		*rcnb = nb;
-		devres_add(dev, rcnb);
-	} else {
-		devres_free(rcnb);
-	}
-
-	return ret;
+	return devm_blocking_notifier_chain_register(dev,
+						     &reboot_notifier_list, nb);
 }
 EXPORT_SYMBOL(devm_register_reboot_notifier);
 
Signature · 1 line
2.47.3
#2 lore raw

Re: [PATCH 11/12] gpio: gpiolib-kunit: use devm_blocking_notifier_chain_register()

In reply to Eliav Farber
Quoted 7 lines · Eliav Farber

Replace the blocking_notifier_chain_register() + devm_add_action_or_reset() pattern with a single call to devm_blocking_notifier_chain_register(), removing the gpio_unbind_unregister_notifier() callback.

---

This could conflict with the changes I already have queued so either it waits until the next cycle or I'd need an immutable branch with patch 1/12.

Bartosz

Reviewed-by on v1 10/12
#5 lore raw
In reply to Eliav Farber
Quoted 7 lines · Eliav Farber

Replace the atomic_notifier_chain_register() + devm_add_action_or_reset() pattern with a single call to devm_atomic_notifier_chain_register(), removing the sprd_eic_unregister_notifier() callback.

---

LGTM. Thanks.

Quoted 38 lines
  drivers/gpio/gpio-eic-sprd.c | 17 ++---------------
  1 file changed, 2 insertions(+), 15 deletions(-)
drivers/gpio/gpio-eic-sprd.c +2 -15
index 3b7ebcf12fe7..86eb9624d38a 100644
@@ -601,13 +601,6 @@ static const struct irq_chip sprd_eic_irq = {
  	GPIOCHIP_IRQ_RESOURCE_HELPERS,
  };
 
-static void sprd_eic_unregister_notifier(void *data)
-{
-	struct notifier_block *nb = data;
-
-	atomic_notifier_chain_unregister(&sprd_eic_irq_notifier, nb);
-}
-
  static int sprd_eic_probe(struct platform_device *pdev)
  {
  	const struct sprd_eic_variant_data *pdata;
@@ -690,14 +683,8 @@ static int sprd_eic_probe(struct platform_device *pdev)
  	}
 
  	sprd_eic->irq_nb.notifier_call = sprd_eic_irq_notify;
-	ret = atomic_notifier_chain_register(&sprd_eic_irq_notifier,
-					     &sprd_eic->irq_nb);
-	if (ret)
-		return dev_err_probe(dev, ret,
-				     "Failed to register with the interrupt notifier");
-
-	return devm_add_action_or_reset(dev, sprd_eic_unregister_notifier,
-					&sprd_eic->irq_nb);
+	return devm_atomic_notifier_chain_register(dev, &sprd_eic_irq_notifier,
+						   &sprd_eic->irq_nb);
  }
 
  static const struct of_device_id sprd_eic_of_match[] = {