From patchwork Wed Nov 26 19:11:03 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Sean Paul X-Patchwork-Id: 5387431 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 321739F319 for ; Wed, 26 Nov 2014 19:12:06 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 586B2201F4 for ; Wed, 26 Nov 2014 19:12:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 77D042017D for ; Wed, 26 Nov 2014 19:12:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751139AbaKZTMB (ORCPT ); Wed, 26 Nov 2014 14:12:01 -0500 Received: from mail-qg0-f49.google.com ([209.85.192.49]:62930 "EHLO mail-qg0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751026AbaKZTL7 (ORCPT ); Wed, 26 Nov 2014 14:11:59 -0500 Received: by mail-qg0-f49.google.com with SMTP id a108so2512210qge.36 for ; Wed, 26 Nov 2014 11:11:58 -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=hKgF7PYa7rvY+wbrTVIov1NNfEmf0cH+5VDNlk2YRJnI5IKbx8losVO+3YUp7fy2Eh b9gnw3ScjTZovB3yCM2YQFdxfclV8+LHzbUTJ8CZXDKROKZVzFCtmyJsp1jhJs+KjGNq uNXheeftXzFWGEWxlgR9VI6h8ad4jIFXBE12Q= 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=awQRVaUvkTbgt6p/QREZ2stbYqV1dmOCJiFtu92gtLTkbBtsKOVLBagWUR6wsTRXnj sXWiX44YgyhZGfZdmJ3cx+6ZiAly7FdYRmSQUe6gKHX8kQ2u4XwtclKrFcDAOFC1PUgt t3DjOlUuFXMb/R2W3klJyy5k6Z1eM/lc8KSGIIqtoUfRmpDOyO0AqUMuKVOa1alop7Hf GmuqI/kR7df+1oYpeIhzW4G8WL8ls5dyIKieyI+okcdKWm8EAeHIAM5LK3EFSUB0YaEI ygVJWgdorHIW7yoclRhTkhiK3sVF9AMAOVVg2GUvVOanCF02e1NQSL9ExOVFaDdlhnyo IlUw== X-Gm-Message-State: ALoCoQmziP9mSC+HLKI/UBaqqWkDQC6ANPnweU/IuJ+peMMDaHE7q0+oj2uLlwUNDxD8aaLuWAIQ X-Received: by 10.224.3.196 with SMTP id 4mr47809852qao.79.1417029118570; Wed, 26 Nov 2014 11:11:58 -0800 (PST) Received: from philcollins.nc.rr.com (cpe-173-095-180-236.nc.res.rr.com. [173.95.180.236]) by mx.google.com with ESMTPSA id z32sm4612477qgd.40.2014.11.26.11.11.57 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 26 Nov 2014 11:11:58 -0800 (PST) From: Sean Paul To: linux-fbdev@vger.kernel.org, devicetree@vger.kernel.org, milo.kim@ti.com Cc: seanpaul@chromium.org, =?UTF-8?q?St=C3=A9phane=20Marchesin?= Subject: [PATCH 1/2] backlight/lp855x: Refactor dt parsing code Date: Wed, 26 Nov 2014 14:11:03 -0500 Message-Id: <1417029064-12460-1-git-send-email-seanpaul@chromium.org> X-Mailer: git-send-email 2.1.1 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 --- 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);