[PATCH v2] Documentation: fix two typos in watchdog-api.txt

2014-07-29 Thread Sangjung Woo
This patch changes 'go of' to 'go off' and 'pretimout' to
'pretimeout'.

Signed-off-by: Sangjung Woo 
Reviewed-by: Guenter Roeck 
---
 Documentation/watchdog/watchdog-api.txt |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Documentation/watchdog/watchdog-api.txt 
b/Documentation/watchdog/watchdog-api.txt
index eb7132e..b3a701f 100644
--- a/Documentation/watchdog/watchdog-api.txt
+++ b/Documentation/watchdog/watchdog-api.txt
@@ -118,7 +118,7 @@ resets.
 Note that the pretimeout is the number of seconds before the time
 when the timeout will go off.  It is not the number of seconds until
 the pretimeout.  So, for instance, if you set the timeout to 60 seconds
-and the pretimeout to 10 seconds, the pretimout will go of in 50
+and the pretimeout to 10 seconds, the pretimeout will go off in 50
 seconds.  Setting a pretimeout to zero disables it.
 
 There is also a get function for getting the pretimeout:
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] Documentation: fix a typo in watchdog-api.txt

2014-07-29 Thread Sangjung Woo
Signed-off-by: Sangjung Woo 
---
 Documentation/watchdog/watchdog-api.txt |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Documentation/watchdog/watchdog-api.txt 
b/Documentation/watchdog/watchdog-api.txt
index eb7132e..53c49a4 100644
--- a/Documentation/watchdog/watchdog-api.txt
+++ b/Documentation/watchdog/watchdog-api.txt
@@ -118,7 +118,7 @@ resets.
 Note that the pretimeout is the number of seconds before the time
 when the timeout will go off.  It is not the number of seconds until
 the pretimeout.  So, for instance, if you set the timeout to 60 seconds
-and the pretimeout to 10 seconds, the pretimout will go of in 50
+and the pretimeout to 10 seconds, the pretimout will go off in 50
 seconds.  Setting a pretimeout to zero disables it.
 
 There is also a get function for getting the pretimeout:
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCHv4 2/8] extcon: adc-jack: Use devm_extcon_dev_register()

2014-04-21 Thread Sangjung Woo
Use the resource-managed extcon device register function (i.e.
devm_extcon_dev_register()) instead of extcon_dev_register(). If extcon device
is attached with this function, that extcon device is automatically unregistered
on driver detach. That reduces tiresome managing code.

Signed-off-by: Sangjung Woo 
---
 drivers/extcon/extcon-adc-jack.c |   30 +-
 1 file changed, 9 insertions(+), 21 deletions(-)

diff --git a/drivers/extcon/extcon-adc-jack.c b/drivers/extcon/extcon-adc-jack.c
index e23f1c2..549d820 100644
--- a/drivers/extcon/extcon-adc-jack.c
+++ b/drivers/extcon/extcon-adc-jack.c
@@ -105,9 +105,8 @@ static int adc_jack_probe(struct platform_device *pdev)
data->edev.name = pdata->name;
 
if (!pdata->cable_names) {
-   err = -EINVAL;
dev_err(&pdev->dev, "error: cable_names not defined.\n");
-   goto out;
+   return -EINVAL;
}
 
data->edev.dev.parent = &pdev->dev;
@@ -117,18 +116,16 @@ static int adc_jack_probe(struct platform_device *pdev)
for (i = 0; data->edev.supported_cable[i]; i++)
;
if (i == 0 || i > SUPPORTED_CABLE_MAX) {
-   err = -EINVAL;
dev_err(&pdev->dev, "error: pdata->cable_names size = %d\n",
i - 1);
-   goto out;
+   return -EINVAL;
}
data->num_cables = i;
 
if (!pdata->adc_conditions ||
!pdata->adc_conditions[0].state) {
-   err = -EINVAL;
dev_err(&pdev->dev, "error: adc_conditions not defined.\n");
-   goto out;
+   return -EINVAL;
}
data->adc_conditions = pdata->adc_conditions;
 
@@ -138,10 +135,8 @@ static int adc_jack_probe(struct platform_device *pdev)
data->num_conditions = i;
 
data->chan = iio_channel_get(&pdev->dev, pdata->consumer_channel);
-   if (IS_ERR(data->chan)) {
-   err = PTR_ERR(data->chan);
-   goto out;
-   }
+   if (IS_ERR(data->chan))
+   return PTR_ERR(data->chan);
 
data->handling_delay = msecs_to_jiffies(pdata->handling_delay_ms);
 
@@ -149,15 +144,14 @@ static int adc_jack_probe(struct platform_device *pdev)
 
platform_set_drvdata(pdev, data);
 
-   err = extcon_dev_register(&data->edev);
+   err = devm_extcon_dev_register(&pdev->dev, &data->edev);
if (err)
-   goto out;
+   return err;
 
data->irq = platform_get_irq(pdev, 0);
if (!data->irq) {
dev_err(&pdev->dev, "platform_get_irq failed\n");
-   err = -ENODEV;
-   goto err_irq;
+   return -ENODEV;
}
 
err = request_any_context_irq(data->irq, adc_jack_irq_thread,
@@ -165,15 +159,10 @@ static int adc_jack_probe(struct platform_device *pdev)
 
if (err < 0) {
dev_err(&pdev->dev, "error: irq %d\n", data->irq);
-   goto err_irq;
+   return err;
}
 
return 0;
-
-err_irq:
-   extcon_dev_unregister(&data->edev);
-out:
-   return err;
 }
 
 static int adc_jack_remove(struct platform_device *pdev)
@@ -182,7 +171,6 @@ static int adc_jack_remove(struct platform_device *pdev)
 
free_irq(data->irq, data);
cancel_work_sync(&data->handler.work);
-   extcon_dev_unregister(&data->edev);
 
return 0;
 }
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCHv4 3/8] extcon: gpio: Use devm_extcon_dev_register()

2014-04-21 Thread Sangjung Woo
Use the resource-managed extcon device register function (i.e.
devm_extcon_dev_register()) instead of extcon_dev_register(). If extcon device
is attached with this function, that extcon device is automatically unregistered
on driver detach. That reduces tiresome managing code.

Signed-off-by: Sangjung Woo 
---
 drivers/extcon/extcon-gpio.c |   16 
 1 file changed, 4 insertions(+), 12 deletions(-)

diff --git a/drivers/extcon/extcon-gpio.c b/drivers/extcon/extcon-gpio.c
index 13d5222..43af34c 100644
--- a/drivers/extcon/extcon-gpio.c
+++ b/drivers/extcon/extcon-gpio.c
@@ -121,34 +121,27 @@ static int gpio_extcon_probe(struct platform_device *pdev)
msecs_to_jiffies(pdata->debounce);
}
 
-   ret = extcon_dev_register(&extcon_data->edev);
+   ret = devm_extcon_dev_register(&pdev->dev, &extcon_data->edev);
if (ret < 0)
return ret;
 
INIT_DELAYED_WORK(&extcon_data->work, gpio_extcon_work);
 
extcon_data->irq = gpio_to_irq(extcon_data->gpio);
-   if (extcon_data->irq < 0) {
-   ret = extcon_data->irq;
-   goto err;
-   }
+   if (extcon_data->irq < 0)
+   return extcon_data->irq;
 
ret = request_any_context_irq(extcon_data->irq, gpio_irq_handler,
  pdata->irq_flags, pdev->name,
  extcon_data);
if (ret < 0)
-   goto err;
+   return ret;
 
platform_set_drvdata(pdev, extcon_data);
/* Perform initial detection */
gpio_extcon_work(&extcon_data->work.work);
 
return 0;
-
-err:
-   extcon_dev_unregister(&extcon_data->edev);
-
-   return ret;
 }
 
 static int gpio_extcon_remove(struct platform_device *pdev)
@@ -157,7 +150,6 @@ static int gpio_extcon_remove(struct platform_device *pdev)
 
cancel_delayed_work_sync(&extcon_data->work);
free_irq(extcon_data->irq, extcon_data);
-   extcon_dev_unregister(&extcon_data->edev);
 
return 0;
 }
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCHv4 1/8] extcon: Add resource-managed extcon register function

2014-04-21 Thread Sangjung Woo
Add resource-managed extcon device register function for convenience.
For example, if a extcon device is attached with new
devm_extcon_dev_register(), that extcon device is automatically
unregistered on driver detach.

Signed-off-by: Sangjung Woo 
---
 drivers/extcon/extcon-class.c |   64 +
 include/linux/extcon.h|   17 +++
 2 files changed, 81 insertions(+)

diff --git a/drivers/extcon/extcon-class.c b/drivers/extcon/extcon-class.c
index 7ab21aa..645b02b 100644
--- a/drivers/extcon/extcon-class.c
+++ b/drivers/extcon/extcon-class.c
@@ -819,6 +819,70 @@ void extcon_dev_unregister(struct extcon_dev *edev)
 }
 EXPORT_SYMBOL_GPL(extcon_dev_unregister);
 
