mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/4] extcon: Clean-up the minor issue and fix the NULL pointer error
@ 2015-06-19  6:48 Chanwoo Choi
  2015-06-19  6:48 ` [PATCH 1/4] extcon: Remove duplicate header file in extcon.h Chanwoo Choi
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Chanwoo Choi @ 2015-06-19  6:48 UTC (permalink / raw)
  Cc: linux-kernel, cwchoi00, myungjoo.ham, kyungmin.park

This patch-set clean-up the minor issue and fix the NULL pointer error of
extcon-palmas driver. And extcon driver don't support the bit operation to
identify the external connectors from Linux v4.2. So, patch4 removes the bit
data of mutually_exclusvie array.

Chanwoo Choi (4):
  extcon: Remove duplicate header file in extcon.h
  extcon: Remove optional print_state() function pointer of struct extcon_dev
  extcon: palmas: Fix NULL pointer error
  extcon: palmas: Remove the mutually_exclusive array

 drivers/extcon/extcon-gpio.c   | 18 ------------------
 drivers/extcon/extcon-palmas.c | 10 ----------
 drivers/extcon/extcon.c        |  8 --------
 include/linux/extcon.h         |  7 -------
 4 files changed, 43 deletions(-)

-- 
2.2.0.GIT


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

* [PATCH 1/4] extcon: Remove duplicate header file in extcon.h
  2015-06-19  6:48 [PATCH 0/4] extcon: Clean-up the minor issue and fix the NULL pointer error Chanwoo Choi
@ 2015-06-19  6:48 ` Chanwoo Choi
  2015-06-19  6:48 ` [PATCH 2/4] extcon: Remove optional print_state() function pointer of struct extcon_dev Chanwoo Choi
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 7+ messages in thread
From: Chanwoo Choi @ 2015-06-19  6:48 UTC (permalink / raw)
  Cc: linux-kernel, cwchoi00, myungjoo.ham, kyungmin.park

This patch removes the duplicate header file in extcon.h.

Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
---
 include/linux/extcon.h | 2 --
 1 file changed, 2 deletions(-)

diff --git a/include/linux/extcon.h b/include/linux/extcon.h
index b16d929..1656c98 100644
--- a/include/linux/extcon.h
+++ b/include/linux/extcon.h
@@ -27,8 +27,6 @@
 #define __LINUX_EXTCON_H__
 
 #include <linux/device.h>
-#include <linux/notifier.h>
-#include <linux/sysfs.h>
 
 /*
  * Define the unique id of supported external connectors
-- 
2.2.0.GIT


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

* [PATCH 2/4] extcon: Remove optional print_state() function pointer of struct extcon_dev
  2015-06-19  6:48 [PATCH 0/4] extcon: Clean-up the minor issue and fix the NULL pointer error Chanwoo Choi
  2015-06-19  6:48 ` [PATCH 1/4] extcon: Remove duplicate header file in extcon.h Chanwoo Choi
