From patchwork Thu Jun 2 06:44:57 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: chris@lapa.com.au X-Patchwork-Id: 9149265 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 1E0B460467 for ; Thu, 2 Jun 2016 06:45:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 10F402654B for ; Thu, 2 Jun 2016 06:45:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 05DA528236; Thu, 2 Jun 2016 06:45:38 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A38BC2654B for ; Thu, 2 Jun 2016 06:45:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932182AbcFBGpM (ORCPT ); Thu, 2 Jun 2016 02:45:12 -0400 Received: from mail-pa0-f66.google.com ([209.85.220.66]:34821 "EHLO mail-pa0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932178AbcFBGpI (ORCPT ); Thu, 2 Jun 2016 02:45:08 -0400 Received: by mail-pa0-f66.google.com with SMTP id gp3so2478769pac.2 for ; Wed, 01 Jun 2016 23:45:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lapa-com-au.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=EjqVoFS4ZKxiTuewWSmWpVGwMRc7UQk7vwUgz4J/RzM=; b=Jj5trZ+niDF/tpApz0QcPDn/xQtMF9HQHPwo7uQi2pbaiTyL60YP1Yc/jW7aW++t2p pkp1LPyg9mzDAoAnyQnwcA+/9DlOISzheG4I8af0l1nGjofkPvxaBFh2YGeIpyT6280A yZOuoIFcISh9PXDxubFG+oTjt1uXLouB0V+MPs5LrE7+g9ax2jaX28q7tpJ3/a1joXBy gKi2RWy9nXEiC9H7JIbxE+/J28GpvZ4JpzKf09jCwWXTeHj7qzzinFZwipNLcNrV6nf6 MHGDkN8uwiEeyYOxNDuUgndcIrci8g+hklvt2bDF5kn31g7a7iqtjcvcOG/ntdo8t2eL DGzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=EjqVoFS4ZKxiTuewWSmWpVGwMRc7UQk7vwUgz4J/RzM=; b=nNso5iIKezJSLuol61eNBeJMk3wILTmkjaiK12u94JkgLFRA6JBbequ6VtqnUVJtr0 Q5zcdoAqXRtwL5V1vX2WTT5iQp2wjSg82/8Ye3i8b1g4nAd07X2QWy3OrouHyiAYUult p7mJ+nlnQ4KxImf8+NO9CniPXIQ7eVHdMAnSRxNiH4j8fHBd0gFBsauRkLiLAZg6I5NW 9deApcB3AdzTGPswbKabvJfpJt4ZCq2liATgskOZnTHiuRb1fqsiSLoe8/kUQvzh6mSm +QJz+wBPRyOh+LLqMp1rkJE/FiaswJbj2DI8YXGHqfnYXc3qR4vBwvXJlmcHVtySGHhE Zoeg== X-Gm-Message-State: ALyK8tKlwI6QgBH6z8CLsHfkh5fXBSJXlYKL3R6t2TqLbzOu/U6+sdmW4lfsOjOzmzZYRQ== X-Received: by 10.66.141.139 with SMTP id ro11mr3319959pab.74.1464849907681; Wed, 01 Jun 2016 23:45:07 -0700 (PDT) Received: from bbb-dev.management.cpd (163.164.70.115.static.exetel.com.au. [115.70.164.163]) by smtp.gmail.com with ESMTPSA id p4sm67212593pac.1.2016.06.01.23.45.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 01 Jun 2016 23:45:07 -0700 (PDT) From: chris@lapa.com.au To: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org Cc: Chris Lapa Subject: [PATCH 2/2] max8903: cleans up confusing relationship between dc_valid, dok and dcm. Date: Thu, 2 Jun 2016 16:44:57 +1000 Message-Id: <1464849897-21527-3-git-send-email-chris@lapa.com.au> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1464849897-21527-1-git-send-email-chris@lapa.com.au> References: <1464849897-21527-1-git-send-email-chris@lapa.com.au> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Chris Lapa The max8903_charger.h file indicated that dcm and dok were not optional when dc_valid is set. It makes sense to have dok as a compulsory pin when dc_valid is given. However dcm can be optionally wired to a fixed level especially when the circuit is configured for dc power exclusively. The previous implementation already allowed for this somewhat, however no error was given if dok wasn't given whilst dc_valid was. The new implementation enforces dok presence when dc_valid is given. Whilst allowing dcm to be optional. Signed-off-by: Chris Lapa --- drivers/power/max8903_charger.c | 40 ++++++++++++----------------------- include/linux/power/max8903_charger.h | 6 +++--- 2 files changed, 17 insertions(+), 29 deletions(-) diff --git a/drivers/power/max8903_charger.c b/drivers/power/max8903_charger.c index 1989c10..d3c09f9 100644 --- a/drivers/power/max8903_charger.c +++ b/drivers/power/max8903_charger.c @@ -290,8 +290,7 @@ static int max8903_probe(struct platform_device *pdev) } if (charger->pdata->dc_valid) { - if (charger->pdata->dok && gpio_is_valid(charger->pdata->dok) && - charger->pdata->dcm && gpio_is_valid(charger->pdata->dcm)) { + if (charger->pdata->dok && gpio_is_valid(charger->pdata->dok)) { ret = devm_gpio_request(dev, charger->pdata->dok, charger->psy_desc.name); @@ -302,6 +301,17 @@ static int max8903_probe(struct platform_device *pdev) return -EINVAL; } + gpio = charger->pdata->dok; /* PULL_UPed Interrupt */ + ta_in = gpio_get_value(gpio) ? 0 : 1; + } else { + dev_err(dev, "When DC is wired, DOK should" + " be wired as well.\n"); + return -EINVAL; + } + } + + if (charger->pdata->dcm) { + if (gpio_is_valid(charger->pdata->dcm)) { ret = devm_gpio_request(dev, charger->pdata->dcm, charger->psy_desc.name); @@ -312,35 +322,13 @@ static int max8903_probe(struct platform_device *pdev) return -EINVAL; } - gpio = pdata->dok; /* PULL_UPed Interrupt */ - ta_in = gpio_get_value(gpio) ? 0 : 1; - gpio = pdata->dcm; /* Output */ + gpio = charger->pdata->dcm; /* Output */ gpio_set_value(gpio, ta_in); } else { - dev_err(dev, "When DC is wired, DOK and DCM should" - " be wired as well.\n"); + dev_err(dev, "Invalid pin: dcm.\n"); return -EINVAL; } - } else { - if (pdata->dcm) { - if (gpio_is_valid(pdata->dcm)) { - ret = devm_gpio_request(dev, - charger->pdata->dcm, - charger->psy_desc.name); - if (ret) { - dev_err(dev, - "Failed GPIO request for dcm: %d err %d\n", - charger->pdata->dcm, ret); - return -EINVAL; - } - - gpio_set_value(pdata->dcm, 0); - } else { - dev_err(dev, "Invalid pin: dcm.\n"); - return -EINVAL; - } - } } if (charger->pdata->usb_valid) { diff --git a/include/linux/power/max8903_charger.h b/include/linux/power/max8903_charger.h index 24f51db..89d3f1c 100644 --- a/include/linux/power/max8903_charger.h +++ b/include/linux/power/max8903_charger.h @@ -26,8 +26,8 @@ struct max8903_pdata { /* * GPIOs - * cen, chg, flt, and usus are optional. - * dok, dcm, and uok are not optional depending on the status of + * cen, chg, flt, dcm and usus are optional. + * dok and uok are not optional depending on the status of * dc_valid and usb_valid. */ int cen; /* Charger Enable input */ @@ -41,7 +41,7 @@ struct max8903_pdata { /* * DC(Adapter/TA) is wired * When dc_valid is true, - * dok and dcm should be valid. + * dok should be valid. * * At least one of dc_valid or usb_valid should be true. */