+static void devm_extcon_dev_release(struct device *dev, void *res)
+{
+   extcon_dev_unregister((struct extcon_dev *)res);
+}
+
+static int devm_extcon_dev_match(struct device *dev, void *res, void *data)
+{
+   return res == data;
+}
+
+/**
+ * devm_extcon_dev_register() - Resource-managed extcon_dev_register()
+ * @dev:   device to allocate extcon device
+ * @edev:  the new extcon device to register
+ *
+ * Managed extcon_dev_register() function. If extcon device is attached with
+ * this function, that extcon device is automatically unregistered on driver
+ * detach. Internally this function calls extcon_dev_register() function.
+ * To get more information, refer that function.
+ *
+ * If extcon device is registered with this function and the device needs to be
+ * unregistered separately, devm_extcon_dev_unregister() should be used.
+ *
+ * RETURNS:
+ * 0 on success, negative error number on failure.
+ */
+int devm_extcon_dev_register(struct device *dev, struct extcon_dev *edev)
+{
+   struct extcon_dev **ptr;
+   int ret;
+
+   ptr = devres_alloc(devm_extcon_dev_release, sizeof(*ptr),
+   GFP_KERNEL);
+   if (!ptr)
+   return -ENOMEM;
+
+   ret = extcon_dev_register(edev);
+   if (ret) {
+   devres_free(ptr);
+   return ret;
+   }
+
+   *ptr = edev;
+   devres_add(dev, ptr);
+
+   return 0;
+}
+EXPORT_SYMBOL_GPL(devm_extcon_dev_register);
+
+/**
+ * devm_extcon_dev_unregister() - Resource-managed extcon_dev_unregister()
+ * @dev:   device the extcon belongs to
+ * @edev:  the extcon device to unregister
+ *
+ * Unregister extcon device that is registered with devm_extcon_dev_register()
+ * function.
+ */
+void devm_extcon_dev_unregister(struct device *dev, struct extcon_dev *edev)
+{
+   WARN_ON(devres_release(dev, devm_extcon_dev_release,
+   devm_extcon_dev_match, edev));
+}
+EXPORT_SYMBOL_GPL(devm_extcon_dev_unregister);
+
 #ifdef CONFIG_OF
 /*
  * extcon_get_edev_by_phandle - Get the extcon device from devicetree
diff --git a/include/linux/extcon.h b/include/linux/extcon.h
index f488145..6a17f69 100644
--- a/include/linux/extcon.h
+++ b/include/linux/extcon.h
@@ -188,6 +188,14 @@ extern void extcon_dev_unregister(struct extcon_dev *edev);
 extern struct extcon_dev *extcon_get_extcon_dev(const char *extcon_name);
 
 /*
+ * Resource-managed extcon device register function.
+ */
+extern int devm_extcon_dev_register(struct device *dev,
+   struct extcon_dev *edev);
+extern void devm_extcon_dev_unregister(struct device *dev,
+  struct extcon_dev *edev);
+
+/*
  * get/set/update_state access the 32b encoded state value, which represents
  * states of all possible cables of the multistate port. For example, if one
  * calls extcon_set_state(edev, 0x7), it may mean that all the three cables
@@ -254,6 +262,15 @@ static inline int extcon_dev_register(struct extcon_dev 
*edev)
 
 static inline void extcon_dev_unregister(struct extcon_dev *edev) { }
 
+static inline devm_extcon_dev_register(struct device *dev,
+  struct extcon_dev *edev)
+{
+   return 0;
+}
+
+static inline devm_extcon_dev_unregister(struct device *dev,
+struct extcon_dev *edev) { }
+
 static inline u32 extcon_get_state(struct extcon_dev *edev)
 {
return 0;
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCHv4 6/8] extcon: max8997: Use devm_extcon_dev_register()

2014-04-21 Thread Sangjung Woo
Use the resource-managed extcon device register function (i.e.
devm_extcon_dev_register()) instead of extcon_dev_register(). If extcon device
is attached with this function, that extcon device is automatically unregistered
on driver detach. That reduces tiresome managing code.

Signed-off-by: Sangjung Woo 
Reviewed-by: Krzysztof Kozlowski 
---
 drivers/extcon/extcon-max8997.c |4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/extcon/extcon-max8997.c b/drivers/extcon/extcon-max8997.c
index 223e6b0..804a446 100644
--- a/drivers/extcon/extcon-max8997.c
+++ b/drivers/extcon/extcon-max8997.c
@@ -709,7 +709,7 @@ static int max8997_muic_probe(struct platform_device *pdev)
info->edev->name = DEV_NAME;
info->edev->dev.parent = &pdev->dev;
info->edev->supported_cable = max8997_extcon_cable;
-   ret = extcon_dev_register(info->edev);
+   ret = devm_extcon_dev_register(&pdev->dev, info->edev);
if (ret) {
dev_err(&pdev->dev, "failed to register extcon device\n");
goto err_irq;
@@ -790,8 +790,6 @@ static int max8997_muic_remove(struct platform_device *pdev)
free_irq(muic_irqs[i].virq, info);
cancel_work_sync(&info->irq_work);
 
-   extcon_dev_unregister(info->edev);
-
return 0;
 }
 
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCHv4 7/8] extcon: palmas: Use devm_extcon_dev_register()

2014-04-21 Thread Sangjung Woo
Use the resource-managed extcon device register function (i.e.
devm_extcon_dev_register()) instead of extcon_dev_register(). If extcon device
is attached with this function, that extcon device is automatically unregistered
on driver detach. That reduces tiresome managing code.

Signed-off-by: Sangjung Woo 
---
 drivers/extcon/extcon-palmas.c |   15 +--
 1 file changed, 5 insertions(+), 10 deletions(-)

diff --git a/drivers/extcon/extcon-palmas.c b/drivers/extcon/extcon-palmas.c
index 51db5bc..1a770e0 100644
--- a/drivers/extcon/extcon-palmas.c
+++ b/drivers/extcon/extcon-palmas.c
@@ -192,7 +192,7 @@ static int palmas_usb_probe(struct platform_device *pdev)
palmas_usb->edev.name = kstrdup(node->name, GFP_KERNEL);
palmas_usb->edev.mutually_exclusive = mutually_exclusive;
 
-   status = extcon_dev_register(&palmas_usb->edev);
+   status = devm_extcon_dev_register(&pdev->dev, &palmas_usb->edev);
if (status) {
dev_err(&pdev->dev, "failed to register extcon device\n");
kfree(palmas_usb->edev.name);
@@ -209,7 +209,8 @@ static int palmas_usb_probe(struct platform_device *pdev)
if (status < 0) {
dev_err(&pdev->dev, "can't get IRQ %d, err %d\n",
palmas_usb->id_irq, status);
-   goto fail_extcon;
+   kfree(palmas_usb->edev.name);
+   return status;
}
}
 
@@ -223,26 +224,20 @@ static int palmas_usb_probe(struct platform_device *pdev)
if (status < 0) {
dev_err(&pdev->dev, "can't get IRQ %d, err %d\n",
palmas_usb->vbus_irq, status);
-   goto fail_extcon;
+   kfree(palmas_usb->edev.name);
+   return status;
}
}
 
palmas_enable_irq(palmas_usb);
device_set_wakeup_capable(&pdev->dev, true);
return 0;
-
-fail_extcon:
-   extcon_dev_unregister(&palmas_usb->edev);
-   kfree(palmas_usb->edev.name);
-
-   return status;
 }
 
 static int palmas_usb_remove(struct platform_device *pdev)
 {
struct palmas_usb *palmas_usb = platform_get_drvdata(pdev);
 
-   extcon_dev_unregister(&palmas_usb->edev);
kfree(palmas_usb->edev.name);
 
return 0;
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCHv4 4/8] extcon: max14577: Use devm_extcon_dev_register()

2014-04-21 Thread Sangjung Woo
Use the resource-managed extcon device register function (i.e.
devm_extcon_dev_register()) instead of extcon_dev_register(). If extcon device
is attached with this function, that extcon device is automatically unregistered
on driver detach. That reduces tiresome managing code.

Signed-off-by: Sangjung Woo 
Reviewed-by: Krzysztof Kozlowski 
---
 drivers/extcon/extcon-max14577.c |9 ++---
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/drivers/extcon/extcon-max14577.c b/drivers/extcon/extcon-max14577.c
index 1fef08d..c6166e7 100644
--- a/drivers/extcon/extcon-max14577.c
+++ b/drivers/extcon/extcon-max14577.c
@@ -675,7 +675,7 @@ static int max14577_muic_probe(struct platform_device *pdev)
}
info->edev->name = DEV_NAME;
info->edev->supported_cable = max14577_extcon_cable;
-   ret = extcon_dev_register(info->edev);
+   ret = devm_extcon_dev_register(&pdev->dev, info->edev);
if (ret) {
dev_err(&pdev->dev, "failed to register extcon device\n");
return ret;
@@ -694,7 +694,7 @@ static int max14577_muic_probe(struct platform_device *pdev)
MAX14577_REG_DEVICEID, &id);
if (ret < 0) {
dev_err(&pdev->dev, "failed to read revision number\n");
-   goto err_extcon;
+   return ret;
}
dev_info(info->dev, "device ID : 0x%x\n", id);
 
@@ -714,10 +714,6 @@ static int max14577_muic_probe(struct platform_device 
*pdev)
delay_jiffies);
 
return ret;
-
-err_extcon:
-   extcon_dev_unregister(info->edev);
-   return ret;
 }
 
 static int max14577_muic_remove(struct platform_device *pdev)
@@ -725,7 +721,6 @@ static int max14577_muic_remove(struct platform_device 
*pdev)
struct max14577_muic_info *info = platform_get_drvdata(pdev);
 
cancel_work_sync(&info->irq_work);
-   extcon_dev_unregister(info->edev);
 
return 0;
 }
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCHv4 8/8] extcon: arizona: Use devm_extcon_dev_register()

2014-04-21 Thread Sangjung Woo
Use the resource-managed extcon device register function (i.e.
devm_extcon_dev_register()) instead of extcon_dev_register(). If extcon device
is attached with this function, that extcon device is automatically unregistered
on driver detach. That reduces tiresome managing code.

Signed-off-by: Sangjung Woo 
---
 drivers/extcon/extcon-arizona.c |   12 
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/extcon/extcon-arizona.c b/drivers/extcon/extcon-arizona.c
index 98a14f6..f63fa6f 100644
--- a/drivers/extcon/extcon-arizona.c
+++ b/drivers/extcon/extcon-arizona.c
@@ -1105,15 +1105,14 @@ static int arizona_extcon_probe(struct platform_device 
*pdev)
info = devm_kzalloc(&pdev->dev, sizeof(*info), GFP_KERNEL);
if (!info) {
dev_err(&pdev->dev, "Failed to allocate memory\n");
-   ret = -ENOMEM;
-   goto err;
+   return -ENOMEM;
}
 
info->micvdd = devm_regulator_get(arizona->dev, "MICVDD");
if (IS_ERR(info->micvdd)) {
ret = PTR_ERR(info->micvdd);
dev_err(arizona->dev, "Failed to get MICVDD: %d\n", ret);
-   goto err;
+   return ret;
}
 
mutex_init(&info->lock);
@@ -1155,11 +1154,11 @@ static int arizona_extcon_probe(struct platform_device 
*pdev)
info->edev.dev.parent = arizona->dev;
info->edev.supported_cable = arizona_cable;
 
-   ret = extcon_dev_register(&info->edev);
+   ret = devm_extcon_dev_register(&pdev->dev, &info->edev);
if (ret < 0) {
dev_err(arizona->dev, "extcon_dev_register() failed: %d\n",
ret);
-   goto err;
+   return ret;
}
 
info->input = devm_input_allocate_device(&pdev->dev);
@@ -1410,8 +1409,6 @@ err_rise:
 err_input:
 err_register:
pm_runtime_disable(&pdev->dev);
-   extcon_dev_unregister(&info->edev);
-err:
return ret;
 }
 
@@ -1445,7 +1442,6 @@ static int arizona_extcon_remove(struct platform_device 
*pdev)
regmap_update_bits(arizona->regmap, ARIZONA_JACK_DETECT_ANALOGUE,
   ARIZONA_JD1_ENA, 0);
arizona_clk32k_disable(arizona);
-   extcon_dev_unregister(&info->edev);
 
return 0;
 }
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCHv4 0/8] Resource-managed extcon device register function

2014-04-21 Thread Sangjung Woo
These patches add resource-managed extcon device register functions for
developers' convenience and apply them to related device driver files.
This work can make the code more tidy since extcon device is automatically
unregistered on driver detach so tiresome managing codes could be removed.


Changelog

v4:
* fix the memory leak bug becuase of single pointer
* clean up the unnecessary code and make proper indentation

v3:
* send the right version instead of previous v1
* add the credit for reviewers according to the review rules

v2:
* modify and clean up all unnecessary code reported by Chanwoo
* fix the bug reported by Seung-Woo
* add the credit for reviewers

v1:
* initial version

Sangjung Woo (8):
  extcon: Add resource-managed extcon register function
  extcon: adc-jack: Use devm_extcon_dev_register()
  extcon: gpio: Use devm_extcon_dev_register()
  extcon: max14577: Use devm_extcon_dev_register()
  extcon: max77693: Use devm_extcon_dev_register()
  extcon: max8997: Use devm_extcon_dev_register()
  extcon: palmas: Use devm_extcon_dev_register()
  extcon: arizona: Use devm_extcon_dev_register()

 drivers/extcon/extcon-adc-jack.c |   30 ++
 drivers/extcon/extcon-arizona.c  |   12 +++
 drivers/extcon/extcon-class.c|   64 ++
 drivers/extcon/extcon-gpio.c |   16 +++---
 drivers/extcon/extcon-max14577.c |9 ++
 drivers/extcon/extcon-max77693.c |7 ++---
 drivers/extcon/extcon-max8997.c  |4 +--
 drivers/extcon/extcon-palmas.c   |   15 +++--
 include/linux/extcon.h   |   17 ++
 9 files changed, 108 insertions(+), 66 deletions(-)

-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCHv4 5/8] extcon: max77693: Use devm_extcon_dev_register()

2014-04-21 Thread Sangjung Woo
Use the resource-managed extcon device register function (i.e.
devm_extcon_dev_register()) instead of extcon_dev_register(). If extcon device
is attached with this function, that extcon device is automatically unregistered
on driver detach. That reduces tiresome managing code.

Signed-off-by: Sangjung Woo 
Reviewed-by: Krzysztof Kozlowski 
---
 drivers/extcon/extcon-max77693.c |7 ++-
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/extcon/extcon-max77693.c b/drivers/extcon/extcon-max77693.c
index 39cd095..f0f18e2 100644
--- a/drivers/extcon/extcon-max77693.c
+++ b/drivers/extcon/extcon-max77693.c
@@ -1185,7 +1185,7 @@ static int max77693_muic_probe(struct platform_device 
*pdev)
info->edev->name = DEV_NAME;
info->edev->dev.parent = &pdev->dev;
info->edev->supported_cable = max77693_extcon_cable;
-   ret = extcon_dev_register(info->edev);
+   ret = devm_extcon_dev_register(&pdev->dev, info->edev);
if (ret) {
dev_err(&pdev->dev, "failed to register extcon device\n");
goto err_irq;
@@ -1267,7 +1267,7 @@ static int max77693_muic_probe(struct platform_device 
*pdev)
MAX77693_MUIC_REG_ID, &id);
if (ret < 0) {
dev_err(&pdev->dev, "failed to read revision number\n");
-   goto err_extcon;
+   goto err_irq;
}
dev_info(info->dev, "device ID : 0x%x\n", id);
 
@@ -1288,8 +1288,6 @@ static int max77693_muic_probe(struct platform_device 
*pdev)
 
return ret;
 
-err_extcon:
-   extcon_dev_unregister(info->edev);
 err_irq:
while (--i >= 0)
free_irq(muic_irqs[i].virq, info);
@@ -1305,7 +1303,6 @@ static int max77693_muic_remove(struct platform_device 
*pdev)
free_irq(muic_irqs[i].virq, info);
cancel_work_sync(&info->irq_work);
input_unregister_device(info->dock);
-   extcon_dev_unregister(info->edev);
 
return 0;
 }
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCHv3 3/8] extcon: gpio: Use devm_extcon_dev_register()

2014-04-17 Thread Sangjung Woo
Use the resource-managed extcon device register function (i.e.
devm_extcon_dev_register()) instead of extcon_dev_register(). If extcon device
is attached with this function, that extcon device is automatically unregistered
on driver detach. That reduces tiresome managing code.

Signed-off-by: Sangjung Woo 
---
 drivers/extcon/extcon-gpio.c |   16 
 1 file changed, 4 insertions(+), 12 deletions(-)

diff --git a/drivers/extcon/extcon-gpio.c b/drivers/extcon/extcon-gpio.c
index 13d5222..43af34c 100644
--- a/drivers/extcon/extcon-gpio.c
+++ b/drivers/extcon/extcon-gpio.c
@@ -121,34 +121,27 @@ static int gpio_extcon_probe(struct platform_device *pdev)
msecs_to_jiffies(pdata->debounce);
}
 
-   ret = extcon_dev_register(&extcon_data->edev);
+   ret = devm_extcon_dev_register(&pdev->dev, &extcon_data->edev);
if (ret < 0)
return ret;
 
INIT_DELAYED_WORK(&extcon_data->work, gpio_extcon_work);
 
extcon_data->irq = gpio_to_irq(extcon_data->gpio);
-   if (extcon_data->irq < 0) {
-   ret = extcon_data->irq;
-   goto err;
-   }
+   if (extcon_data->irq < 0)
+   return extcon_data->irq;
 
ret = request_any_context_irq(extcon_data->irq, gpio_irq_handler,
  pdata->irq_flags, pdev->name,
  extcon_data);
if (ret < 0)
-   goto err;
+   return ret;
 
platform_set_drvdata(pdev, extcon_data);
/* Perform initial detection */
gpio_extcon_work(&extcon_data->work.work);
 
return 0;
-
-err:
-   extcon_dev_unregister(&extcon_data->edev);
-
-   return ret;
 }
 
 static int gpio_extcon_remove(struct platform_device *pdev)
@@ -157,7 +150,6 @@ static int gpio_extcon_remove(struct platform_device *pdev)
 
cancel_delayed_work_sync(&extcon_data->work);
free_irq(extcon_data->irq, extcon_data);
-   extcon_dev_unregister(&extcon_data->edev);
 
return 0;
 }
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCHv3 4/8] extcon: max14577: Use devm_extcon_dev_register()

2014-04-17 Thread Sangjung Woo
Use the resource-managed extcon device register function (i.e.
devm_extcon_dev_register()) instead of extcon_dev_register(). If extcon device
is attached with this function, that extcon device is automatically unregistered
on driver detach. That reduces tiresome managing code.

Signed-off-by: Sangjung Woo 
Reviewed-by: Krzysztof Kozlowski 
---
 drivers/extcon/extcon-max14577.c |9 ++---
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/drivers/extcon/extcon-max14577.c b/drivers/extcon/extcon-max14577.c
index 1fef08d..c6166e7 100644
--- a/drivers/extcon/extcon-max14577.c
+++ b/drivers/extcon/extcon-max14577.c
@@ -675,7 +675,7 @@ static int max14577_muic_probe(struct platform_device *pdev)
}
info->edev->name = DEV_NAME;
info->edev->supported_cable = max14577_extcon_cable;
-   ret = extcon_dev_register(info->edev);
+   ret = devm_extcon_dev_register(&pdev->dev, info->edev);
if (ret) {
dev_err(&pdev->dev, "failed to register extcon device\n");
return ret;
@@ -694,7 +694,7 @@ static int max14577_muic_probe(struct platform_device *pdev)
MAX14577_REG_DEVICEID, &id);
if (ret < 0) {
dev_err(&pdev->dev, "failed to read revision number\n");
-   goto err_extcon;
+   return ret;
}
dev_info(info->dev, "device ID : 0x%x\n", id);
 
@@ -714,10 +714,6 @@ static int max14577_muic_probe(struct platform_device 
*pdev)
delay_jiffies);
 
return ret;
-
-err_extcon:
-   extcon_dev_unregister(info->edev);
-   return ret;
 }
 
 static int max14577_muic_remove(struct platform_device *pdev)
@@ -725,7 +721,6 @@ static int max14577_muic_remove(struct platform_device 
*pdev)
struct max14577_muic_info *info = platform_get_drvdata(pdev);
 