@ 2015-06-19  6:48 ` Chanwoo Choi
  2015-06-19  6:48 ` [PATCH 3/4] extcon: palmas: Fix NULL pointer error Chanwoo Choi
  2015-06-19  6:48 ` [PATCH 4/4] extcon: palmas: Remove the mutually_exclusive array Chanwoo Choi
  3 siblings, 0 replies; 7+ messages in thread
From: Chanwoo Choi @ 2015-06-19  6:48 UTC (permalink / raw)
  Cc: linux-kernel, cwchoi00, myungjoo.ham, kyungmin.park

This patch removes the optional print_state() function pointer which included
in 'struct extcon_dev' because the extcon must maintain the consistent name
of extcon device on sysfs instead of inconsistent state of external connectors.

Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
---
 drivers/extcon/extcon-gpio.c | 18 ------------------
 drivers/extcon/extcon.c      |  8 --------
 include/linux/extcon.h       |  5 -----
 3 files changed, 31 deletions(-)

diff --git a/drivers/extcon/extcon-gpio.c b/drivers/extcon/extcon-gpio.c
index 355459a..57c24fa 100644
--- a/drivers/extcon/extcon-gpio.c
+++ b/drivers/extcon/extcon-gpio.c
@@ -65,22 +65,6 @@ static irqreturn_t gpio_irq_handler(int irq, void *dev_id)
 	return IRQ_HANDLED;
 }
 
-static ssize_t extcon_gpio_print_state(struct extcon_dev *edev, char *buf)
-{
-	struct device *dev = edev->dev.parent;
-	struct gpio_extcon_data *extcon_data = dev_get_drvdata(dev);
-	const char *state;
-
-	if (extcon_get_state(edev))
-		state = extcon_data->state_on;
-	else
-		state = extcon_data->state_off;
-
-	if (state)
-		return sprintf(buf, "%s\n", state);
-	return -EINVAL;
-}
-
 static int gpio_extcon_probe(struct platform_device *pdev)
 {
 	struct gpio_extcon_platform_data *pdata = dev_get_platdata(&pdev->dev);
@@ -110,8 +94,6 @@ static int gpio_extcon_probe(struct platform_device *pdev)
 	extcon_data->state_on = pdata->state_on;
 	extcon_data->state_off = pdata->state_off;
 	extcon_data->check_on_resume = pdata->check_on_resume;
-	if (pdata->state_on && pdata->state_off)
-		extcon_data->edev->print_state = extcon_gpio_print_state;
 
 	ret = devm_gpio_request_one(&pdev->dev, extcon_data->gpio, GPIOF_DIR_IN,
 				    pdev->name);
diff --git a/drivers/extcon/extcon.c b/drivers/extcon/extcon.c
index 76157ab..6f03ccf 100644
--- a/drivers/extcon/extcon.c
+++ b/drivers/extcon/extcon.c
@@ -162,14 +162,6 @@ static ssize_t state_show(struct device *dev, struct device_attribute *attr,
 	int i, count = 0;
 	struct extcon_dev *edev = dev_get_drvdata(dev);
 
-	if (edev->print_state) {
-		int ret = edev->print_state(edev, buf);
-
-		if (ret >= 0)
-			return ret;
-		/* Use default if failed */
-	}
-
 	if (edev->max_supported == 0)
 		return sprintf(buf, "%u\n", edev->state);
 
diff --git a/include/linux/extcon.h b/include/linux/extcon.h
index 1656c98..c0f8c4f 100644
--- a/include/linux/extcon.h
+++ b/include/linux/extcon.h
@@ -75,8 +75,6 @@ struct extcon_cable;
  *			be attached simulataneously. {0x7, 0} is equivalent to
  *			{0x3, 0x6, 0x5, 0}. If it is {0xFFFFFFFF, 0}, there
  *			can be no simultaneous connections.
- * @print_state:	An optional callback to override the method to print the
- *			status of the extcon device.
  * @dev:		Device of this extcon.
  * @state:		Attach/detach state of this extcon. Do not provide at
  *			register-time.
@@ -100,9 +98,6 @@ struct extcon_dev {
 	const unsigned int *supported_cable;
 	const u32 *mutually_exclusive;
 
-	/* Optional callbacks to override class functions */
-	ssize_t	(*print_state)(struct extcon_dev *edev, char *buf);
-
 	/* Internal data. Please do not set. */
 	struct device dev;
 	struct raw_notifier_head *nh;
-- 
2.2.0.GIT


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

* [PATCH 3/4] extcon: palmas: Fix NULL pointer error
  2015-06-19  6:48 [PATCH 0/4] extcon: Clean-up the minor issue and fix the NULL pointer error Chanwoo Choi
  2015-06-19  6:48 ` [PATCH 1/4] extcon: Remove duplicate header file in extcon.h Chanwoo Choi
  2015-06-19  6:48 ` [PATCH 2/4] extcon: Remove optional print_state() function pointer of struct extcon_dev Chanwoo Choi
@ 2015-06-19  6:48 ` Chanwoo Choi
  2015-06-22  0:45   ` Krzysztof Kozlowski
  2015-06-19  6:48 ` [PATCH 4/4] extcon: palmas: Remove the mutually_exclusive array Chanwoo Choi
  3 siblings, 1 reply; 7+ messages in thread
From: Chanwoo Choi @ 2015-06-19  6:48 UTC (permalink / raw)
  Cc: linux-kernel, cwchoi00, myungjoo.ham, kyungmin.park

This patch fixes NULL pointer error by removing the unneeded kfree() call
of edev->name because extcon-palmas no longer allocate the memory for edev->name.

Fixes: d71aadda19f8 ("extcon: Remove the optional name of extcon device")
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
---
 drivers/extcon/extcon-palmas.c | 7 -------
 1 file changed, 7 deletions(-)

