From patchwork Sun Jun 19 22:27:17 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: 9186747 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 27B9860756 for ; Mon, 20 Jun 2016 07:19:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0BDBF24B48 for ; Mon, 20 Jun 2016 07:19:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F28A324B5E; Mon, 20 Jun 2016 07:19:22 +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=-5.2 required=2.0 tests=BAYES_00, DATE_IN_PAST_06_12, DKIM_SIGNED, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham 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 3FFDB24B48 for ; Mon, 20 Jun 2016 07:19:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751846AbcFTHTV (ORCPT ); Mon, 20 Jun 2016 03:19:21 -0400 Received: from mail-pf0-f193.google.com ([209.85.192.193]:36290 "EHLO mail-pf0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751705AbcFTHTU (ORCPT ); Mon, 20 Jun 2016 03:19:20 -0400 Received: by mail-pf0-f193.google.com with SMTP id i123so7973810pfg.3 for ; Mon, 20 Jun 2016 00:19:20 -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 :in-reply-to:references; bh=EZmGbT6bK5GMYH4GLe7RAKCoIOiU8OE/Fr5aLahjf0U=; b=TehQVIf8F0M5MIIuofG2lBW33EP7pLIpJQz6Nq92B003qdWYFJvKBUHIULagL3+8pk sCaEvwy+tNAnvpWVShsIXO86ITpWy7/8RxsQV5gxx9yETowwa7L8U+y9FpFEtf3sD6Kr LAgWKMWBsCRAHdclzU0AS6Tw3JTesRsENAYl3su3k7y8YgkoVcSxTtXgdrksd4poVlH2 +34RiFAeWmyfmLtuXfEoUCUJUsjNoDE2djy2IIEjeVze/J0imtpzWBDay6kinHiIdaZr 1glSMmFBBW9prB7HR9B5G6uPrSzhdI0Po+4Mi2o7zgb/QnUg9NMbx5XIv3pJ4RJ9y9gc rCgg== 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:in-reply-to:references; bh=EZmGbT6bK5GMYH4GLe7RAKCoIOiU8OE/Fr5aLahjf0U=; b=eGASVNsLs/MFk8NXTV5Npp/E7ihld47DKTkYA6vf8AHLbpUL3oo5FeaHOIaDRSCNBS Rul4LZAUF7MF47NKldDg+9fRq3e4DNt1xDEdptuI2L7Defo1X+VQZAtQUwQC8RIITv4r HHVjtsk0aGVHOwywtSYotkMfuIf+2hI6hm0YXPLw5y1Dw3O7lQlzFDpRWv8Ocl4fPySL XoVJenBZW+6G9msKURKtrB49BBq8OWyIqT4wEJAIX9EQ4qTpmsxTIFqEgjHRLXLAEXlV l58323WKFWyHnljSIpwAywqPnJEyzDsKgs+uXGQINN1IBkS5uOhTuCfBcBLKS5c5zaLl NhOQ== X-Gm-Message-State: ALyK8tLJolHFELPvfBDXNndzm446OPWct3d72AKfmQzFbciv1qOfpRfx4sFzMcR1c+BirA== X-Received: by 10.98.152.210 with SMTP id d79mr20518675pfk.2.1466406437668; Mon, 20 Jun 2016 00:07:17 -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 h5sm78872398pfb.81.2016.06.20.00.07.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 Jun 2016 00:07:17 -0700 (PDT) From: Chris Lapa X-Google-Original-From: Chris Lapa To: k.kozlowski@samsung.com, dwmw2@infradead.org, dbaryshkov@gmail.com, sre@kernel.org, mark.rutland@arm.com, robh+dt@kernel.org Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, Chris Lapa Subject: [PATCH v4 2/7] max8903: store pointer to pdata instead of copying it. Date: Mon, 20 Jun 2016 08:27:17 +1000 Message-Id: <1466375242-38354-3-git-send-email-chris@cpdesign.com.au> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1466375242-38354-1-git-send-email-chris@cpdesign.com.au> References: <1464849897-21527-3-git-send-email-chris@lapa.com.au> <1466375242-38354-1-git-send-email-chris@cpdesign.com.au> In-Reply-To: <1464849897-21527-3-git-send-email-chris@lapa.com.au> References: <1464849897-21527-3-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 Stores pointer to pdata because it easily allows pdata to reference either platform data or in the future device tree data. Signed-off-by: Chris Lapa Reviewed-by: Krzysztof Kozlowski --- drivers/power/max8903_charger.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/drivers/power/max8903_charger.c b/drivers/power/max8903_charger.c index 17876ca..0a5b0e1 100644 --- a/drivers/power/max8903_charger.c +++ b/drivers/power/max8903_charger.c @@ -29,7 +29,7 @@ #include struct max8903_data { - struct max8903_pdata pdata; + struct max8903_pdata *pdata; struct device *dev; struct power_supply *psy; struct power_supply_desc psy_desc; @@ -53,8 +53,8 @@ static int max8903_get_property(struct power_supply *psy, switch (psp) { case POWER_SUPPLY_PROP_STATUS: val->intval = POWER_SUPPLY_STATUS_UNKNOWN; - if (data->pdata.chg) { - if (gpio_get_value(data->pdata.chg) == 0) + if (data->pdata->chg) { + if (gpio_get_value(data->pdata->chg) == 0) val->intval = POWER_SUPPLY_STATUS_CHARGING; else if (data->usb_in || data->ta_in) val->intval = POWER_SUPPLY_STATUS_NOT_CHARGING; @@ -81,7 +81,7 @@ static int max8903_get_property(struct power_supply *psy, static irqreturn_t max8903_dcin(int irq, void *_data) { struct max8903_data *data = _data; - struct max8903_pdata *pdata = &data->pdata; + struct max8903_pdata *pdata = data->pdata; bool ta_in; enum power_supply_type old_type; @@ -122,7 +122,7 @@ static irqreturn_t max8903_dcin(int irq, void *_data) static irqreturn_t max8903_usbin(int irq, void *_data) { struct max8903_data *data = _data; - struct max8903_pdata *pdata = &data->pdata; + struct max8903_pdata *pdata = data->pdata; bool usb_in; enum power_supply_type old_type; @@ -161,7 +161,7 @@ static irqreturn_t max8903_usbin(int irq, void *_data) static irqreturn_t max8903_fault(int irq, void *_data) { struct max8903_data *data = _data; - struct max8903_pdata *pdata = &data->pdata; + struct max8903_pdata *pdata = data->pdata; bool fault; fault = gpio_get_value(pdata->flt) ? false : true; @@ -190,12 +190,18 @@ static int max8903_probe(struct platform_device *pdev) int ta_in = 0; int usb_in = 0; + if (pdata == NULL) { + dev_err(dev, "No platform data.\n"); + return -EINVAL; + } + data = devm_kzalloc(dev, sizeof(struct max8903_data), GFP_KERNEL); if (data == NULL) { dev_err(dev, "Cannot allocate memory.\n"); return -ENOMEM; } - memcpy(&data->pdata, pdata, sizeof(struct max8903_pdata)); + + data->pdata = pdev->dev.platform_data; data->dev = dev; platform_set_drvdata(pdev, data);