cancel_work_sync(&info->irq_work);
-   extcon_dev_unregister(info->edev);
 
return 0;
 }
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCHv3 6/8] extcon: max8997: Use devm_extcon_dev_register()

2014-04-17 Thread Sangjung Woo
Use the resource-managed extcon device register function (i.e.
devm_extcon_dev_register()) instead of extcon_dev_register(). If extcon device
is attached with this function, that extcon device is automatically unregistered
on driver detach. That reduces tiresome managing code.

Signed-off-by: Sangjung Woo 
Reviewed-by: Krzysztof Kozlowski 
---
 drivers/extcon/extcon-max8997.c |4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/extcon/extcon-max8997.c b/drivers/extcon/extcon-max8997.c
index 223e6b0..804a446 100644
--- a/drivers/extcon/extcon-max8997.c
+++ b/drivers/extcon/extcon-max8997.c
@@ -709,7 +709,7 @@ static int max8997_muic_probe(struct platform_device *pdev)
info->edev->name = DEV_NAME;
info->edev->dev.parent = &pdev->dev;
info->edev->supported_cable = max8997_extcon_cable;
-   ret = extcon_dev_register(info->edev);
+   ret = devm_extcon_dev_register(&pdev->dev, info->edev);
if (ret) {
dev_err(&pdev->dev, "failed to register extcon device\n");
goto err_irq;
@@ -790,8 +790,6 @@ static int max8997_muic_remove(struct platform_device *pdev)
free_irq(muic_irqs[i].virq, info);
cancel_work_sync(&info->irq_work);
 
-   extcon_dev_unregister(info->edev);
-
return 0;
 }
 
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCHv3 5/8] extcon: max77693: Use devm_extcon_dev_register()

2014-04-17 Thread Sangjung Woo
Use the resource-managed extcon device register function (i.e.
devm_extcon_dev_register()) instead of extcon_dev_register(). If extcon device
is attached with this function, that extcon device is automatically unregistered
on driver detach. That reduces tiresome managing code.

Signed-off-by: Sangjung Woo 
Reviewed-by: Krzysztof Kozlowski 
---
 drivers/extcon/extcon-max77693.c |7 ++-
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/extcon/extcon-max77693.c b/drivers/extcon/extcon-max77693.c
index 39cd095..f0f18e2 100644
--- a/drivers/extcon/extcon-max77693.c
+++ b/drivers/extcon/extcon-max77693.c
@@ -1185,7 +1185,7 @@ static int max77693_muic_probe(struct platform_device 
*pdev)
info->edev->name = DEV_NAME;
info->edev->dev.parent = &pdev->dev;
info->edev->supported_cable = max77693_extcon_cable;
-   ret = extcon_dev_register(info->edev);
+   ret = devm_extcon_dev_register(&pdev->dev, info->edev);
if (ret) {
dev_err(&pdev->dev, "failed to register extcon device\n");
goto err_irq;
@@ -1267,7 +1267,7 @@ static int max77693_muic_probe(struct platform_device 
*pdev)
MAX77693_MUIC_REG_ID, &id);
if (ret < 0) {
dev_err(&pdev->dev, "failed to read revision number\n");
-   goto err_extcon;
+   goto err_irq;
}
dev_info(info->dev, "device ID : 0x%x\n", id);
 
@@ -1288,8 +1288,6 @@ static int max77693_muic_probe(struct platform_device 
*pdev)
 
return ret;
 
-err_extcon:
-   extcon_dev_unregister(info->edev);
 err_irq:
while (--i >= 0)
free_irq(muic_irqs[i].virq, info);
@@ -1305,7 +1303,6 @@ static int max77693_muic_remove(struct platform_device 
*pdev)
free_irq(muic_irqs[i].virq, info);
cancel_work_sync(&info->irq_work);
input_unregister_device(info->dock);
-   extcon_dev_unregister(info->edev);
 
return 0;
 }
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCHv3 0/8] Resource-managed extcon device register function

2014-04-17 Thread Sangjung Woo
These patches add resource-managed extcon device register functions for
developers' convenience and apply them to related device driver files.
This work can make the code more tidy since extcon device is automatically
unregistered on driver detach so tiresome managing codes could be removed.


Changelog:

v3:
* send the right version instead of previous v1
* add the credit for reviewers according to the review rules

v2:
* modify and clean up all unnecessary code reported by Chanwoo
* fix the bug reported by Seung-Woo
* add the credit for reviewers

v1:
* initial version

Sangjung Woo (8):
  extcon: Add resource-managed extcon register function
  extcon: adc-jack: Use devm_extcon_dev_register()
  extcon: gpio: Use devm_extcon_dev_register()
  extcon: max14577: Use devm_extcon_dev_register()
  extcon: max77693: Use devm_extcon_dev_register()
  extcon: max8997: Use devm_extcon_dev_register()
  extcon: palmas: Use devm_extcon_dev_register()
  extcon: arizona: Use devm_extcon_dev_register()

 drivers/extcon/extcon-adc-jack.c |   30 +---
 drivers/extcon/extcon-arizona.c  |   12 +++
 drivers/extcon/extcon-class.c|   72 ++
 drivers/extcon/extcon-gpio.c |   16 +++--
 drivers/extcon/extcon-max14577.c |9 ++---
 drivers/extcon/extcon-max77693.c |7 ++--
 drivers/extcon/extcon-max8997.c  |4 +--
 drivers/extcon/extcon-palmas.c   |   15 +++-
 include/linux/extcon.h   |   17 +
 9 files changed, 116 insertions(+), 66 deletions(-)

-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCHv3 1/8] extcon: Add resource-managed extcon register function

2014-04-17 Thread Sangjung Woo
Add resource-managed extcon device register function for convenience.
For example, if a extcon device is attached with new
devm_extcon_dev_register(), that extcon device is automatically
unregistered on driver detach.

Signed-off-by: Sangjung Woo 
---
 drivers/extcon/extcon-class.c |   72 +
 include/linux/extcon.h|   17 ++
 2 files changed, 89 insertions(+)

diff --git a/drivers/extcon/extcon-class.c b/drivers/extcon/extcon-class.c
index 7ab21aa..e177edb6 100644
--- a/drivers/extcon/extcon-class.c
+++ b/drivers/extcon/extcon-class.c
@@ -819,6 +819,78 @@ void extcon_dev_unregister(struct extcon_dev *edev)
 }
 EXPORT_SYMBOL_GPL(extcon_dev_unregister);
 