diff --git a/drivers/extcon/extcon-palmas.c b/drivers/extcon/extcon-palmas.c
index 080d5cc..4e7335f 100644
--- a/drivers/extcon/extcon-palmas.c
+++ b/drivers/extcon/extcon-palmas.c
@@ -200,7 +200,6 @@ static int palmas_usb_probe(struct platform_device *pdev)
 	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);
 		return status;
 	}
 
@@ -214,7 +213,6 @@ 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);
-			kfree(palmas_usb->edev->name);
 			return status;
 		}
 	}
@@ -229,7 +227,6 @@ 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);
-			kfree(palmas_usb->edev->name);
 			return status;
 		}
 	}
@@ -241,10 +238,6 @@ static int palmas_usb_probe(struct platform_device *pdev)
 
 static int palmas_usb_remove(struct platform_device *pdev)
 {
-	struct palmas_usb *palmas_usb = platform_get_drvdata(pdev);
-
-	kfree(palmas_usb->edev->name);
-
 	return 0;
 }
 
-- 
2.2.0.GIT


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

* [PATCH 4/4] extcon: palmas: Remove the mutually_exclusive array
  2015-06-19  6:48 [PATCH 0/4] extcon: Clean-up the minor issue and fix the NULL pointer error Chanwoo Choi
                   ` (2 preceding siblings ...)
  2015-06-19  6:48 ` [PATCH 3/4] extcon: palmas: Fix NULL pointer error Chanwoo Choi
@ 2015-06-19  6:48 ` Chanwoo Choi
  3 siblings, 0 replies; 7+ messages in thread
From: Chanwoo Choi @ 2015-06-19  6:48 UTC (permalink / raw)
  Cc: linux-kernel, cwchoi00, myungjoo.ham, kyungmin.park

This patch removes the mutually_exclusive array of extcon-palmas.c.
After used the unique id of each external connector on 2a9de9c0f08d
("extcon: Use the unique id for external connector instead of string"),
extcon driver can't directly handle the bit value indicating the external
connectors.

Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
---
 drivers/extcon/extcon-palmas.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/extcon/extcon-palmas.c b/drivers/extcon/extcon-palmas.c
index 4e7335f..12ce2a3 100644
--- a/drivers/extcon/extcon-palmas.c
+++ b/drivers/extcon/extcon-palmas.c
@@ -35,8 +35,6 @@ static const unsigned int palmas_extcon_cable[] = {
 	EXTCON_NONE,
 };
 
-static const int mutually_exclusive[] = {0x3, 0x0};
-
 static void palmas_usb_wakeup(struct palmas *palmas, int enable)
 {
 	if (enable)
@@ -195,7 +193,6 @@ static int palmas_usb_probe(struct platform_device *pdev)
 		dev_err(&pdev->dev, "failed to allocate extcon device\n");
 		return -ENOMEM;
 	}
-	palmas_usb->edev->mutually_exclusive = mutually_exclusive;
 
 	status = devm_extcon_dev_register(&pdev->dev, palmas_usb->edev);
 	if (status) {
-- 
2.2.0.GIT


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

* Re: [PATCH 3/4] extcon: palmas: Fix NULL pointer error
  2015-06-19  6:48 ` [PATCH 3/4] extcon: palmas: Fix NULL pointer error Chanwoo Choi
@ 2015-06-22  0:45   ` Krzysztof Kozlowski
  2015-06-22  0:58     ` Chanwoo Choi
  0 siblings, 1 reply; 7+ messages in thread
From: Krzysztof Kozlowski @ 2015-06-22  0:45 UTC (permalink / raw)
  To: Chanwoo Choi; +Cc: linux-kernel, myungjoo.ham, kyungmin.park

2015-06-19 15:48 GMT+09:00 Chanwoo Choi <cwchoi00@gmail.com>:
> This patch fixes NULL pointer error by removing the unneeded kfree() call
> of edev->name because extcon-palmas no longer allocate the memory for edev->name.

So the kfree() was executed on pointer returned by "dev_name(edev->dev.parent)"?



