From patchwork Wed Jul 24 15:42:27 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olof Johansson X-Patchwork-Id: 2832911 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 83CF8C0319 for ; Wed, 24 Jul 2013 15:47:48 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6BA8320416 for ; Wed, 24 Jul 2013 15:47:43 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 12DD820411 for ; Wed, 24 Jul 2013 15:47:42 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1V21Hw-000082-9y; Wed, 24 Jul 2013 15:47:40 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1V21D4-0007fH-LY; Wed, 24 Jul 2013 15:42:38 +0000 Received: from mail-pb0-f44.google.com ([209.85.160.44]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1V21D1-0007em-A2 for linux-arm-kernel@lists.infradead.org; Wed, 24 Jul 2013 15:42:36 +0000 Received: by mail-pb0-f44.google.com with SMTP id uo1so9843064pbc.31 for ; Wed, 24 Jul 2013 08:42:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:x-gm-message-state; bh=zFul/MYCZInJWUyivaKUJlzF/bMee/55jUnrlCTfXGg=; b=JbKWm9l48NX77stXXUiHgbjD/o4IGK6KObITwJU3oI/aXiaaUzvrXAY458RDfXFLsn aPppsPtKoAE7wvqDo0m3wq+zR0WXLEqvrIEaaRJCiICQD2ar+81kWZKTV1V+6ihnWOrI RKVkfqjKsJ/Hni4Izh2OUktstnGAp/nZNxUu9xXGp3/gTJSHl9VzYNWbiD6xmJTThbJN DQjn5xR30608gp+J/BBssVL26Mn18e1Y3/1eWKvnM1dyUO9cXxTKAlLab3uzhYuFX1l/ f34EOtJL/zmN42wNN/mNmSOEbV0FjlTzBYlcFXmupRKvdlI4TK/5A0s3Hb3agJpOb6T9 dLcw== X-Received: by 10.66.176.143 with SMTP id ci15mr2036628pac.146.1374680532237; Wed, 24 Jul 2013 08:42:12 -0700 (PDT) Received: from brutus.lixom.net (173-13-129-225-sfba.hfc.comcastbusiness.net. [173.13.129.225]) by mx.google.com with ESMTPSA id qh10sm8652034pbb.33.2013.07.24.08.42.10 for (version=TLSv1.2 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 24 Jul 2013 08:42:11 -0700 (PDT) From: Olof Johansson To: Richard Purdie , Jingoo Han Subject: [PATCH] mfd: max8925: fix dt code for backlight Date: Wed, 24 Jul 2013 08:42:27 -0700 Message-Id: <1374680547-5336-1-git-send-email-olof@lixom.net> X-Mailer: git-send-email 1.7.10.4 X-Gm-Message-State: ALoCoQkmvPkgAFw5ZMX1cUMu6UMg6Rwlvgnhrq23WUtVVYW/IyKYYDZowYSpm1ZcejPSGqBwNRAb X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130724_114235_437529_0C1B208C X-CRM114-Status: GOOD ( 16.04 ) X-Spam-Score: -2.6 (--) Cc: sameo@linux.intel.com, linux-kernel@vger.kernel.org, Haojian Zhuang , holt@sgi.com, Qing Xu , Olof Johansson , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The device-tree enablement for max8925 has several problems, but besides the bindings being wrong (and not having seen review) there's also some bad coding practices on how to fill in the platform_data from device tree. I came across this since it causes a warning when compiling mmp2_defconfig, and instead of doing the minimal fix to silence the warning, I restructured the code a bit. This silences the warning: drivers/video/backlight/max8925_bl.c: In function 'max8925_backlight_probe': drivers/video/backlight/max8925_bl.c:177:3: warning: statement with no effect [-Wunused-value] Note that the bindings themselves need to be revisited too, but that will affect more than just the backlight driver and is best done separately; this just fixes the bad code for the backlight driver. Signed-off-by: Olof Johansson Acked-by: Jingoo Han --- Richard, Jingoo, this would be good to see go into 3.11 if you're comfortable with it. -Olof drivers/video/backlight/max8925_bl.c | 41 +++++++++++++++++----------------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/drivers/video/backlight/max8925_bl.c b/drivers/video/backlight/max8925_bl.c index 5ca11b0..886e797 100644 --- a/drivers/video/backlight/max8925_bl.c +++ b/drivers/video/backlight/max8925_bl.c @@ -101,33 +101,37 @@ static const struct backlight_ops max8925_backlight_ops = { .get_brightness = max8925_backlight_get_brightness, }; -#ifdef CONFIG_OF -static int max8925_backlight_dt_init(struct platform_device *pdev, - struct max8925_backlight_pdata *pdata) +static void max8925_backlight_dt_init(struct platform_device *pdev) { struct device_node *nproot = pdev->dev.parent->of_node, *np; - int dual_string; + struct max8925_backlight_pdata *pdata; + u32 val; + + if (!nproot || !IS_ENABLED(CONFIG_OF)) + return; + + pdata = devm_kzalloc(&pdev->dev, + sizeof(struct max8925_backlight_pdata), + GFP_KERNEL); + if (!pdata) + return; - if (!nproot) - return -ENODEV; np = of_find_node_by_name(nproot, "backlight"); if (!np) { dev_err(&pdev->dev, "failed to find backlight node\n"); - return -ENODEV; + return; } - of_property_read_u32(np, "maxim,max8925-dual-string", &dual_string); - pdata->dual_string = dual_string; - return 0; + if (!of_property_read_u32(np, "maxim,max8925-dual-string", &val)) + pdata->dual_string = val; + + pdev->dev.platform_data = pdata; } -#else -#define max8925_backlight_dt_init(x, y) (-1) -#endif static int max8925_backlight_probe(struct platform_device *pdev) { struct max8925_chip *chip = dev_get_drvdata(pdev->dev.parent); - struct max8925_backlight_pdata *pdata = pdev->dev.platform_data; + struct max8925_backlight_pdata *pdata; struct max8925_backlight_data *data; struct backlight_device *bl; struct backlight_properties props; @@ -170,13 +174,10 @@ static int max8925_backlight_probe(struct platform_device *pdev) platform_set_drvdata(pdev, bl); value = 0; - if (pdev->dev.parent->of_node && !pdata) { - pdata = devm_kzalloc(&pdev->dev, - sizeof(struct max8925_backlight_pdata), - GFP_KERNEL); - max8925_backlight_dt_init(pdev, pdata); - } + if (!pdev->dev.platform_data) + max8925_backlight_dt_init(pdev); + pdata = pdev->dev.platform_data; if (pdata) { if (pdata->lxw_scl) value |= (1 << 7);