+
+/*
+ * Device resource management
+ */
+static void devm_extcon_dev_release(struct device *dev, void *res)
+{
+   struct extcon_dev *devres = res;
+
+   extcon_dev_unregister(devres);
+}
+
+static int devm_extcon_dev_match(struct device *dev, void *res, void *data)
+{
+   struct extcon_dev *devres = res;
+   struct extcon_dev *match = data;
+   return devres == match;
+}
+
+/**
+ * devm_extcon_dev_register() - Resource-managed extcon_dev_register()
+ * @dev:   device to allocate extcon device
+ * @edev:  the new extcon device to register
+ *
+ * Managed extcon_dev_register() function. If extcon device is attached with
+ * this function, that extcon device is automatically unregistered on driver
+ * detach. Internally this function calls extcon_dev_register() function.
+ * To get more information, refer that function.
+ *
+ * If extcon device is registered with this function and the device needs to be
+ * unregistered separately, devm_extcon_dev_unregister() should be used.
+ *
+ * RETURNS:
+ * 0 on success, negative error number on failure.
+ */
+int devm_extcon_dev_register(struct device *dev, struct extcon_dev *edev)
+{
+   struct extcon_dev *devres;
+   int ret;
+
+   devres = devres_alloc(devm_extcon_dev_release, sizeof(*devres),
+   GFP_KERNEL);
+   if (!devres)
+   return -ENOMEM;
+
+   ret = extcon_dev_register(edev);
+   if (ret) {
+   devres_free(devres);
+   return ret;
+   }
+
+   devres = edev;
+   devres_add(dev, devres);
+
+   return 0;
+}
+EXPORT_SYMBOL_GPL(devm_extcon_dev_register);
+
+/**
+ * devm_extcon_dev_unregister() - Resource-managed extcon_dev_unregister()
+ * @dev:   device the extcon belongs to
+ * @edev:  the extcon device to unregister
+ *
+ * Unregister extcon device that is registered with devm_extcon_dev_register()
+ * function.
+ */
+void devm_extcon_dev_unregister(struct device *dev, struct extcon_dev *edev)
+{
+   WARN_ON(devres_release(dev, devm_extcon_dev_release,
+   devm_extcon_dev_match, edev));
+}
+EXPORT_SYMBOL_GPL(devm_extcon_dev_unregister);
+
 #ifdef CONFIG_OF
 /*
  * extcon_get_edev_by_phandle - Get the extcon device from devicetree
diff --git a/include/linux/extcon.h b/include/linux/extcon.h
index f488145..35f3343 100644
--- a/include/linux/extcon.h
+++ b/include/linux/extcon.h
@@ -188,6 +188,14 @@ extern void extcon_dev_unregister(struct extcon_dev *edev);
 extern struct extcon_dev *extcon_get_extcon_dev(const char *extcon_name);
 
 /*
+ * Resource-managed extcon device register function.
+ */
+extern int devm_extcon_dev_register(struct device *dev,
+   struct extcon_dev *edev);
+extern void devm_extcon_dev_unregister(struct device *dev,
+   struct extcon_dev *edev);
+
+/*
  * get/set/update_state access the 32b encoded state value, which represents
  * states of all possible cables of the multistate port. For example, if one
  * calls extcon_set_state(edev, 0x7), it may mean that all the three cables
@@ -254,6 +262,15 @@ static inline int extcon_dev_register(struct extcon_dev 
*edev)
 
 static inline void extcon_dev_unregister(struct extcon_dev *edev) { }
 
+static inline devm_extcon_dev_register(struct device *dev,
+   struct extcon_dev *edev)
+{
+   return 0;
+}
+
+static inline devm_extcon_dev_unregister(struct device *dev,
+   struct extcon_dev *edev) { }
+
 static inline u32 extcon_get_state(struct extcon_dev *edev)
 {
return 0;
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCHv3 7/8] extcon: palmas: Use devm_extcon_dev_register()

2014-04-17 Thread Sangjung Woo
Use the resource-managed extcon device register function (i.e.
devm_extcon_dev_register()) instead of extcon_dev_register(). If extcon device
is attached with this function, that extcon device is automatically unregistered
on driver detach. That reduces tiresome managing code.

Signed-off-by: Sangjung Woo 
---
 drivers/extcon/extcon-palmas.c |   15 +--
 1 file changed, 5 insertions(+), 10 deletions(-)

diff --git a/drivers/extcon/extcon-palmas.c b/drivers/extcon/extcon-palmas.c
index 51db5bc..1a770e0 100644
--- a/drivers/extcon/extcon-palmas.c
+++ b/drivers/extcon/extcon-palmas.c
@@ -192,7 +192,7 @@ static int palmas_usb_probe(struct platform_device *pdev)
palmas_usb->edev.name = kstrdup(node->name, GFP_KERNEL);
palmas_usb->edev.mutually_exclusive = mutually_exclusive;
 
-   status = extcon_dev_register(&palmas_usb->edev);
+   status = devm_extcon_dev_register(&pdev->dev, &palmas_usb->edev);
if (status) {
dev_err(&pdev->dev, "failed to register extcon device\n");
kfree(palmas_usb->edev.name);
@@ -209,7 +209,8 @@ static int palmas_usb_probe(struct platform_device *pdev)
if (status < 0) {
dev_err(&pdev->dev, "can't get IRQ %d, err %d\n",
palmas_usb->id_irq, status);
-   goto fail_extcon;
+   kfree(palmas_usb->edev.name);
+   return status;
}
}
 
@@ -223,26 +224,20 @@ static int palmas_usb_probe(struct platform_device *pdev)
if (status < 0) {
dev_err(&pdev->dev, "can't get IRQ %d, err %d\n",
palmas_usb->vbus_irq, status);
-   goto fail_extcon;
+   kfree(palmas_usb->edev.name);
+   return status;
}
}
 
palmas_enable_irq(palmas_usb);
device_set_wakeup_capable(&pdev->dev, true);
return 0;
-
-fail_extcon:
-   extcon_dev_unregister(&palmas_usb->edev);
-   kfree(palmas_usb->edev.name);
-
-   return status;
 }
 
 static int palmas_usb_remove(struct platform_device *pdev)
 {
struct palmas_usb *palmas_usb = platform_get_drvdata(pdev);
 
-   extcon_dev_unregister(&palmas_usb->edev);
kfree(palmas_usb->edev.name);
 
return 0;
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCHv3 8/8] extcon: arizona: Use devm_extcon_dev_register()

2014-04-17 Thread Sangjung Woo
Use the resource-managed extcon device register function (i.e.
devm_extcon_dev_register()) instead of extcon_dev_register(). If extcon device
is attached with this function, that extcon device is automatically unregistered
on driver detach. That reduces tiresome managing code.

Signed-off-by: Sangjung Woo 
---
 drivers/extcon/extcon-arizona.c |   12 
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/extcon/extcon-arizona.c b/drivers/extcon/extcon-arizona.c
index 98a14f6..f63fa6f 100644
--- a/drivers/extcon/extcon-arizona.c
+++ b/drivers/extcon/extcon-arizona.c
@@ -1105,15 +1105,14 @@ static int arizona_extcon_probe(struct platform_device 
*pdev)
info = devm_kzalloc(&pdev->dev, sizeof(*info), GFP_KERNEL);
if (!info) {
dev_err(&pdev->dev, "Failed to allocate memory\n");
-   ret = -ENOMEM;
-   goto err;
+   return -ENOMEM;
}
 
info->micvdd = devm_regulator_get(arizona->dev, "MICVDD");
if (IS_ERR(info->micvdd)) {
ret = PTR_ERR(info->micvdd);
dev_err(arizona->dev, "Failed to get MICVDD: %d\n", ret);
-   goto err;
+   return ret;
}
 
mutex_init(&info->lock);
@@ -1155,11 +1154,11 @@ static int arizona_extcon_probe(struct platform_device 
*pdev)
info->edev.dev.parent = arizona->dev;
info->edev.supported_cable = arizona_cable;
 
-   ret = extcon_dev_register(&info->edev);
+   ret = devm_extcon_dev_register(&pdev->dev, &info->edev);
if (ret < 0) {
dev_err(arizona->dev, "extcon_dev_register() failed: %d\n",
ret);
-   goto err;
+   return ret;
}
 
info->input = devm_input_allocate_device(&pdev->dev);
@@ -1410,8 +1409,6 @@ err_rise:
 err_input:
 err_register:
pm_runtime_disable(&pdev->dev);
-   extcon_dev_unregister(&info->edev);
-err:
return ret;
 }
 
@@ -1445,7 +1442,6 @@ static int arizona_extcon_remove(struct platform_device 
*pdev)
regmap_update_bits(arizona->regmap, ARIZONA_JACK_DETECT_ANALOGUE,
   ARIZONA_JD1_ENA, 0);
arizona_clk32k_disable(arizona);
-   extcon_dev_unregister(&info->edev);
 
return 0;
 }
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCHv3 2/8] extcon: adc-jack: Use devm_extcon_dev_register()

2014-04-17 Thread Sangjung Woo
Use the resource-managed extcon device register function (i.e.
devm_extcon_dev_register()) instead of extcon_dev_register(). If extcon device
is attached with this function, that extcon device is automatically unregistered
on driver detach. That reduces tiresome managing code.

Signed-off-by: Sangjung Woo 
---
 drivers/extcon/extcon-adc-jack.c |   30 +-
 1 file changed, 9 insertions(+), 21 deletions(-)

diff --git a/drivers/extcon/extcon-adc-jack.c b/drivers/extcon/extcon-adc-jack.c
index e23f1c2..549d820 100644
--- a/drivers/extcon/extcon-adc-jack.c
+++ b/drivers/extcon/extcon-adc-jack.c
@@ -105,9 +105,8 @@ static int adc_jack_probe(struct platform_device *pdev)
data->edev.name = pdata->name;
 
if (!pdata->cable_names) {
-   err = -EINVAL;
dev_err(&pdev->dev, "error: cable_names not defined.\n");
-   goto out;
+   return -EINVAL;
}
 
data->edev.dev.parent = &pdev->dev;
@@ -117,18 +116,16 @@ static int adc_jack_probe(struct platform_device *pdev)
for (i = 0; data->edev.supported_cable[i]; i++)
;
if (i == 0 || i > SUPPORTED_CABLE_MAX) {
-   err = -EINVAL;
dev_err(&pdev->dev, "error: pdata->cable_names size = %d\n",
i - 1);
-   goto out;
+   return -EINVAL;
}
data->num_cables = i;
 
if (!pdata->adc_conditions ||
!pdata->adc_conditions[0].state) {
-   err = -EINVAL;
dev_err(&pdev->dev, "error: adc_conditions not defined.\n");
-   goto out;
+   return -EINVAL;
}
data->adc_conditions = pdata->adc_conditions;
 
@@ -138,10 +135,8 @@ static int adc_jack_probe(struct platform_device *pdev)
data->num_conditions = i;
 
data->chan = iio_channel_get(&pdev->dev, pdata->consumer_channel);
-   if (IS_ERR(data->chan)) {
-   err = PTR_ERR(data->chan);
-   goto out;
-   }
+   if (IS_ERR(data->chan))
+   return PTR_ERR(data->chan);
 
data->handling_delay = msecs_to_jiffies(pdata->handling_delay_ms);
 
@@ -149,15 +144,14 @@ static int adc_jack_probe(struct platform_device *pdev)
 
platform_set_drvdata(pdev, data);
 
-   err = extcon_dev_register(&data->edev);
+   err = devm_extcon_dev_register(&pdev->dev, &data->edev);
if (err)
-   goto out;
+   return err;
 
data->irq = platform_get_irq(pdev, 0);
if (!data->irq) {
dev_err(&pdev->dev, "platform_get_irq failed\n");
-   err = -ENODEV;
-   goto err_irq;
+   return -ENODEV;
}
 
err = request_any_context_irq(data->irq, adc_jack_irq_thread,
@@ -165,15 +159,10 @@ static int adc_jack_probe(struct platform_device *pdev)
 
if (err < 0) {
dev_err(&pdev->dev, "error: irq %d\n", data->irq);
-   goto err_irq;
+   return err;
}
 
return 0;
-
-err_irq:
-   extcon_dev_unregister(&data->edev);
-out:
-   return err;
 }
 
 static int adc_jack_remove(struct platform_device *pdev)
@@ -182,7 +171,6 @@ static int adc_jack_remove(struct platform_device *pdev)
 
free_irq(data->irq, data);
cancel_work_sync(&data->handler.work);
-   extcon_dev_unregister(&data->edev);
 
return 0;
 }
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCHv2 1/8] extcon: Add resource-managed extcon register function

2014-04-17 Thread Sangjung Woo
Add resource-managed extcon device register function for convenience.
For example, if a extcon device is attached with new
devm_extcon_dev_register(), that extcon device is automatically
unregistered on driver detach.

Signed-off-by: Sangjung Woo 
---
 drivers/extcon/extcon-class.c |   83 +
 include/linux/extcon.h|8 
 2 files changed, 91 insertions(+)

diff --git a/drivers/extcon/extcon-class.c b/drivers/extcon/extcon-class.c
index 7ab21aa..accb49c 100644
--- a/drivers/extcon/extcon-class.c
+++ b/drivers/extcon/extcon-class.c
@@ -32,6 +32,7 @@
 #include 
 #include 
 #include 
+#include 
 
 /*
  * extcon_cable_name suggests the standard cable names for commonly used
@@ -819,6 +820,88 @@ void extcon_dev_unregister(struct extcon_dev *edev)
 }
 EXPORT_SYMBOL_GPL(extcon_dev_unregister);
 
+
+/*
+ * Device resource management
+ */
+
+struct extcon_devres {
+   struct extcon_dev *edev;
+};
+
+static void devm_extcon_release(struct device *dev, void *res)
+{
+   struct extcon_devres *dr = (struct extcon_devres *)res;
+
+   extcon_dev_unregister(dr->edev);
+}
+
+static int devm_extcon_match(struct device *dev, void *res, void *data)
+{
+   struct extcon_devres *dr = (struct extcon_devres *)res;
+   struct extcon_devres *match = (struct extcon_devres *)data;
+
+   return dr->edev == match->edev;
+}
+
+/**
+ * devm_extcon_dev_register() - Resource-managed extcon_dev_register()
+ * @dev:   device to allocate extcon device
+ * @edev:  the new extcon device to register
+ *
+ * Managed extcon_dev_register() function. If extcon device is attached with
+ * this function, that extcon device is automatically unregistered on driver
+ * detach. Internally this function calls extcon_dev_register() function.
+ * To get more information, refer that function.
+ *
+ * If extcon device is registered with this function and the device needs to be
+ * unregistered separately, devm_extcon_dev_unregister() should be used.
+ *
+ * RETURNS:
+ * 0 on success, negative error number on failure.
+ */
+int devm_extcon_dev_register(struct device *dev, struct extcon_dev *edev)
+{
+   struct extcon_devres *dr;
+   int rc;
+
+   dr = devres_alloc(devm_extcon_release, sizeof(struct extcon_devres),
+   GFP_KERNEL);
+   if (!dr)
+   return -ENOMEM;
+
+   rc = extcon_dev_register(edev);
+   if (rc) {
+   devres_free(dr);
+   return rc;
+   }
+
+   dr->edev = edev;
+   devres_add(dev, dr);
+
+   return 0;
+}
+EXPORT_SYMBOL_GPL(devm_extcon_dev_register);
+
+/**
+ * devm_extcon_dev_unregister() - Resource-managed extcon_dev_unregister()
+ * @dev:   device the extcon belongs to
+ * @edev:  the extcon device to unregister
+ *
+ * Unregister extcon device that is registered with devm_extcon_dev_register()
+ * function.
+ */
+void devm_extcon_dev_unregister(struct device *dev, struct extcon_dev *edev)
+{
+   struct extcon_devres match_dr = { edev };
+
+   WARN_ON(devres_destroy(dev, devm_extcon_release,
+   devm_extcon_match, &match_dr));
+
+   extcon_dev_unregister(edev);
+}
+EXPORT_SYMBOL_GPL(devm_extcon_dev_unregister);
+
 #ifdef CONFIG_OF
 /*
  * extcon_get_edev_by_phandle - Get the extcon device from devicetree
diff --git a/include/linux/extcon.h b/include/linux/extcon.h
index f488145..e1e85a1 100644
--- a/include/linux/extcon.h
+++ b/include/linux/extcon.h
@@ -188,6 +188,14 @@ extern void extcon_dev_unregister(struct extcon_dev *edev);
 extern struct extcon_dev *extcon_get_extcon_dev(const char *extcon_name);
 
 /*
+ * Resource-managed extcon device register function.
+ */
+extern int devm_extcon_dev_register(struct device *dev,
+   struct extcon_dev *edev);
+extern void devm_extcon_dev_unregister(struct device *dev,
+   struct extcon_dev *edev);
+
+/*
  * get/set/update_state access the 32b encoded state value, which represents
  * states of all possible cables of the multistate port. For example, if one
  * calls extcon_set_state(edev, 0x7), it may mean that all the three cables
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCHv2 2/8] extcon: adc-jack: Use devm_extcon_dev_register()

2014-04-17 Thread Sangjung Woo
Use the resource-managed extcon device register function (i.e.
devm_extcon_dev_register()) instead of extcon_dev_register(). If extcon device
is attached with this function, that extcon device is automatically unregistered
on driver detach. That reduces tiresome managing code.

Signed-off-by: Sangjung Woo 
---
 drivers/extcon/extcon-adc-jack.c |   30 +-
 1 file changed, 9 insertions(+), 21 deletions(-)

diff --git a/drivers/extcon/extcon-adc-jack.c b/drivers/extcon/extcon-adc-jack.c
index e23f1c2..549d820 100644
--- a/drivers/extcon/extcon-adc-jack.c
+++ b/drivers/extcon/extcon-adc-jack.c
@@ -105,9 +105,8 @@ static int adc_jack_probe(struct platform_device *pdev)
data->edev.name = pdata->name;
 
if (!pdata->cable_names) {
-   err = -EINVAL;
dev_err(&pdev->dev, "error: cable_names not defined.\n");
-   goto out;
+   return -EINVAL;
}
 
data->edev.dev.parent = &pdev->dev;
@@ -117,18 +116,16 @@ static int adc_jack_probe(struct platform_device *pdev)
for (i = 0; data->edev.supported_cable[i]; i++)
;
if (i == 0 || i > SUPPORTED_CABLE_MAX) {
-   err = -EINVAL;
dev_err(&pdev->dev, "error: pdata->cable_names size = %d\n",
i - 1);
-   goto out;
+   return -EINVAL;
}
data->num_cables = i;
 
if (!pdata->adc_conditions ||
!pdata->adc_conditions[0].state) {
-   err = -EINVAL;
dev_err(&pdev->dev, "error: adc_conditions not defined.\n");
-   goto out;
+   return -EINVAL;
}
data->adc_conditions = pdata->adc_conditions;
 
@@ -138,10 +135,8 @@ static int adc_jack_probe(struct platform_device *pdev)
data->num_conditions = i;
 
data->chan = iio_channel_get(&pdev->dev, pdata->consumer_channel);
-   if (IS_ERR(data->chan)) {
-   err = PTR_ERR(data->chan);
-   goto out;
-   }
+   if (IS_ERR(data->chan))
+   return PTR_ERR(data->chan);
 
data->handling_delay = msecs_to_jiffies(pdata->handling_delay_ms);
 
@@ -149,15 +144,14 @@ static int adc_jack_probe(struct platform_device *pdev)
 
platform_set_drvdata(pdev, data);
 
-   err = extcon_dev_register(&data->edev);
+   err = devm_extcon_dev_register(&pdev->dev, &data->edev);
if (err)
-   goto out;
+   return err;
 
data->irq = platform_get_irq(pdev, 0);
if (!data->irq) {
dev_err(&pdev->dev, "platform_get_irq failed\n");
-   err = -ENODEV;
-   goto err_irq;
+   return -ENODEV;
}
 
err = request_any_context_irq(data->irq, adc_jack_irq_thread,
@@ -165,15 +159,10 @@ static int adc_jack_probe(struct platform_device *pdev)
 
if (err < 0) {
dev_err(&pdev->dev, "error: irq %d\n", data->irq);
-   goto err_irq;
+   return err;
}
 
return 0;
-
-err_irq:
-   extcon_dev_unregister(&data->edev);
-out:
-   return err;
 }
 
 static int adc_jack_remove(struct platform_device *pdev)
@@ -182,7 +171,6 @@ static int adc_jack_remove(struct platform_device *pdev)
 
free_irq(data->irq, data);
cancel_work_sync(&data->handler.work);
-   extcon_dev_unregister(&data->edev);
 
return 0;
 }
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCHv2 5/8] extcon: max77693: Use devm_extcon_dev_register()

2014-04-17 Thread Sangjung Woo
Use the resource-managed extcon device register function (i.e.
devm_extcon_dev_register()) instead of extcon_dev_register(). If extcon device
is attached with this function, that extcon device is automatically unregistered
on driver detach. That reduces tiresome managing code.

Signed-off-by: Sangjung Woo 
Reviewed-by: Krzysztof Kozlowski 
---
 drivers/extcon/extcon-max77693.c |7 ++-
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/extcon/extcon-max77693.c b/drivers/extcon/extcon-max77693.c
index 39cd095..f0f18e2 100644
--- a/drivers/extcon/extcon-max77693.c
+++ b/drivers/extcon/extcon-max77693.c
@@ -1185,7 +1185,7 @@ static int max77693_muic_probe(struct platform_device 
*pdev)
info->edev->name = DEV_NAME;
info->edev->dev.parent = &pdev->dev;
info->edev->supported_cable = max77693_extcon_cable;
-   ret = extcon_dev_register(info->edev);
+   ret = devm_extcon_dev_register(&pdev->dev, info->edev);
if (ret) {
dev_err(&pdev->dev, "failed to register extcon device\n");
goto err_irq;
@@ -1267,7 +1267,7 @@ static int max77693_muic_probe(struct platform_device 
*pdev)
MAX77693_MUIC_REG_ID, &id);
if (ret < 0) {
dev_err(&pdev->dev, "failed to read revision number\n");
-   goto err_extcon;
+   goto err_irq;
}
dev_info(info->dev, "device ID : 0x%x\n", id);
 
@@ -1288,8 +1288,6 @@ static int max77693_muic_probe(struct platform_device 
*pdev)
 
return ret;
 
-err_extcon:
-   extcon_dev_unregister(info->edev);
 err_irq:
while (--i >= 0)
free_irq(muic_irqs[i].virq, info);
@@ -1305,7 +1303,6 @@ static int max77693_muic_remove(struct platform_device 
*pdev)
free_irq(muic_irqs[i].virq, info);
cancel_work_sync(&info->irq_work);
input_unregister_device(info->dock);
-   extcon_dev_unregister(info->edev);
 
return 0;
 }
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCHv2 8/8] extcon: arizona: Use devm_extcon_dev_register()

2014-04-17 Thread Sangjung Woo
Use the resource-managed extcon device register function (i.e.
devm_extcon_dev_register()) instead of extcon_dev_register(). If extcon device
is attached with this function, that extcon device is automatically unregistered
on driver detach. That reduces tiresome managing code.

Signed-off-by: Sangjung Woo 
Reviewed-by: Seung-Woo Kim 
---
 drivers/extcon/extcon-arizona.c |   13 -
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/drivers/extcon/extcon-arizona.c b/drivers/extcon/extcon-arizona.c
index 98a14f6..40e6c0b 100644
--- a/drivers/extcon/extcon-arizona.c
+++ b/drivers/extcon/extcon-arizona.c
@@ -1105,15 +1105,13 @@ static int arizona_extcon_probe(struct platform_device 
*pdev)
info = devm_kzalloc(&pdev->dev, sizeof(*info), GFP_KERNEL);
if (!info) {
dev_err(&pdev->dev, "Failed to allocate memory\n");
-   ret = -ENOMEM;
-   goto err;
+   return -ENOMEM;
}
 
info->micvdd = devm_regulator_get(arizona->dev, "MICVDD");
if (IS_ERR(info->micvdd)) {
-   ret = PTR_ERR(info->micvdd);
dev_err(arizona->dev, "Failed to get MICVDD: %d\n", ret);
-   goto err;
+   return PTR_ERR(info->micvdd);
}
 
mutex_init(&info->lock);
@@ -1155,11 +1153,11 @@ static int arizona_extcon_probe(struct platform_device 
*pdev)
info->edev.dev.parent = arizona->dev;
info->edev.supported_cable = arizona_cable;
 
-   ret = extcon_dev_register(&info->edev);
+   ret = devm_extcon_dev_register(&pdev->dev, &info->edev);
if (ret < 0) {
dev_err(arizona->dev, "extcon_dev_register() failed: %d\n",
ret);
-   goto err;
+   return ret;
}
 
info->input = devm_input_allocate_device(&pdev->dev);
@@ -1410,8 +1408,6 @@ err_rise:
 err_input:
 err_register:
pm_runtime_disable(&pdev->dev);
-   extcon_dev_unregister(&info->edev);
-err:
return ret;
 }
 
@@ -1445,7 +1441,6 @@ static int arizona_extcon_remove(struct platform_device 
*pdev)
regmap_update_bits(arizona->regmap, ARIZONA_JACK_DETECT_ANALOGUE,
   ARIZONA_JD1_ENA, 0);
arizona_clk32k_disable(arizona);
-   extcon_dev_unregister(&info->edev);
 
return 0;
 }
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCHv2 4/8] extcon: max14577: Use devm_extcon_dev_register()

2014-04-17 Thread Sangjung Woo
Use the resource-managed extcon device register function (i.e.
devm_extcon_dev_register()) instead of extcon_dev_register(). If extcon device
is attached with this function, that extcon device is automatically unregistered
on driver detach. That reduces tiresome managing code.

Signed-off-by: Sangjung Woo 
Reviewed-by: Krzysztof Kozlowski 
---
 drivers/extcon/extcon-max14577.c |9 ++---
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/drivers/extcon/extcon-max14577.c b/drivers/extcon/extcon-max14577.c
index 1fef08d..c6166e7 100644
--- a/drivers/extcon/extcon-max14577.c
+++ b/drivers/extcon/extcon-max14577.c
@@ -675,7 +675,7 @@ static int max14577_muic_probe(struct platform_device *pdev)
}
info->edev->name = DEV_NAME;
info->edev->supported_cable = max14577_extcon_cable;
-   ret = extcon_dev_register(info->edev);
+   ret = devm_extcon_dev_register(&pdev->dev, info->edev);
if (ret) {
dev_err(&pdev->dev, "failed to register extcon device\n");
return ret;
@@ -694,7 +694,7 @@ static int max14577_muic_probe(struct platform_device *pdev)
MAX14577_REG_DEVICEID, &id);
if (ret < 0) {
dev_err(&pdev->dev, "failed to read revision number\n");
-   goto err_extcon;
+   return ret;
}
dev_info(info->dev, "device ID : 0x%x\n", id);
 
@@ -714,10 +714,6 @@ static int max14577_muic_probe(struct platform_device 
*pdev)
delay_jiffies);
 
return ret;
-
-err_extcon:
-   extcon_dev_unregister(info->edev);
-   return ret;
 }
 
 static int max14577_muic_remove(struct platform_device *pdev)
@@ -725,7 +721,6 @@ static int max14577_muic_remove(struct platform_device 
*pdev)
struct max14577_muic_info *info = platform_get_drvdata(pdev);
 
cancel_work_sync(&info->irq_work);
-   extcon_dev_unregister(info->edev);
 
return 0;
 }
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCHv3 3/8] extcon: gpio: Use devm_extcon_dev_register()

2014-04-17 Thread Sangjung Woo
Use the resource-managed extcon device register function (i.e.
devm_extcon_dev_register()) instead of extcon_dev_register(). If extcon device
is attached with this function, that extcon device is automatically unregistered
on driver detach. That reduces tiresome managing code.

Signed-off-by: Sangjung Woo 
---
 drivers/extcon/extcon-gpio.c |   16 
 1 file changed, 4 insertions(+), 12 deletions(-)

diff --git a/drivers/extcon/extcon-gpio.c b/drivers/extcon/extcon-gpio.c
index 13d5222..43af34c 100644
--- a/drivers/extcon/extcon-gpio.c
+++ b/drivers/extcon/extcon-gpio.c
@@ -121,34 +121,27 @@ static int gpio_extcon_probe(struct platform_device *pdev)
msecs_to_jiffies(pdata->debounce);
}
 
-   ret = extcon_dev_register(&extcon_data->edev);
+   ret = devm_extcon_dev_register(&pdev->dev, &extcon_data->edev);
if (ret < 0)
return ret;
 
INIT_DELAYED_WORK(&extcon_data->work, gpio_extcon_work);
 
extcon_data->irq = gpio_to_irq(extcon_data->gpio);
-   if (extcon_data->irq < 0) {
-   ret = extcon_data->irq;
-   goto err;
-   }
+   if (extcon_data->irq < 0)
+   return extcon_data->irq;
 
ret = request_any_context_irq(extcon_data->irq, gpio_irq_handler,
  pdata->irq_flags, pdev->name,
  extcon_data);
if (ret < 0)
-   goto err;
+   return ret;
 
platform_set_drvdata(pdev, extcon_data);
/* Perform initial detection */
gpio_extcon_work(&extcon_data->work.work);
 