> Fixes: d71aadda19f8 ("extcon: Remove the optional name of extcon device")
> Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
> ---
>  drivers/extcon/extcon-palmas.c | 7 -------
>  1 file changed, 7 deletions(-)
>
> diff --git a/drivers/extcon/extcon-palmas.c b/drivers/extcon/extcon-palmas.c
> index 080d5cc..4e7335f 100644
> --- a/drivers/extcon/extcon-palmas.c
> +++ b/drivers/extcon/extcon-palmas.c
> @@ -200,7 +200,6 @@ static int palmas_usb_probe(struct platform_device *pdev)
>         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);
>                 return status;
>         }
>
> @@ -214,7 +213,6 @@ 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);
> -                       kfree(palmas_usb->edev->name);
>                         return status;
>                 }
>         }
> @@ -229,7 +227,6 @@ 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);
> -                       kfree(palmas_usb->edev->name);
>                         return status;
>                 }
>         }
> @@ -241,10 +238,6 @@ static int palmas_usb_probe(struct platform_device *pdev)
>
>  static int palmas_usb_remove(struct platform_device *pdev)
>  {
> -       struct palmas_usb *palmas_usb = platform_get_drvdata(pdev);
> -
> -       kfree(palmas_usb->edev->name);
> -
>         return 0;
>  }

The remove function is now no-op so I think you can remove it. The
platform driver code executes it only if it is non-NULL.

Best regards,
Krzysztof
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
Please read the FAQ at  http://www.tux.org/lkml/

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

* Re: [PATCH 3/4] extcon: palmas: Fix NULL pointer error
  2015-06-22  0:45   ` Krzysztof Kozlowski
@ 2015-06-22  0:58     ` Chanwoo Choi
  0 siblings, 0 replies; 7+ messages in thread
From: Chanwoo Choi @ 2015-06-22  0:58 UTC (permalink / raw)
  To: Krzysztof Kozlowski; +Cc: linux-kernel, myungjoo.ham, Kyungmin Park

On Mon, Jun 22, 2015 at 9:45 AM, Krzysztof Kozlowski
<k.kozlowski@samsung.com> wrote:
> 2015-06-19 15:48 GMT+09:00 Chanwoo Choi <cwchoi00@gmail.com>:
>> This patch fixes NULL pointer error by removing the unneeded kfree() call
>> of edev->name because extcon-palmas no longer allocate the memory for edev->name.
>
> So the kfree() was executed on pointer returned by "dev_name(edev->dev.parent)"?
>

Right.

>
>> Fixes: d71aadda19f8 ("extcon: Remove the optional name of extcon device")
>> Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
>> ---
>>  drivers/extcon/extcon-palmas.c | 7 -------
>>  1 file changed, 7 deletions(-)
>>
>> diff --git a/drivers/extcon/extcon-palmas.c b/drivers/extcon/extcon-palmas.c
>> index 080d5cc..4e7335f 100644
>> --- a/drivers/extcon/extcon-palmas.c
>> +++ b/drivers/extcon/extcon-palmas.c
>> @@ -200,7 +200,6 @@ static int palmas_usb_probe(struct platform_device *pdev)
>>         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);
>>                 return status;
>>         }
>>
>> @@ -214,7 +213,6 @@ 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);
>> -                       kfree(palmas_usb->edev->name);
>>                         return status;
>>                 }
>>         }
>> @@ -229,7 +227,6 @@ 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);
>> -                       kfree(palmas_usb->edev->name);
>>                         return status;
>>                 }
>>         }
>> @@ -241,10 +238,6 @@ static int palmas_usb_probe(struct platform_device *pdev)
>>
>>  static int palmas_usb_remove(struct platform_device *pdev)
>>  {
>> -       struct palmas_usb *palmas_usb = platform_get_drvdata(pdev);
>> -
>> -       kfree(palmas_usb->edev->name);
>> -
>>         return 0;
>>  }
>
> The remove function is now no-op so I think you can remove it. The
> platform driver code executes it only if it is non-NULL.

OK.

Thanks,
Chanwoo Choi
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
Please read the FAQ at  http://www.tux.org/lkml/

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

end of thread, other threads:[~2015-06-22  0:58 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-19  6:48 [PATCH 0/4] extcon: Clean-up the minor issue and fix the NULL pointer error Chanwoo Choi
2015-06-19  6:48 ` [PATCH 1/4] extcon: Remove duplicate header file in extcon.h Chanwoo Choi
2015-06-19  6:48 ` [PATCH 2/4] extcon: Remove optional print_state() function pointer of struct extcon_dev Chanwoo Choi
2015-06-19  6:48 ` [PATCH 3/4] extcon: palmas: Fix NULL pointer error Chanwoo Choi
2015-06-22  0:45   ` Krzysztof Kozlowski
2015-06-22  0:58     ` Chanwoo Choi
2015-06-19  6:48 ` [PATCH 4/4] extcon: palmas: Remove the mutually_exclusive array Chanwoo Choi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®