From patchwork Wed Dec 3 01:39:11 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Sean Paul X-Patchwork-Id: 5425961 Return-Path: X-Original-To: patchwork-linux-fbdev@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 873419F319 for ; Wed, 3 Dec 2014 01:39:28 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A2ECD2034B for ; Wed, 3 Dec 2014 01:39:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 989BF20259 for ; Wed, 3 Dec 2014 01:39:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751043AbaLCBj0 (ORCPT ); Tue, 2 Dec 2014 20:39:26 -0500 Received: from mail-ig0-f179.google.com ([209.85.213.179]:51381 "EHLO mail-ig0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750988AbaLCBjZ (ORCPT ); Tue, 2 Dec 2014 20:39:25 -0500 Received: by mail-ig0-f179.google.com with SMTP id r2so11956112igi.6 for ; Tue, 02 Dec 2014 17:39:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version:content-type :content-transfer-encoding; bh=VD53SkMfGNp0f82u5Z69BY5DnUWT2cdZx1SWBfidMb8=; b=C6CiOEd6/I/Dv51QOJ3dh/ZVyhr3Xjj6ndyEXTjl0UtcK8vYgaYxS7rNugP1e973md ZyR2+DheJDQrVCAGhctQWAviayLrb7ZegZ26Wh5TEKeeMPO9424eWEP5CsaEHQpsqoRL 2ief+lnpdzdeY/880FJcwlX1PSG1gKa8OZlsE= 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:mime-version :content-type:content-transfer-encoding; bh=VD53SkMfGNp0f82u5Z69BY5DnUWT2cdZx1SWBfidMb8=; b=nD65d6OYUWQ1J9vaopLL07pTPmeW8/sqmDOsInLUJiLUghF72yrm71jCTvi5yA+tao sMQD24PTmQKDv16Ll2XapkTDvxcq6XneVFGIK+j/myJd6PQ9dhltRYZqjjbONu6v/49c NWEVrICGQ8oojHD9esFMZ/fBflyZcADB3+7kJIbvKxjxxM4ubEamEPD+MuQyMWMonQWL hErMV299dXDUB3fo6wX7jJkpUc2xnNwV3dfHIGDhYMQ0jfcDjqs1bkzSXjw65/GbpG0C b6FckUm8O4w2/BJ6YUB7GTSGemEvYEMbTEUERgl41A18YHB/zgF3L35FdpSBKyaImng7 3JPQ== X-Gm-Message-State: ALoCoQkb5FklKeNr1d5Qijdq/HJjY+cctWkOiwtho+cJWnGdLThJKV3z0sOCc27JfGMMRW4K9VWw X-Received: by 10.107.168.18 with SMTP id r18mr2405514ioe.76.1417570764726; Tue, 02 Dec 2014 17:39:24 -0800 (PST) Received: from davidriley-lab.mtv.corp.google.com ([172.22.64.15]) by mx.google.com with ESMTPSA id jg3sm9232854igb.12.2014.12.02.17.39.23 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 02 Dec 2014 17:39:24 -0800 (PST) From: Sean Paul To: milo.kim@ti.com, cooloney@gmail.com, linux-fbdev@vger.kernel.org, devicetree@vger.kernel.org Cc: jg1.han@samsung.com, lee.jones@linaro.org, Sean Paul , =?UTF-8?q?St=C3=A9phane=20Marchesin?= Subject: [PATCH v2 1/2] backlight/lp855x: Refactor dt parsing code Date: Tue, 2 Dec 2014 17:39:11 -0800 Message-Id: <1417570752-23633-1-git-send-email-seanpaul@chromium.org> X-Mailer: git-send-email 2.2.0.rc0.207.ga3a616c MIME-Version: 1.0 Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID,T_RP_MATCHES_RCVD,UNPARSEABLE_RELAY autolearn=ham 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 This patch refactors the dt parsing code to avoid setting platform_data, instead just setting lp->pdata directly. This facilitates easier probe deferral since the current scheme would require us to clear out dev->platform_data before deferring. Cc: Stéphane Marchesin Signed-off-by: Sean Paul Acked-by: Bryan Wu Acked-by: Milo Kim Acked-by: Jingoo Han --- drivers/video/backlight/lp855x_bl.c | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/drivers/video/backlight/lp855x_bl.c b/drivers/video/backlight/lp855x_bl.c index 25fb8e3..257b3ba 100644 --- a/drivers/video/backlight/lp855x_bl.c +++ b/drivers/video/backlight/lp855x_bl.c @@ -341,8 +341,10 @@ static const struct attribute_group lp855x_attr_group = { }; #ifdef CONFIG_OF -static int lp855x_parse_dt(struct device *dev, struct device_node *node) +static int lp855x_parse_dt(struct lp855x *lp) { + struct device *dev = lp->dev; + struct device_node *node = dev->of_node; struct lp855x_platform_data *pdata; int rom_length; @@ -381,12 +383,12 @@ static int lp855x_parse_dt(struct device *dev, struct device_node *node) pdata->rom_data = &rom[0]; } - dev->platform_data = pdata; + lp->pdata = pdata; return 0; } #else -static int lp855x_parse_dt(struct device *dev, struct device_node *node) +static int lp855x_parse_dt(struct lp855x *lp) { return -EINVAL; } @@ -395,18 +397,8 @@ static int lp855x_parse_dt(struct device *dev, struct device_node *node) static int lp855x_probe(struct i2c_client *cl, const struct i2c_device_id *id) { struct lp855x *lp; - struct lp855x_platform_data *pdata = dev_get_platdata(&cl->dev); - struct device_node *node = cl->dev.of_node; int ret; - if (!pdata) { - ret = lp855x_parse_dt(&cl->dev, node); - if (ret < 0) - return ret; - - pdata = dev_get_platdata(&cl->dev); - } - if (!i2c_check_functionality(cl->adapter, I2C_FUNC_SMBUS_I2C_BLOCK)) return -EIO; @@ -414,16 +406,23 @@ static int lp855x_probe(struct i2c_client *cl, const struct i2c_device_id *id) if (!lp) return -ENOMEM; - if (pdata->period_ns > 0) - lp->mode = PWM_BASED; - else - lp->mode = REGISTER_BASED; - lp->client = cl; lp->dev = &cl->dev; - lp->pdata = pdata; lp->chipname = id->name; lp->chip_id = id->driver_data; + lp->pdata = dev_get_platdata(&cl->dev); + + if (!lp->pdata) { + ret = lp855x_parse_dt(lp); + if (ret < 0) + return ret; + } + + if (lp->pdata->period_ns > 0) + lp->mode = PWM_BASED; + else + lp->mode = REGISTER_BASED; + i2c_set_clientdata(cl, lp); ret = lp855x_configure(lp);