return 0;
-
-err:
-   extcon_dev_unregister(&extcon_data->edev);
-
-   return ret;
 }
 
 static int gpio_extcon_remove(struct platform_device *pdev)
@@ -157,7 +150,6 @@ static int gpio_extcon_remove(struct platform_device *pdev)
 
cancel_delayed_work_sync(&extcon_data->work);
free_irq(extcon_data->irq, extcon_data);
-   extcon_dev_unregister(&extcon_data->edev);
 
return 0;
 }
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCHv2 0/8] Resource-managed extcon device register function

2014-04-17 Thread Sangjung Woo
These patches add resource-managed extcon device register functions for
developers' convenience and apply them to related device driver files.
This work can make the code more tidy since extcon device is automatically
unregistered on driver detach so tiresome managing codes could be removed.


Changelog:

v2:
* modify and clean up all unnecessary code reported by Chanwoo
* fix the bug reported by Seung-Woo
* add the credit for reviewers

v1:
* initial version

Sangjung Woo (8):
  extcon: Add resource-managed extcon register function
  extcon: adc-jack: Use devm_extcon_dev_register()
  extcon: gpio: Use devm_extcon_dev_register()
  extcon: max14577: Use devm_extcon_dev_register()
  extcon: max77693: Use devm_extcon_dev_register()
  extcon: max8997: Use devm_extcon_dev_register()
  extcon: palmas: Use devm_extcon_dev_register()
  extcon: arizona: Use devm_extcon_dev_register()

 drivers/extcon/extcon-adc-jack.c |   30 +-
 drivers/extcon/extcon-arizona.c  |   13 ++
 drivers/extcon/extcon-class.c|   83 ++
 drivers/extcon/extcon-gpio.c |   16 ++--
 drivers/extcon/extcon-max14577.c |9 +
 drivers/extcon/extcon-max77693.c |7 +---
 drivers/extcon/extcon-max8997.c  |4 +-
 drivers/extcon/extcon-palmas.c   |   15 +++
 include/linux/extcon.h   |8 
 9 files changed, 118 insertions(+), 67 deletions(-)

-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCHv2 7/8] extcon: palmas: Use devm_extcon_dev_register()

2014-04-17 Thread Sangjung Woo
Use the resource-managed extcon device register function (i.e.
devm_extcon_dev_register()) instead of extcon_dev_register(). If extcon device
is attached with this function, that extcon device is automatically unregistered
on driver detach. That reduces tiresome managing code.

Signed-off-by: Sangjung Woo 
---
 drivers/extcon/extcon-palmas.c |   15 +--
 1 file changed, 5 insertions(+), 10 deletions(-)

diff --git a/drivers/extcon/extcon-palmas.c b/drivers/extcon/extcon-palmas.c
index 51db5bc..1a770e0 100644
--- a/drivers/extcon/extcon-palmas.c
+++ b/drivers/extcon/extcon-palmas.c
@@ -192,7 +192,7 @@ static int palmas_usb_probe(struct platform_device *pdev)
palmas_usb->edev.name = kstrdup(node->name, GFP_KERNEL);
palmas_usb->edev.mutually_exclusive = mutually_exclusive;
 
-   status = extcon_dev_register(&palmas_usb->edev);
+   status = devm_extcon_dev_register(&pdev->dev, &palmas_usb->edev);
if (status) {
dev_err(&pdev->dev, "failed to register extcon device\n");
kfree(palmas_usb->edev.name);
@@ -209,7 +209,8 @@ static int palmas_usb_probe(struct platform_device *pdev)
if (status < 0) {
dev_err(&pdev->dev, "can't get IRQ %d, err %d\n",
palmas_usb->id_irq, status);
-   goto fail_extcon;
+   kfree(palmas_usb->edev.name);
+   return status;
}
}
 
@@ -223,26 +224,20 @@ static int palmas_usb_probe(struct platform_device *pdev)
if (status < 0) {
dev_err(&pdev->dev, "can't get IRQ %d, err %d\n",
palmas_usb->vbus_irq, status);
-   goto fail_extcon;
+   kfree(palmas_usb->edev.name);
+   return status;
}
}
 
palmas_enable_irq(palmas_usb);
device_set_wakeup_capable(&pdev->dev, true);
return 0;
-
-fail_extcon:
-   extcon_dev_unregister(&palmas_usb->edev);
-   kfree(palmas_usb->edev.name);
-
-   return status;
 }
 
 static int palmas_usb_remove(struct platform_device *pdev)
 {
struct palmas_usb *palmas_usb = platform_get_drvdata(pdev);
 
-   extcon_dev_unregister(&palmas_usb->edev);
kfree(palmas_usb->edev.name);
 
return 0;
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCHv2 6/8] extcon: max8997: Use devm_extcon_dev_register()

2014-04-17 Thread Sangjung Woo
Use the resource-managed extcon device register function (i.e.
devm_extcon_dev_register()) instead of extcon_dev_register(). If extcon device
is attached with this function, that extcon device is automatically unregistered
on driver detach. That reduces tiresome managing code.

Signed-off-by: Sangjung Woo 
Reviewed-by: Krzysztof Kozlowski 
---
 drivers/extcon/extcon-max8997.c |4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/extcon/extcon-max8997.c b/drivers/extcon/extcon-max8997.c
index 223e6b0..804a446 100644
--- a/drivers/extcon/extcon-max8997.c
+++ b/drivers/extcon/extcon-max8997.c
@@ -709,7 +709,7 @@ static int max8997_muic_probe(struct platform_device *pdev)
info->edev->name = DEV_NAME;
info->edev->dev.parent = &pdev->dev;
info->edev->supported_cable = max8997_extcon_cable;
-   ret = extcon_dev_register(info->edev);
+   ret = devm_extcon_dev_register(&pdev->dev, info->edev);
if (ret) {
dev_err(&pdev->dev, "failed to register extcon device\n");
goto err_irq;
@@ -790,8 +790,6 @@ static int max8997_muic_remove(struct platform_device *pdev)
free_irq(muic_irqs[i].virq, info);
cancel_work_sync(&info->irq_work);
 
-   extcon_dev_unregister(info->edev);
-
return 0;
 }
 
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/8] extcon: adc-jack: Use devm_extcon_dev_register()

2014-04-16 Thread Sangjung Woo
Use the resource-managed extcon device register function (i.e.
devm_extcon_dev_register()) instead of extcon_dev_register(). If extcon device
is attached with this function, that extcon device is automatically unregistered
on driver detach. That reduces tiresome managing code.

Signed-off-by: Sangjung Woo 
---
 drivers/extcon/extcon-adc-jack.c |   30 +-
 1 file changed, 9 insertions(+), 21 deletions(-)

diff --git a/drivers/extcon/extcon-adc-jack.c b/drivers/extcon/extcon-adc-jack.c
index e23f1c2..549d820 100644
--- a/drivers/extcon/extcon-adc-jack.c
+++ b/drivers/extcon/extcon-adc-jack.c
@@ -105,9 +105,8 @@ static int adc_jack_probe(struct platform_device *pdev)
data->edev.name = pdata->name;
 
if (!pdata->cable_names) {
-   err = -EINVAL;
dev_err(&pdev->dev, "error: cable_names not defined.\n");
-   goto out;
+   return -EINVAL;
}
 
data->edev.dev.parent = &pdev->dev;
@@ -117,18 +116,16 @@ static int adc_jack_probe(struct platform_device *pdev)
for (i = 0; data->edev.supported_cable[i]; i++)
;
if (i == 0 || i > SUPPORTED_CABLE_MAX) {
-   err = -EINVAL;
dev_err(&pdev->dev, "error: pdata->cable_names size = %d\n",
i - 1);
-   goto out;
+   return -EINVAL;
}
data->num_cables = i;
 
if (!pdata->adc_conditions ||
!pdata->adc_conditions[0].state) {
-   err = -EINVAL;
dev_err(&pdev->dev, "error: adc_conditions not defined.\n");
-   goto out;
+   return -EINVAL;
}
data->adc_conditions = pdata->adc_conditions;
 
@@ -138,10 +135,8 @@ static int adc_jack_probe(struct platform_device *pdev)
data->num_conditions = i;
 
data->chan = iio_channel_get(&pdev->dev, pdata->consumer_channel);
-   if (IS_ERR(data->chan)) {
-   err = PTR_ERR(data->chan);
-   goto out;
-   }
+   if (IS_ERR(data->chan))
+   return PTR_ERR(data->chan);
 
