All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 1/3] extcon: axp288: Constify the axp288_pwr_up_down_info array
@ 2018-02-12 19:46 ` Hans de Goede
  2018-02-12 19:46   ` [PATCH v3 2/3] Revert "extcon: axp288: Redo charger type detection a couple of seconds after probe()" Hans de Goede
                     ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Hans de Goede @ 2018-02-12 19:46 UTC (permalink / raw)
  To: MyungJoo Ham, Chanwoo Choi; +Cc: Hans de Goede, linux-kernel

Make the axp288_pwr_up_down_info array const char * const, this leads
to the following section size changes:

.text     0x674 -> 0x664
.data     0x148 -> 0x0f0
.rodata   0x0b4 -> 0x114

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 drivers/extcon/extcon-axp288.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/extcon/extcon-axp288.c b/drivers/extcon/extcon-axp288.c
index 0a44d43802fe..c8f7b6435679 100644
--- a/drivers/extcon/extcon-axp288.c
+++ b/drivers/extcon/extcon-axp288.c
@@ -106,7 +106,7 @@ struct axp288_extcon_info {
 };
 
 /* Power up/down reason string array */
-static char *axp288_pwr_up_down_info[] = {
+static const char * const axp288_pwr_up_down_info[] = {
 	"Last wake caused by user pressing the power button",
 	"Last wake caused by a charger insertion",
 	"Last wake caused by a battery insertion",
@@ -124,7 +124,7 @@ static char *axp288_pwr_up_down_info[] = {
  */
 static void axp288_extcon_log_rsi(struct axp288_extcon_info *info)
 {
-	char **rsi;
+	const char * const *rsi;
 	unsigned int val, i, clear_mask = 0;
 	int ret;
 
-- 
2.14.3

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

* [PATCH v3 2/3] Revert "extcon: axp288: Redo charger type detection a couple of seconds after probe()"
  2018-02-12 19:46 ` [PATCH v3 1/3] extcon: axp288: Constify the axp288_pwr_up_down_info array Hans de Goede
@ 2018-02-12 19:46   ` Hans de Goede
  2018-02-12 21:50     ` Chanwoo Choi
  2018-02-12 19:46   ` [PATCH v3 3/3] extcon: int3496: process id-pin first so that we start with the right status Hans de Goede
  2018-02-12 21:50   ` [PATCH v3 1/3] extcon: axp288: Constify the axp288_pwr_up_down_info array Chanwoo Choi
  2 siblings, 1 reply; 6+ messages in thread
From: Hans de Goede @ 2018-02-12 19:46 UTC (permalink / raw)
  To: MyungJoo Ham, Chanwoo Choi; +Cc: Hans de Goede, linux-kernel

Redoing the charger type detection to give the usb-role-switch code time
to properly set the role-switch is no good for mainline, since the
usb-role-switch code is not yet in mainline (my bad, sorry).

Also once we've that code there are better ways to fix this which are
not prone to racing as doing a retry after 2 seconds is.

This reverts commit 50082c17bb1455acacd376ae30dff92f2e1addbd.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 drivers/extcon/extcon-axp288.c | 32 ++------------------------------
 1 file changed, 2 insertions(+), 30 deletions(-)

diff --git a/drivers/extcon/extcon-axp288.c b/drivers/extcon/extcon-axp288.c
index c8f7b6435679..3ec4c715e240 100644
--- a/drivers/extcon/extcon-axp288.c
+++ b/drivers/extcon/extcon-axp288.c
@@ -1,7 +1,6 @@
 /*
  * extcon-axp288.c - X-Power AXP288 PMIC extcon cable detection driver
  *
- * Copyright (C) 2016-2017 Hans de Goede <hdegoede@redhat.com>
  * Copyright (C) 2015 Intel Corporation
  * Author: Ramakrishna Pallala <ramakrishna.pallala@intel.com>
  *
@@ -98,11 +97,9 @@ struct axp288_extcon_info {
 	struct device *dev;
 	struct regmap *regmap;
 	struct regmap_irq_chip_data *regmap_irqc;
-	struct delayed_work det_work;
 	int irq[EXTCON_IRQ_END];
 	struct extcon_dev *edev;
 	unsigned int previous_cable;
-	bool first_detect_done;
 };
 
 /* Power up/down reason string array */
@@ -140,25 +137,6 @@ static void axp288_extcon_log_rsi(struct axp288_extcon_info *info)
 	regmap_write(info->regmap, AXP288_PS_BOOT_REASON_REG, clear_mask);
 }
 
-static void axp288_chrg_detect_complete(struct axp288_extcon_info *info)
-{
-	/*
-	 * We depend on other drivers to do things like mux the data lines,
-	 * enable/disable vbus based on the id-pin, etc. Sometimes the BIOS has
-	 * not set these things up correctly resulting in the initial charger
-	 * cable type detection giving a wrong result and we end up not charging
-	 * or charging at only 0.5A.
-	 *
-	 * So we schedule a second cable type detection after 2 seconds to
-	 * give the other drivers time to load and do their thing.
-	 */
-	if (!info->first_detect_done) {
-		queue_delayed_work(system_wq, &info->det_work,
-				   msecs_to_jiffies(2000));
-		info->first_detect_done = true;
-	}
-}
-
 static int axp288_handle_chrg_det_event(struct axp288_extcon_info *info)
 {
 	int ret, stat, cfg, pwr_stat;
@@ -223,8 +201,6 @@ static int axp288_handle_chrg_det_event(struct axp288_extcon_info *info)
 		info->previous_cable = cable;
 	}
 
-	axp288_chrg_detect_complete(info);
-
 	return 0;
 
 dev_det_ret:
@@ -246,11 +222,8 @@ static irqreturn_t axp288_extcon_isr(int irq, void *data)
 	return IRQ_HANDLED;
 }
 
-static void axp288_extcon_det_work(struct work_struct *work)
+static void axp288_extcon_enable(struct axp288_extcon_info *info)
 {
-	struct axp288_extcon_info *info =
-		container_of(work, struct axp288_extcon_info, det_work.work);
-
 	regmap_update_bits(info->regmap, AXP288_BC_GLOBAL_REG,
 						BC_GLOBAL_RUN, 0);
 	/* Enable the charger detection logic */
@@ -272,7 +245,6 @@ static int axp288_extcon_probe(struct platform_device *pdev)
 	info->regmap = axp20x->regmap;
 	info->regmap_irqc = axp20x->regmap_irqc;
 	info->previous_cable = EXTCON_NONE;
-	INIT_DELAYED_WORK(&info->det_work, axp288_extcon_det_work);
 
 	platform_set_drvdata(pdev, info);
 
@@ -318,7 +290,7 @@ static int axp288_extcon_probe(struct platform_device *pdev)
 	}
 
 	/* Start charger cable type detection */
-	queue_delayed_work(system_wq, &info->det_work, 0);
+	axp288_extcon_enable(info);
 
 	return 0;
 }
-- 
2.14.3

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

* [PATCH v3 3/3] extcon: int3496: process id-pin first so that we start with the right status
  2018-02-12 19:46 ` [PATCH v3 1/3] extcon: axp288: Constify the axp288_pwr_up_down_info array Hans de Goede
  2018-02-12 19:46   ` [PATCH v3 2/3] Revert "extcon: axp288: Redo charger type detection a couple of seconds after probe()" Hans de Goede
@ 2018-02-12 19:46   ` Hans de Goede
  2018-02-12 21:50     ` Chanwoo Choi
  2018-02-12 21:50   ` [PATCH v3 1/3] extcon: axp288: Constify the axp288_pwr_up_down_info array Chanwoo Choi
  2 siblings, 1 reply; 6+ messages in thread
From: Hans de Goede @ 2018-02-12 19:46 UTC (permalink / raw)
  To: MyungJoo Ham, Chanwoo Choi; +Cc: Hans de Goede, linux-kernel, stable

Some other drivers may be waiting for our extcon to show-up (exiting their
probe methods with -EPROBE_DEFER until we show up).

These drivers will typically get the cable state directly after getting
the extcon, this commit changes the int3496 code to process the id-pin
before registering the extcon, so that other drivers see the correct state
right away.

Fixes: 2f556bdb9f2e ("extcon: int3496: Add Intel INT3496 ACPI ... driver")
Cc: stable@vger.kernel.org
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
Changes in v2:
-Add Fixes tag

Changes in v3:
-Fix oops on probe by scheduling the work too early
---
 drivers/extcon/extcon-intel-int3496.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/extcon/extcon-intel-int3496.c b/drivers/extcon/extcon-intel-int3496.c
index c8691b5a9cb0..673bb26a9a2a 100644
--- a/drivers/extcon/extcon-intel-int3496.c
+++ b/drivers/extcon/extcon-intel-int3496.c
@@ -131,11 +131,15 @@ static int int3496_probe(struct platform_device *pdev)
 	if (IS_ERR(data->gpio_usb_mux))
 		dev_info(dev, "can't request USB MUX GPIO\n");
 
-	/* register extcon device */
 	data->edev = devm_extcon_dev_allocate(dev, int3496_cable);
 	if (IS_ERR(data->edev))
 		return -ENOMEM;
 
+	/* process id-pin first so that we start with the right status */
+	queue_delayed_work(system_wq, &data->work, 0);
+	flush_delayed_work(&data->work);
+
+	/* register extcon device */
 	ret = devm_extcon_dev_register(dev, data->edev);
 	if (ret < 0) {
 		dev_err(dev, "can't register extcon device: %d\n", ret);
@@ -153,9 +157,6 @@ static int int3496_probe(struct platform_device *pdev)
 		return ret;
 	}
 
-	/* queue initial processing of id-pin */
-	queue_delayed_work(system_wq, &data->work, 0);
-
 	platform_set_drvdata(pdev, data);
 
 	return 0;
-- 
2.14.3

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

* Re: [PATCH v3 1/3] extcon: axp288: Constify the axp288_pwr_up_down_info array
  2018-02-12 19:46 ` [PATCH v3 1/3] extcon: axp288: Constify the axp288_pwr_up_down_info array Hans de Goede
  2018-02-12 19:46   ` [PATCH v3 2/3] Revert "extcon: axp288: Redo charger type detection a couple of seconds after probe()" Hans de Goede
  2018-02-12 19:46   ` [PATCH v3 3/3] extcon: int3496: process id-pin first so that we start with the right status Hans de Goede
@ 2018-02-12 21:50   ` Chanwoo Choi
  2 siblings, 0 replies; 6+ messages in thread
From: Chanwoo Choi @ 2018-02-12 21:50 UTC (permalink / raw)
  To: Hans de Goede, MyungJoo Ham; +Cc: linux-kernel

On 2018년 02월 13일 04:46, Hans de Goede wrote:
> Make the axp288_pwr_up_down_info array const char * const, this leads
> to the following section size changes:
> 
> .text     0x674 -> 0x664
> .data     0x148 -> 0x0f0
> .rodata   0x0b4 -> 0x114
> 
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
> ---
>  drivers/extcon/extcon-axp288.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/extcon/extcon-axp288.c b/drivers/extcon/extcon-axp288.c
> index 0a44d43802fe..c8f7b6435679 100644
> --- a/drivers/extcon/extcon-axp288.c
> +++ b/drivers/extcon/extcon-axp288.c
> @@ -106,7 +106,7 @@ struct axp288_extcon_info {
>  };
>  
>  /* Power up/down reason string array */
> -static char *axp288_pwr_up_down_info[] = {
> +static const char * const axp288_pwr_up_down_info[] = {
>  	"Last wake caused by user pressing the power button",
>  	"Last wake caused by a charger insertion",
>  	"Last wake caused by a battery insertion",
> @@ -124,7 +124,7 @@ static char *axp288_pwr_up_down_info[] = {
>   */
>  static void axp288_extcon_log_rsi(struct axp288_extcon_info *info)
>  {
> -	char **rsi;
> +	const char * const *rsi;
>  	unsigned int val, i, clear_mask = 0;
>  	int ret;
>  
> 

Applied it.

-- 
Best Regards,
Chanwoo Choi
Samsung Electronics

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

* Re: [PATCH v3 2/3] Revert "extcon: axp288: Redo charger type detection a couple of seconds after probe()"
  2018-02-12 19:46   ` [PATCH v3 2/3] Revert "extcon: axp288: Redo charger type detection a couple of seconds after probe()" Hans de Goede
@ 2018-02-12 21:50     ` Chanwoo Choi
  0 siblings, 0 replies; 6+ messages in thread
From: Chanwoo Choi @ 2018-02-12 21:50 UTC (permalink / raw)
  To: Hans de Goede, MyungJoo Ham; +Cc: linux-kernel

On 2018년 02월 13일 04:46, Hans de Goede wrote:
> Redoing the charger type detection to give the usb-role-switch code time
> to properly set the role-switch is no good for mainline, since the
> usb-role-switch code is not yet in mainline (my bad, sorry).
> 
> Also once we've that code there are better ways to fix this which are
> not prone to racing as doing a retry after 2 seconds is.
> 
> This reverts commit 50082c17bb1455acacd376ae30dff92f2e1addbd.
> 
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
> ---
>  drivers/extcon/extcon-axp288.c | 32 ++------------------------------
>  1 file changed, 2 insertions(+), 30 deletions(-)

Applied it.

[snip]

-- 
Best Regards,
Chanwoo Choi
Samsung Electronics

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

* Re: [PATCH v3 3/3] extcon: int3496: process id-pin first so that we start with the right status
  2018-02-12 19:46   ` [PATCH v3 3/3] extcon: int3496: process id-pin first so that we start with the right status Hans de Goede
@ 2018-02-12 21:50     ` Chanwoo Choi
  0 siblings, 0 replies; 6+ messages in thread
From: Chanwoo Choi @ 2018-02-12 21:50 UTC (permalink / raw)
  To: Hans de Goede, MyungJoo Ham; +Cc: linux-kernel, stable

On 2018년 02월 13일 04:46, Hans de Goede wrote:
> Some other drivers may be waiting for our extcon to show-up (exiting their
> probe methods with -EPROBE_DEFER until we show up).
> 
> These drivers will typically get the cable state directly after getting
> the extcon, this commit changes the int3496 code to process the id-pin
> before registering the extcon, so that other drivers see the correct state
> right away.
> 
> Fixes: 2f556bdb9f2e ("extcon: int3496: Add Intel INT3496 ACPI ... driver")
> Cc: stable@vger.kernel.org
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
> ---
> Changes in v2:
> -Add Fixes tag
> 
> Changes in v3:
> -Fix oops on probe by scheduling the work too early
> ---
>  drivers/extcon/extcon-intel-int3496.c | 9 +++++----
>  1 file changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/extcon/extcon-intel-int3496.c b/drivers/extcon/extcon-intel-int3496.c
> index c8691b5a9cb0..673bb26a9a2a 100644
> --- a/drivers/extcon/extcon-intel-int3496.c
> +++ b/drivers/extcon/extcon-intel-int3496.c
> @@ -131,11 +131,15 @@ static int int3496_probe(struct platform_device *pdev)
>  	if (IS_ERR(data->gpio_usb_mux))
>  		dev_info(dev, "can't request USB MUX GPIO\n");
>  
> -	/* register extcon device */
>  	data->edev = devm_extcon_dev_allocate(dev, int3496_cable);
>  	if (IS_ERR(data->edev))
>  		return -ENOMEM;
>  
> +	/* process id-pin first so that we start with the right status */
> +	queue_delayed_work(system_wq, &data->work, 0);
> +	flush_delayed_work(&data->work);
> +
> +	/* register extcon device */
>  	ret = devm_extcon_dev_register(dev, data->edev);
>  	if (ret < 0) {
>  		dev_err(dev, "can't register extcon device: %d\n", ret);
> @@ -153,9 +157,6 @@ static int int3496_probe(struct platform_device *pdev)
>  		return ret;
>  	}
>  
> -	/* queue initial processing of id-pin */
> -	queue_delayed_work(system_wq, &data->work, 0);
> -
>  	platform_set_drvdata(pdev, data);
>  
>  	return 0;
> 

Applied it.

-- 
Best Regards,
Chanwoo Choi
Samsung Electronics

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

end of thread, other threads:[~2018-02-12 21:50 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CGME20180212194646epcas3p4de9a5b929ea45edb11f7e5b509b6cf98@epcas3p4.samsung.com>
2018-02-12 19:46 ` [PATCH v3 1/3] extcon: axp288: Constify the axp288_pwr_up_down_info array Hans de Goede
2018-02-12 19:46   ` [PATCH v3 2/3] Revert "extcon: axp288: Redo charger type detection a couple of seconds after probe()" Hans de Goede
2018-02-12 21:50     ` Chanwoo Choi
2018-02-12 19:46   ` [PATCH v3 3/3] extcon: int3496: process id-pin first so that we start with the right status Hans de Goede
2018-02-12 21:50     ` Chanwoo Choi
2018-02-12 21:50   ` [PATCH v3 1/3] extcon: axp288: Constify the axp288_pwr_up_down_info array Chanwoo Choi

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