diff mbox

power: supply: charger-manager: Verify polling interval only when polling requested

Message ID 20180321155000.GA7528@lenoch (mailing list archive)
State Not Applicable, archived
Headers show

Commit Message

Ladislav Michl March 21, 2018, 3:50 p.m. UTC
Driver bails out with -EINVAL when no polling specififaion is requested.
Fix that by verifing polling interval only if polling_mode is different
from CM_POLL_DISABLE.

Signed-off-by: Ladislav Michl <ladis@linux-mips.org>
---
 drivers/power/supply/charger-manager.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

Sebastian Reichel April 25, 2018, 10:03 p.m. UTC | #1
Hi,

On Wed, Mar 21, 2018 at 04:50:00PM +0100, Ladislav Michl wrote:
> Driver bails out with -EINVAL when no polling specififaion is requested.
> Fix that by verifing polling interval only if polling_mode is different
> from CM_POLL_DISABLE.
> 
> Signed-off-by: Ladislav Michl <ladis@linux-mips.org>
> ---

Thanks, queued.

-- Sebastian

>  drivers/power/supply/charger-manager.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/power/supply/charger-manager.c b/drivers/power/supply/charger-manager.c
> index 1de4b4493824..2a50b4654793 100644
> --- a/drivers/power/supply/charger-manager.c
> +++ b/drivers/power/supply/charger-manager.c
> @@ -1700,8 +1700,9 @@ static int charger_manager_probe(struct platform_device *pdev)
>  		power_supply_put(psy);
>  	}
>  
> -	if (desc->polling_interval_ms == 0 ||
> -	    msecs_to_jiffies(desc->polling_interval_ms) <= CM_JIFFIES_SMALL) {
> +	if (cm->desc->polling_mode != CM_POLL_DISABLE &&
> +	    (desc->polling_interval_ms == 0 ||
> +	     msecs_to_jiffies(desc->polling_interval_ms) <= CM_JIFFIES_SMALL)) {
>  		dev_err(&pdev->dev, "polling_interval_ms is too small\n");
>  		return -EINVAL;
>  	}
> -- 
> 2.16.2
>
diff mbox

Patch

diff --git a/drivers/power/supply/charger-manager.c b/drivers/power/supply/charger-manager.c
index 1de4b4493824..2a50b4654793 100644
--- a/drivers/power/supply/charger-manager.c
+++ b/drivers/power/supply/charger-manager.c
@@ -1700,8 +1700,9 @@  static int charger_manager_probe(struct platform_device *pdev)
 		power_supply_put(psy);
 	}
 
-	if (desc->polling_interval_ms == 0 ||
-	    msecs_to_jiffies(desc->polling_interval_ms) <= CM_JIFFIES_SMALL) {
+	if (cm->desc->polling_mode != CM_POLL_DISABLE &&
+	    (desc->polling_interval_ms == 0 ||
+	     msecs_to_jiffies(desc->polling_interval_ms) <= CM_JIFFIES_SMALL)) {
 		dev_err(&pdev->dev, "polling_interval_ms is too small\n");
 		return -EINVAL;
 	}