data->handling_delay = msecs_to_jiffies(pdata->handling_delay_ms);
 
@@ -149,15 +144,14 @@ static int adc_jack_probe(struct platform_device *pdev)
 
platform_set_drvdata(pdev, data);
 
-   err = extcon_dev_register(&data->edev);
+   err = devm_extcon_dev_register(&pdev->dev, &data->edev);
if (err)
-   goto out;
+   return err;
 
data->irq = platform_get_irq(pdev, 0);
if (!data->irq) {
dev_err(&pdev->dev, "platform_get_irq failed\n");
-   err = -ENODEV;
-   goto err_irq;
+   return -ENODEV;
}
 
err = request_any_context_irq(data->irq, adc_jack_irq_thread,
@@ -165,15 +159,10 @@ static int adc_jack_probe(struct platform_device *pdev)
 
if (err < 0) {
dev_err(&pdev->dev, "error: irq %d\n", data->irq);
-   goto err_irq;
+   return err;
}
 
return 0;
-
-err_irq:
-   extcon_dev_unregister(&data->edev);
-out:
-   return err;
 }
 
 static int adc_jack_remove(struct platform_device *pdev)
@@ -182,7 +171,6 @@ static int adc_jack_remove(struct platform_device *pdev)
 
free_irq(data->irq, data);
cancel_work_sync(&data->handler.work);
-   extcon_dev_unregister(&data->edev);
 
return 0;
 }
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 0/8] Resource-managed extcon device register function

2014-04-16 Thread Sangjung Woo
These patches add resource-managed extcon device register functions for
developers' convenience and apply them to related device driver files.
This work can make the code more tidy since extcon device is automatically
unregistered on driver detach so tiresome managing codes could be removed.


Sangjung Woo (8):
  extcon: Add resource-managed extcon register function
  extcon: adc-jack: Use devm_extcon_dev_register()
  extcon: gpio: Use devm_extcon_dev_register()
  extcon: max14577: Use devm_extcon_dev_register()
  extcon: max77693: Use devm_extcon_dev_register()
  extcon: max8997: Use devm_extcon_dev_register()
  extcon: palmas: Use devm_extcon_dev_register()
  extcon: arizona: Use devm_extcon_dev_register()

 drivers/extcon/extcon-adc-jack.c |   30 +-
 drivers/extcon/extcon-arizona.c  |   13 ++
 drivers/extcon/extcon-class.c|   83 ++
 drivers/extcon/extcon-gpio.c |   16 ++--
 drivers/extcon/extcon-max14577.c |9 +
 drivers/extcon/extcon-max77693.c |7 +---
 drivers/extcon/extcon-max8997.c  |4 +-
 drivers/extcon/extcon-palmas.c   |   15 +++
 include/linux/extcon.h   |8 
 9 files changed, 118 insertions(+), 67 deletions(-)

-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 5/8] extcon: max77693: Use devm_extcon_dev_register()

2014-04-16 Thread Sangjung Woo
Use the resource-managed extcon device register function (i.e.
devm_extcon_dev_register()) instead of extcon_dev_register(). If extcon device
is attached with this function, that extcon device is automatically unregistered
on driver detach. That reduces tiresome managing code.

Signed-off-by: Sangjung Woo 
---
 drivers/extcon/extcon-max77693.c |7 ++-
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/extcon/extcon-max77693.c b/drivers/extcon/extcon-max77693.c
index 39cd095..f0f18e2 100644
--- a/drivers/extcon/extcon-max77693.c
+++ b/drivers/extcon/extcon-max77693.c
@@ -1185,7 +1185,7 @@ static int max77693_muic_probe(struct platform_device 
*pdev)
info->edev->name = DEV_NAME;
info->edev->dev.parent = &pdev->dev;
info->edev->supported_cable = max77693_extcon_cable;
-   ret = extcon_dev_register(info->edev);
+   ret = devm_extcon_dev_register(&pdev->dev, info->edev);
if (ret) {
dev_err(&pdev->dev, "failed to register extcon device\n");
goto err_irq;
@@ -1267,7 +1267,7 @@ static int max77693_muic_probe(struct platform_device 
*pdev)
MAX77693_MUIC_REG_ID, &id);
if (ret < 0) {
dev_err(&pdev->dev, "failed to read revision number\n");
-   goto err_extcon;
+   goto err_irq;
}
dev_info(info->dev, "device ID : 0x%x\n", id);
 
@@ -1288,8 +1288,6 @@ static int max77693_muic_probe(struct platform_device 
*pdev)
 
return ret;
 
-err_extcon:
-   extcon_dev_unregister(info->edev);
 err_irq:
while (--i >= 0)
free_irq(muic_irqs[i].virq, info);
@@ -1305,7 +1303,6 @@ static int max77693_muic_remove(struct platform_device 
*pdev)
free_irq(muic_irqs[i].virq, info);
cancel_work_sync(&info->irq_work);
input_unregister_device(info->dock);
-   extcon_dev_unregister(info->edev);
 
return 0;
 }
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 3/8] extcon: gpio: Use devm_extcon_dev_register()

2014-04-16 Thread Sangjung Woo
Use the resource-managed extcon device register function (i.e.
devm_extcon_dev_register()) instead of extcon_dev_register(). If extcon device
is attached with this function, that extcon device is automatically unregistered
on driver detach. That reduces tiresome managing code.

Signed-off-by: Sangjung Woo 
---
 drivers/extcon/extcon-gpio.c |   16 
 1 file changed, 4 insertions(+), 12 deletions(-)

diff --git a/drivers/extcon/extcon-gpio.c b/drivers/extcon/extcon-gpio.c
index 13d5222..43af34c 100644
--- a/drivers/extcon/extcon-gpio.c
+++ b/drivers/extcon/extcon-gpio.c
@@ -121,34 +121,27 @@ static int gpio_extcon_probe(struct platform_device *pdev)
msecs_to_jiffies(pdata->debounce);
}
 
-   ret = extcon_dev_register(&extcon_data->edev);
+   ret = devm_extcon_dev_register(&pdev->dev, &extcon_data->edev);
if (ret < 0)
return ret;
 
INIT_DELAYED_WORK(&extcon_data->work, gpio_extcon_work);
 
extcon_data->irq = gpio_to_irq(extcon_data->gpio);
-   if (extcon_data->irq < 0) {
-   ret = extcon_data->irq;
-   goto err;
-   }
+   if (extcon_data->irq < 0)
+   return extcon_data->irq;
 
ret = request_any_context_irq(extcon_data->irq, gpio_irq_handler,
  pdata->irq_flags, pdev->name,
  extcon_data);
if (ret < 0)
-   goto err;
+   return ret;
 
platform_set_drvdata(pdev, extcon_data);
/* Perform initial detection */
gpio_extcon_work(&extcon_data->work.work);
 
return 0;
-
-err:
-   extcon_dev_unregister(&extcon_data->edev);
-
-   return ret;
 }
 
 static int gpio_extcon_remove(struct platform_device *pdev)
@@ -157,7 +150,6 @@ static int gpio_extcon_remove(struct platform_device *pdev)
 
cancel_delayed_work_sync(&extcon_data->work);
free_irq(extcon_data->irq, extcon_data);
-   extcon_dev_unregister(&extcon_data->edev);
 
return 0;
 }
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 6/8] extcon: max8997: Use devm_extcon_dev_register()

2014-04-16 Thread Sangjung Woo
Use the resource-managed extcon device register function (i.e.
devm_extcon_dev_register()) instead of extcon_dev_register(). If extcon device
is attached with this function, that extcon device is automatically unregistered
on driver detach. That reduces tiresome managing code.

Signed-off-by: Sangjung Woo 
---
 drivers/extcon/extcon-max8997.c |4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/extcon/extcon-max8997.c b/drivers/extcon/extcon-max8997.c
index 223e6b0..804a446 100644
--- a/drivers/extcon/extcon-max8997.c
+++ b/drivers/extcon/extcon-max8997.c
@@ -709,7 +709,7 @@ static int max8997_muic_probe(struct platform_device *pdev)
info->edev->name = DEV_NAME;
info->edev->dev.parent = &pdev->dev;
info->edev->supported_cable = max8997_extcon_cable;
-   ret = extcon_dev_register(info->edev);
+   ret = devm_extcon_dev_register(&pdev->dev, info->edev);
if (ret) {
dev_err(&pdev->dev, "failed to register extcon device\n");
goto err_irq;
@@ -790,8 +790,6 @@ static int max8997_muic_remove(struct platform_device *pdev)
free_irq(muic_irqs[i].virq, info);
cancel_work_sync(&info->irq_work);
 
-   extcon_dev_unregister(info->edev);
-
return 0;
 }
 
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 8/8] extcon: arizona: Use devm_extcon_dev_register()

2014-04-16 Thread Sangjung Woo
Use the resource-managed extcon device register function (i.e.
devm_extcon_dev_register()) instead of extcon_dev_register(). If extcon device
is attached with this function, that extcon device is automatically unregistered
on driver detach. That reduces tiresome managing code.

Signed-off-by: Sangjung Woo 
---
 drivers/extcon/extcon-arizona.c |   13 -
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/drivers/extcon/extcon-arizona.c b/drivers/extcon/extcon-arizona.c
index 98a14f6..40e6c0b 100644
--- a/drivers/extcon/extcon-arizona.c
+++ b/drivers/extcon/extcon-arizona.c
@@ -1105,15 +1105,13 @@ static int arizona_extcon_probe(struct platform_device 
*pdev)
info = devm_kzalloc(&pdev->dev, sizeof(*info), GFP_KERNEL);
if (!info) {
dev_err(&pdev->dev, "Failed to allocate memory\n");
-   ret = -ENOMEM;
-   goto err;
+   return -ENOMEM;
}
 
info->micvdd = devm_regulator_get(arizona->dev, "MICVDD");
if (IS_ERR(info->micvdd)) {
-   ret = PTR_ERR(info->micvdd);
dev_err(arizona->dev, "Failed to get MICVDD: %d\n", ret);
-   goto err;
+   return PTR_ERR(info->micvdd);
}
 
mutex_init(&info->lock);
@@ -1155,11 +1153,11 @@ static int arizona_extcon_probe(struct platform_device 
*pdev)
info->edev.dev.parent = arizona->dev;
info->edev.supported_cable = arizona_cable;
 
-   ret = extcon_dev_register(&info->edev);
+   ret = devm_extcon_dev_register(&pdev->dev, &info->edev);
if (ret < 0) {
dev_err(arizona->dev, "extcon_dev_register() failed: %d\n",
ret);
-   goto err;
+   return ret;
}
 
info->input = devm_input_allocate_device(&pdev->dev);
@@ -1410,8 +1408,6 @@ err_rise:
 err_input:
 err_register:
pm_runtime_disable(&pdev->dev);
-   extcon_dev_unregister(&info->edev);
-err:
return ret;
 }
 
@@ -1445,7 +1441,6 @@ static int arizona_extcon_remove(struct platform_device 
*pdev)
regmap_update_bits(arizona->regmap, ARIZONA_JACK_DETECT_ANALOGUE,
   ARIZONA_JD1_ENA, 0);
arizona_clk32k_disable(arizona);
-   extcon_dev_unregister(&info->edev);
 
return 0;
 }
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 7/8] extcon: palmas: Use devm_extcon_dev_register()

2014-04-16 Thread Sangjung Woo
Use the resource-managed extcon device register function (i.e.
devm_extcon_dev_register()) instead of extcon_dev_register(). If extcon device
is attached with this function, that extcon device is automatically unregistered
on driver detach. That reduces tiresome managing code.

Signed-off-by: Sangjung Woo 
---
 drivers/extcon/extcon-palmas.c |   15 +--
 1 file changed, 5 insertions(+), 10 deletions(-)

diff --git a/drivers/extcon/extcon-palmas.c b/drivers/extcon/extcon-palmas.c
index 51db5bc..1a770e0 100644
--- a/drivers/extcon/extcon-palmas.c
+++ b/drivers/extcon/extcon-palmas.c
@@ -192,7 +192,7 @@ static int palmas_usb_probe(struct platform_device *pdev)
palmas_usb->edev.name = kstrdup(node->name, GFP_KERNEL);
palmas_usb->edev.mutually_exclusive = mutually_exclusive;
 
-   status = extcon_dev_register(&palmas_usb->edev);
+   status = devm_extcon_dev_register(&pdev->dev, &palmas_usb->edev);
if (status) {
dev_err(&pdev->dev, "failed to register extcon device\n");
kfree(palmas_usb->edev.name);
@@ -209,7 +209,8 @@ static int palmas_usb_probe(struct platform_device *pdev)
if (status < 0) {
dev_err(&pdev->dev, "can't get IRQ %d, err %d\n",
palmas_usb->id_irq, status);
-   goto fail_extcon;
+   kfree(palmas_usb->edev.name);
+   return status;
}
}
 
@@ -223,26 +224,20 @@ static int palmas_usb_probe(struct platform_device *pdev)
if (status < 0) {
dev_err(&pdev->dev, "can't get IRQ %d, err %d\n",
palmas_usb->vbus_irq, status);
-   goto fail_extcon;
+   kfree(palmas_usb->edev.name);
+   return status;
}
}
 
palmas_enable_irq(palmas_usb);
device_set_wakeup_capable(&pdev->dev, true);
return 0;
-
-fail_extcon:
-   extcon_dev_unregister(&palmas_usb->edev);
-   kfree(palmas_usb->edev.name);
-
-   return status;
 }
 
 static int palmas_usb_remove(struct platform_device *pdev)
 {
struct palmas_usb *palmas_usb = platform_get_drvdata(pdev);
 
-   extcon_dev_unregister(&palmas_usb->edev);
kfree(palmas_usb->edev.name);
 
return 0;
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 4/8] extcon: max14577: Use devm_extcon_dev_register()

2014-04-16 Thread Sangjung Woo
Use the resource-managed extcon device register function (i.e.
devm_extcon_dev_register()) instead of extcon_dev_register(). If extcon device
is attached with this function, that extcon device is automatically unregistered
on driver detach. That reduces tiresome managing code.

Signed-off-by: Sangjung Woo 
---
 drivers/extcon/extcon-max14577.c |9 ++---
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/drivers/extcon/extcon-max14577.c b/drivers/extcon/extcon-max14577.c
index 1fef08d..c6166e7 100644
--- a/drivers/extcon/extcon-max14577.c
+++ b/drivers/extcon/extcon-max14577.c
@@ -675,7 +675,7 @@ static int max14577_muic_probe(struct platform_device *pdev)
}
info->edev->name = DEV_NAME;
info->edev->supported_cable = max14577_extcon_cable;
-   ret = extcon_dev_register(info->edev);
+   ret = devm_extcon_dev_register(&pdev->dev, info->edev);
if (ret) {
dev_err(&pdev->dev, "failed to register extcon device\n");
return ret;
@@ -694,7 +694,7 @@ static int max14577_muic_probe(struct platform_device *pdev)
MAX14577_REG_DEVICEID, &id);
if (ret < 0) {
dev_err(&pdev->dev, "failed to read revision number\n");
-   goto err_extcon;
+   return ret;
}
dev_info(info->dev, "device ID : 0x%x\n", id);
 
@@ -714,10 +714,6 @@ static int max14577_muic_probe(struct platform_device 
*pdev)
delay_jiffies);
 
return ret;
-
-err_extcon:
-   extcon_dev_unregister(info->edev);
-   return ret;
 }
 
 static int max14577_muic_remove(struct platform_device *pdev)
@@ -725,7 +721,6 @@ static int max14577_muic_remove(struct platform_device 
*pdev)
struct max14577_muic_info *info = platform_get_drvdata(pdev);
 
cancel_work_sync(&info->irq_work);
-   extcon_dev_unregister(info->edev);
 
return 0;
 }
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/8] extcon: Add resource-managed extcon register function

2014-04-16 Thread Sangjung Woo
Add resource-managed extcon device register function for convenience.
For example, if a extcon device is attached with new
devm_extcon_dev_register(), that extcon device is automatically
unregistered on driver detach.

Signed-off-by: Sangjung Woo 
---
 drivers/extcon/extcon-class.c |   83 +
 include/linux/extcon.h|8 
 2 files changed, 91 insertions(+)

diff --git a/drivers/extcon/extcon-class.c b/drivers/extcon/extcon-class.c
index 7ab21aa..accb49c 100644
--- a/drivers/extcon/extcon-class.c
+++ b/drivers/extcon/extcon-class.c
@@ -32,6 +32,7 @@
 #include 
 #include 
 #include 
+#include 
 
 /*
  * extcon_cable_name suggests the standard cable names for commonly used
@@ -819,6 +820,88 @@ void extcon_dev_unregister(struct extcon_dev *edev)
 }
 EXPORT_SYMBOL_GPL(extcon_dev_unregister);
 
+
+/*
+ * Device resource management
+ */
+
+struct extcon_devres {
+   struct extcon_dev *edev;
+};
+
+static void devm_extcon_release(struct device *dev, void *res)
+{
+   struct extcon_devres *dr = (struct extcon_devres *)res;
+
+   extcon_dev_unregister(dr->edev);
+}
+
+static int devm_extcon_match(struct device *dev, void *res, void *data)
+{
+   struct extcon_devres *dr = (struct extcon_devres *)res;
+   struct extcon_devres *match = (struct extcon_devres *)data;
+
+   return dr->edev == match->edev;
+}
+
+/**
+ * devm_extcon_dev_register() - Resource-managed extcon_dev_register()
+ * @dev:   device to allocate extcon device
+ * @edev:  the new extcon device to register
+ *
+ * Managed extcon_dev_register() function. If extcon device is attached with
+ * this function, that extcon device is automatically unregistered on driver
+ * detach. Internally this function calls extcon_dev_register() function.
+ * To get more information, refer that function.
+ *
+ * If extcon device is registered with this function and the device needs to be
+ * unregistered separately, devm_extcon_dev_unregister() should be used.
+ *
+ * RETURNS:
+ * 0 on success, negative error number on failure.
+ */
+int devm_extcon_dev_register(struct device *dev, struct extcon_dev *edev)
+{
+   struct extcon_devres *dr;
+   int rc;
+
+   dr = devres_alloc(devm_extcon_release, sizeof(struct extcon_devres),
+   GFP_KERNEL);
+   if (!dr)
+   return -ENOMEM;
+
+   rc = extcon_dev_register(edev);
+   if (rc) {
+   devres_free(dr);
+   return rc;
+   }
+
+   dr->edev = edev;
+   devres_add(dev, dr);
+
+   return 0;
+}
+EXPORT_SYMBOL_GPL(devm_extcon_dev_register);
+
+/**
+ * devm_extcon_dev_unregister() - Resource-managed extcon_dev_unregister()
+ * @dev:   device the extcon belongs to
+ * @edev:  the extcon device to unregister
+ *
+ * Unregister extcon device that is registered with devm_extcon_dev_register()
+ * function.
+ */
+void devm_extcon_dev_unregister(struct device *dev, struct extcon_dev *edev)
+{
+   struct extcon_devres match_dr = { edev };
+
+   WARN_ON(devres_destroy(dev, devm_extcon_release,
+   devm_extcon_match, &match_dr));
+
+   extcon_dev_unregister(edev);
+}
+EXPORT_SYMBOL_GPL(devm_extcon_dev_unregister);
+
 #ifdef CONFIG_OF
 /*
  * extcon_get_edev_by_phandle - Get the extcon device from devicetree
diff --git a/include/linux/extcon.h b/include/linux/extcon.h
index f488145..e1e85a1 100644
--- a/include/linux/extcon.h
+++ b/include/linux/extcon.h
@@ -188,6 +188,14 @@ extern void extcon_dev_unregister(struct extcon_dev *edev);
 extern struct extcon_dev *extcon_get_extcon_dev(const char *extcon_name);
 
 /*
+ * Resource-managed extcon device register function.
+ */
+extern int devm_extcon_dev_register(struct device *dev,
+   struct extcon_dev *edev);
+extern void devm_extcon_dev_unregister(struct device *dev,
+   struct extcon_dev *edev);
+
+/*
  * get/set/update_state access the 32b encoded state value, which represents
  * states of all possible cables of the multistate port. For example, if one
  * calls extcon_set_state(edev, 0x7), it may mean that all the three cables
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] Documentation / CPU hotplug: Fix the typo in example code

2014-01-14 Thread Sangjung Woo
As the notifier_block name (i.e. foobar_cpu_notifer) is different from
the parameter (i.e.foobar_cpu_notifier) of register function, that is
definitely error and it also makes readers confused.

Signed-off-by: Sangjung Woo 
---
 Documentation/cpu-hotplug.txt |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Documentation/cpu-hotplug.txt b/Documentation/cpu-hotplug.txt
index 8cb9938..be675d2 100644
--- a/Documentation/cpu-hotplug.txt
+++ b/Documentation/cpu-hotplug.txt
@@ -285,7 +285,7 @@ A: This is what you would need in your kernel code to 
receive notifications.
return NOTIFY_OK;
}
 
-   static struct notifier_block foobar_cpu_notifer =
+   static struct notifier_block foobar_cpu_notifier =
{
   .notifier_call = foobar_cpu_callback,
};
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] pwm: samsung: memory leak bugfix in pwm_samsung_free

2013-11-04 Thread Sangjung Woo
There is certainly a kind of memory leak since allocated data (i.e.
chip_data) is set NULL before freeing it by calling devm_kfree(). This
patch fixes the memory leak bug by modifying its call order.

Signed-off-by: Sangjung Woo 
Reviewed-by: Jonghwa Lee 
---
 drivers/pwm/pwm-samsung.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/pwm/pwm-samsung.c b/drivers/pwm/pwm-samsung.c
index fcc8b9a..07b2d9d 100644
--- a/drivers/pwm/pwm-samsung.c
+++ b/drivers/pwm/pwm-samsung.c
@@ -224,8 +224,8 @@ static int pwm_samsung_request(struct pwm_chip *chip, 
struct pwm_device *pwm)
 
 static void pwm_samsung_free(struct pwm_chip *chip, struct pwm_device *pwm)
 {
-   pwm_set_chip_data(pwm, NULL);
devm_kfree(chip->dev, pwm_get_chip_data(pwm));
+   pwm_set_chip_data(pwm, NULL);
 }
 
 static int pwm_samsung_enable(struct pwm_chip *chip, struct pwm_device *pwm)
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v2] rtc: rtc-puv3: use dev_dbg() instead of pr_debug()

2013-10-08 Thread Sangjung Woo
Because dev_*() are used along with pr_debug() function in this code,
the debug message is not tidy. This patch converts from pr_debug() to
dev_dbg() since dev_*() are encouraged to use in device driver code.

Signed-off-by: Sangjung Woo 
---
 drivers/rtc/rtc-puv3.c |   22 +++---
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/drivers/rtc/rtc-puv3.c b/drivers/rtc/rtc-puv3.c
index 402732c..1ecfe3b 100644
--- a/drivers/rtc/rtc-puv3.c
+++ b/drivers/rtc/rtc-puv3.c
@@ -53,11 +53,11 @@ static irqreturn_t puv3_rtc_tickirq(int irq, void *id)
 }
 
 /* Update control registers */
-static void puv3_rtc_setaie(int to)
+static void puv3_rtc_setaie(struct device *dev, int to)
 {
unsigned int tmp;
 
-   pr_debug("%s: aie=%d\n", __func__, to);
+   dev_dbg(dev, "%s: aie=%d\n", __func__, to);
 
tmp = readl(RTC_RTSR) & ~RTC_RTSR_ALE;
 
@@ -71,7 +71,7 @@ static int puv3_rtc_setpie(struct device *dev, int enabled)
 {
unsigned int tmp;
 
-   pr_debug("%s: pie=%d\n", __func__, enabled);
+   dev_debug(dev, "%s: pie=%d\n", __func__, enabled);
 
spin_lock_irq(&puv3_rtc_pie_lock);
tmp = readl(RTC_RTSR) & ~RTC_RTSR_HZE;
@@ -90,7 +90,7 @@ static int puv3_rtc_gettime(struct device *dev, struct 
rtc_time *rtc_tm)
 {
rtc_time_to_tm(readl(RTC_RCNR), rtc_tm);
 
-   pr_debug("read time %02x.%02x.%02x %02x/%02x/%02x\n",
+   dev_dbg(dev, "read time %02x.%02x.%02x %02x/%02x/%02x\n",
 rtc_tm->tm_year, rtc_tm->tm_mon, rtc_tm->tm_mday,
 rtc_tm->tm_hour, rtc_tm->tm_min, rtc_tm->tm_sec);
 
@@ -101,7 +101,7 @@ static int puv3_rtc_settime(struct device *dev, struct 
rtc_time *tm)
 {
unsigned long rtc_count = 0;
 
-   pr_debug("set time %02d.%02d.%02d %02d/%02d/%02d\n",
+   dev_dbg(dev, "set time %02d.%02d.%02d %02d/%02d/%02d\n",
 tm->tm_year, tm->tm_mon, tm->tm_mday,
 tm->tm_hour, tm->tm_min, tm->tm_sec);
 
@@ -119,7 +119,7 @@ static int puv3_rtc_getalarm(struct device *dev, struct 
rtc_wkalrm *alrm)
 
alrm->enabled = readl(RTC_RTSR) & RTC_RTSR_ALE;
 
-   pr_debug("read alarm %02x %02x.%02x.%02x %02x/%02x/%02x\n",
+   dev_dbg(dev, "read alarm %02x %02x.%02x.%02x %02x/%02x/%02x\n",
 alrm->enabled,
 alm_tm->tm_year, alm_tm->tm_mon, alm_tm->tm_mday,
 alm_tm->tm_hour, alm_tm->tm_min, alm_tm->tm_sec);
@@ -132,7 +132,7 @@ static int puv3_rtc_setalarm(struct device *dev, struct 
rtc_wkalrm *alrm)
struct rtc_time *tm = &alrm->time;
unsigned long rtcalarm_count = 0;
 
-   pr_debug("puv3_rtc_setalarm: %d, %02x/%02x/%02x %02x.%02x.%02x\n",
+   dev_dbg(dev, "puv3_rtc_setalarm: %d, %02x/%02x/%02x %02x.%02x.%02x\n",
 alrm->enabled,
 tm->tm_mday & 0xff, tm->tm_mon & 0xff, tm->tm_year & 0xff,
 tm->tm_hour & 0xff, tm->tm_min & 0xff, tm->tm_sec);
@@ -140,7 +140,7 @@ static int puv3_rtc_setalarm(struct device *dev, struct 
rtc_wkalrm *alrm)
rtc_tm_to_time(tm, &rtcalarm_count);
writel(rtcalarm_count, RTC_RTAR);
 
-   puv3_rtc_setaie(alrm->enabled);
+   puv3_rtc_setaie(&dev->dev, alrm->enabled);
 
if (alrm->enabled)
enable_irq_wake(puv3_rtc_alarmno);
@@ -227,7 +227,7 @@ static int puv3_rtc_remove(struct platform_device *dev)
rtc_device_unregister(rtc);
 
puv3_rtc_setpie(&dev->dev, 0);
-   puv3_rtc_setaie(0);
+   puv3_rtc_setaie(&dev->dev, 0);
 
release_resource(puv3_rtc_mem);
kfree(puv3_rtc_mem);
@@ -241,7 +241,7 @@ static int puv3_rtc_probe(struct platform_device *pdev)
struct resource *res;
int ret;
 
-   pr_debug("%s: probe=%p\n", __func__, pdev);
+   dev_dbg(&pdev->dev, "%s: probe=%p\n", __func__, pdev);
 
/* find the IRQs */
puv3_rtc_tickno = platform_get_irq(pdev, 1);
@@ -256,7 +256,7 @@ static int puv3_rtc_probe(struct platform_device *pdev)
return -ENOENT;
}
 
-   pr_debug("PKUnity_rtc: tick irq %d, alarm irq %d\n",
+   dev_dbg(&pdev->dev, "PKUnity_rtc: tick irq %d, alarm irq %d\n",
 puv3_rtc_tickno, puv3_rtc_alarmno);
 
/* get the memory region */
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] rtc: rtc-puv3: use dev_dbg() instead of pr_debug()

2013-10-08 Thread Sangjung Woo
Because dev_*() are used along with pr_debug() function in this code,
the debug message is not tidy. This patch converts from pr_debug() to
dev_dbg() since dev_*() are encouraged to use in device driver code.

Signed-off-by: Sangjung Woo 
---
 drivers/rtc/rtc-puv3.c |   20 ++--
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/rtc/rtc-puv3.c b/drivers/rtc/rtc-puv3.c
index 402732c..9167bb0 100644
--- a/drivers/rtc/rtc-puv3.c
+++ b/drivers/rtc/rtc-puv3.c
@@ -57,7 +57,7 @@ static void puv3_rtc_setaie(int to)
 {
unsigned int tmp;
 
-   pr_debug("%s: aie=%d\n", __func__, to);
+   dev_dbg(dev, "%s: aie=%d\n", __func__, to);
 
tmp = readl(RTC_RTSR) & ~RTC_RTSR_ALE;
 
@@ -71,7 +71,7 @@ static int puv3_rtc_setpie(struct device *dev, int enabled)
 {
unsigned int tmp;
 
-   pr_debug("%s: pie=%d\n", __func__, enabled);
+   dev_debug(dev, "%s: pie=%d\n", __func__, enabled);
 
spin_lock_irq(&puv3_rtc_pie_lock);
tmp = readl(RTC_RTSR) & ~RTC_RTSR_HZE;
@@ -90,7 +90,7 @@ static int puv3_rtc_gettime(struct device *dev, struct 
rtc_time *rtc_tm)
 {
rtc_time_to_tm(readl(RTC_RCNR), rtc_tm);
 
-   pr_debug("read time %02x.%02x.%02x %02x/%02x/%02x\n",
+   dev_dbg(dev, "read time %02x.%02x.%02x %02x/%02x/%02x\n",
 rtc_tm->tm_year, rtc_tm->tm_mon, rtc_tm->tm_mday,
 rtc_tm->tm_hour, rtc_tm->tm_min, rtc_tm->tm_sec);
 
@@ -101,7 +101,7 @@ static int puv3_rtc_settime(struct device *dev, struct 
rtc_time *tm)
 {
unsigned long rtc_count = 0;
 
-   pr_debug("set time %02d.%02d.%02d %02d/%02d/%02d\n",
+   dev_dbg(dev, "set time %02d.%02d.%02d %02d/%02d/%02d\n",
 tm->tm_year, tm->tm_mon, tm->tm_mday,
 tm->tm_hour, tm->tm_min, tm->tm_sec);
 
@@ -119,7 +119,7 @@ static int puv3_rtc_getalarm(struct device *dev, struct 
rtc_wkalrm *alrm)
 
alrm->enabled = readl(RTC_RTSR) & RTC_RTSR_ALE;
 
-   pr_debug("read alarm %02x %02x.%02x.%02x %02x/%02x/%02x\n",
+   dev_dbg(dev, "read alarm %02x %02x.%02x.%02x %02x/%02x/%02x\n",
 alrm->enabled,
 alm_tm->tm_year, alm_tm->tm_mon, alm_tm->tm_mday,
 alm_tm->tm_hour, alm_tm->tm_min, alm_tm->tm_sec);
@@ -132,7 +132,7 @@ static int puv3_rtc_setalarm(struct device *dev, struct 
rtc_wkalrm *alrm)
struct rtc_time *tm = &alrm->time;
unsigned long rtcalarm_count = 0;
 
-   pr_debug("puv3_rtc_setalarm: %d, %02x/%02x/%02x %02x.%02x.%02x\n",
+   dev_dbg(dev, "puv3_rtc_setalarm: %d, %02x/%02x/%02x %02x.%02x.%02x\n",
 alrm->enabled,
 tm->tm_mday & 0xff, tm->tm_mon & 0xff, tm->tm_year & 0xff,
 tm->tm_hour & 0xff, tm->tm_min & 0xff, tm->tm_sec);
@@ -140,7 +140,7 @@ static int puv3_rtc_setalarm(struct device *dev, struct 
rtc_wkalrm *alrm)
rtc_tm_to_time(tm, &rtcalarm_count);
writel(rtcalarm_count, RTC_RTAR);
 
-   puv3_rtc_setaie(alrm->enabled);
+   puv3_rtc_setaie(&dev->dev, alrm->enabled);
 
if (alrm->enabled)
enable_irq_wake(puv3_rtc_alarmno);
@@ -227,7 +227,7 @@ static int puv3_rtc_remove(struct platform_device *dev)
rtc_device_unregister(rtc);
 
puv3_rtc_setpie(&dev->dev, 0);
-   puv3_rtc_setaie(0);
+   puv3_rtc_setaie(&dev->dev, 0);
 
release_resource(puv3_rtc_mem);
kfree(puv3_rtc_mem);
@@ -241,7 +241,7 @@ static int puv3_rtc_probe(struct platform_device *pdev)
struct resource *res;
int ret;
 
-   pr_debug("%s: probe=%p\n", __func__, pdev);
+   dev_dbg(&pdev->dev, "%s: probe=%p\n", __func__, pdev);
 
/* find the IRQs */
puv3_rtc_tickno = platform_get_irq(pdev, 1);
@@ -256,7 +256,7 @@ static int puv3_rtc_probe(struct platform_device *pdev)
return -ENOENT;
}
 
-   pr_debug("PKUnity_rtc: tick irq %d, alarm irq %d\n",
+   dev_dbg(&pdev->dev, "PKUnity_rtc: tick irq %d, alarm irq %d\n",
 puv3_rtc_tickno, puv3_rtc_alarmno);
 
/* get the memory region */
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v2] rtc: pl030: Use devm_kzalloc() instead of kmalloc()

2013-10-08 Thread Sangjung Woo
In order to be free automatically and make the cleanup paths more
simple, use devm_kzalloc() instead of kmalloc().

Signed-off-by: Sangjung Woo 
---
 drivers/rtc/rtc-pl030.c |7 ++-
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/rtc/rtc-pl030.c b/drivers/rtc/rtc-pl030.c
index 22bacdb..ecd57c6 100644
--- a/drivers/rtc/rtc-pl030.c
+++ b/drivers/rtc/rtc-pl030.c
@@ -106,7 +106,7 @@ static int pl030_probe(struct amba_device *dev, const 
struct amba_id *id)
if (ret)
goto err_req;
 
-   rtc = kmalloc(sizeof(*rtc), GFP_KERNEL);
+   rtc = devm_kzalloc(&dev->dev, sizeof(*rtc), GFP_KERNEL);
if (!rtc) {
ret = -ENOMEM;
goto err_rtc;
@@ -115,7 +115,7 @@ static int pl030_probe(struct amba_device *dev, const 
struct amba_id *id)
rtc->base = ioremap(dev->res.start, resource_size(&dev->res));
if (!rtc->base) {
ret = -ENOMEM;
-   goto err_map;
+   goto err_rtc;
}
 
__raw_writel(0, rtc->base + RTC_CR);
@@ -141,8 +141,6 @@ static int pl030_probe(struct amba_device *dev, const 
struct amba_id *id)
free_irq(dev->irq[0], rtc);
  err_irq:
iounmap(rtc->base);
- err_map:
-   kfree(rtc);
  err_rtc:
amba_release_regions(dev);
  err_req:
@@ -160,7 +158,6 @@ static int pl030_remove(struct amba_device *dev)
free_irq(dev->irq[0], rtc);
rtc_device_unregister(rtc->rtc);
iounmap(rtc->base);
-   kfree(rtc);
amba_release_regions(dev);
 
return 0;
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] rtc: pl030: Use devm_kzalloc() instead of kmalloc()

2013-10-08 Thread Sangjung Woo
In order to be free automatically and make the cleanup paths more
simple, use devm_kzalloc() instead of kzalloc().

Signed-off-by: Sangjung Woo 
---
 drivers/rtc/rtc-pl030.c |7 ++-
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/rtc/rtc-pl030.c b/drivers/rtc/rtc-pl030.c
index 22bacdb..ecd57c6 100644
--- a/drivers/rtc/rtc-pl030.c
+++ b/drivers/rtc/rtc-pl030.c
@@ -106,7 +106,7 @@ static int pl030_probe(struct amba_device *dev, const 
struct amba_id *id)
if (ret)
goto err_req;
 
-   rtc = kmalloc(sizeof(*rtc), GFP_KERNEL);
+   rtc = devm_kzalloc(&dev->dev, sizeof(*rtc), GFP_KERNEL);
if (!rtc) {
ret = -ENOMEM;
goto err_rtc;
@@ -115,7 +115,7 @@ static int pl030_probe(struct amba_device *dev, const 
struct amba_id *id)
rtc->base = ioremap(dev->res.start, resource_size(&dev->res));
if (!rtc->base) {
ret = -ENOMEM;
-   goto err_map;
+   goto err_rtc;
}
 
__raw_writel(0, rtc->base + RTC_CR);
@@ -141,8 +141,6 @@ static int pl030_probe(struct amba_device *dev, const 
struct amba_id *id)
free_irq(dev->irq[0], rtc);
  err_irq:
iounmap(rtc->base);
- err_map:
-   kfree(rtc);
  err_rtc:
amba_release_regions(dev);
  err_req:
@@ -160,7 +158,6 @@ static int pl030_remove(struct amba_device *dev)
free_irq(dev->irq[0], rtc);
rtc_device_unregister(rtc->rtc);
iounmap(rtc->base);
-   kfree(rtc);
amba_release_regions(dev);
 
return 0;
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] sgi-xp: fix wrong usage of dev_set_name()

2013-10-03 Thread Sangjung Woo
The second parameter of dev_set_name() is format string. In order to
avoid any potential accidents such as segmentation fault, basic format
parameter "%s" should be used in this case.

Signed-off-by: Sangjung Woo 
---
 drivers/misc/sgi-xp/xpc_main.c |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/misc/sgi-xp/xpc_main.c b/drivers/misc/sgi-xp/xpc_main.c
index 82dc574..ed668ec 100644
--- a/drivers/misc/sgi-xp/xpc_main.c
+++ b/drivers/misc/sgi-xp/xpc_main.c
@@ -1233,8 +1233,8 @@ xpc_init(void)
int ret;
struct task_struct *kthread;
 
-   dev_set_name(xpc_part, "part");
-   dev_set_name(xpc_chan, "chan");
+   dev_set_name(xpc_part, "%s", "part");
+   dev_set_name(xpc_chan, "%s", "chan");
 
if (is_shub()) {
/*
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] staging:iio: fix wrong usage of dev_set_name()

2013-10-03 Thread Sangjung Woo
The second parameter of dev_set_name() is format string. In order to
avoid any potential accidents such as segmentation fault, basic format
parameter "%s" should be used in this case.

Signed-off-by: Sangjung Woo 
---
 drivers/staging/iio/iio_dummy_evgen.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/iio/iio_dummy_evgen.c 
b/drivers/staging/iio/iio_dummy_evgen.c
index 132d278..2c06d16 100644
--- a/drivers/staging/iio/iio_dummy_evgen.c
+++ b/drivers/staging/iio/iio_dummy_evgen.c
@@ -205,7 +205,7 @@ static __init int iio_dummy_evgen_init(void)
if (ret < 0)
return ret;
device_initialize(&iio_evgen_dev);
-   dev_set_name(&iio_evgen_dev, "iio_evgen");
+   dev_set_name(&iio_evgen_dev, "%s", "iio_evgen");
return device_add(&iio_evgen_dev);
 }
 module_init(iio_dummy_evgen_init);
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] fbdev: sh_mobile_hdmi: Use devm_kzalloc()

2013-10-03 Thread Sangjung Woo
Use devm_kzalloc() instead of kzalloc() in order to be free
automatically. This makes cleanup paths more simple.

Signed-off-by: Sangjung Woo 
---
 drivers/video/sh_mobile_hdmi.c |7 ++-
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/video/sh_mobile_hdmi.c b/drivers/video/sh_mobile_hdmi.c
index bfe4728..64bd0bf 100644
--- a/drivers/video/sh_mobile_hdmi.c
+++ b/drivers/video/sh_mobile_hdmi.c
@@ -1290,7 +1290,7 @@ static int __init sh_hdmi_probe(struct platform_device 
*pdev)
}
}
 
-   hdmi = kzalloc(sizeof(*hdmi), GFP_KERNEL);
+   hdmi = devm_kzalloc(&pdev->dev, sizeof(*hdmi), GFP_KERNEL);
if (!hdmi) {
dev_err(&pdev->dev, "Cannot allocate device data\n");
return -ENOMEM;
@@ -1304,7 +1304,7 @@ static int __init sh_hdmi_probe(struct platform_device 
*pdev)
if (IS_ERR(hdmi->hdmi_clk)) {
ret = PTR_ERR(hdmi->hdmi_clk);
dev_err(&pdev->dev, "Unable to get clock: %d\n", ret);
-   goto egetclk;
+   return ret;
}
 
/* select register access functions */
@@ -1407,8 +1407,6 @@ ereqreg:
clk_disable(hdmi->hdmi_clk);
 erate:
clk_put(hdmi->hdmi_clk);
-egetclk:
-   kfree(hdmi);
 
return ret;
 }
@@ -1433,7 +1431,6 @@ static int __exit sh_hdmi_remove(struct platform_device 
*pdev)
iounmap(hdmi->htop1);
iounmap(hdmi->base);
release_mem_region(res->start, resource_size(res));
-   kfree(hdmi);
 
return 0;
 }
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] drivers/rtc/rtc-max77686.c: Fix wrong register

2013-08-13 Thread Sangjung Woo
Fix to read the wrong register when checking whether the RTC timer has
reached or not.

Signed-off-by: Sangjung Woo 
Signed-off-by: Myugnjoo Ham 
Reviewed-by: Jonghwa Lee 
---
 drivers/rtc/rtc-max77686.c |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/rtc/rtc-max77686.c b/drivers/rtc/rtc-max77686.c
index 9915cb9..9efe118 100644
--- a/drivers/rtc/rtc-max77686.c
+++ b/drivers/rtc/rtc-max77686.c
@@ -240,9 +240,9 @@ static int max77686_rtc_read_alarm(struct device *dev, 
struct rtc_wkalrm *alrm)
}
 
alrm->pending = 0;
-   ret = regmap_read(info->max77686->regmap, MAX77686_REG_STATUS1, &val);
+   ret = regmap_read(info->max77686->regmap, MAX77686_REG_STATUS2, &val);
if (ret < 0) {
-   dev_err(info->dev, "%s:%d fail to read status1 reg(%d)\n",
+   dev_err(info->dev, "%s:%d fail to read status2 reg(%d)\n",
__func__, __LINE__, ret);
goto out;
}
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] drivers/rtc/rtc-max77686.c: Fix wrong register

2013-08-13 Thread Sangjung Woo
Fix to read the wrong register when cheching whether the RTC timer has
reached or not.

Signed-off-by: Sangjung Woo 
Signed-off-by: Myugnjoo Ham 
Reviewed-by: Jonghwa Lee 
---
 drivers/rtc/rtc-max77686.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/rtc/rtc-max77686.c b/drivers/rtc/rtc-max77686.c
index 9915cb9..a1140c8 100644
--- a/drivers/rtc/rtc-max77686.c
+++ b/drivers/rtc/rtc-max77686.c
@@ -240,7 +240,7 @@ static int max77686_rtc_read_alarm(struct device *dev, 
struct rtc_wkalrm *alrm)
}
 
alrm->pending = 0;
-   ret = regmap_read(info->max77686->regmap, MAX77686_REG_STATUS1, &val);
+   ret = regmap_read(info->max77686->regmap, MAX77686_REG_STATUS2, &val);
if (ret < 0) {
dev_err(info->dev, "%s:%d fail to read status1 reg(%d)\n",
__func__, __LINE__, ret);
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/