From patchwork Mon May 27 19:11:54 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Andrzej Siewior X-Patchwork-Id: 2621271 Return-Path: X-Original-To: patchwork-linux-input@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id E2DFCDF215 for ; Mon, 27 May 2013 19:12:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756670Ab3E0TMX (ORCPT ); Mon, 27 May 2013 15:12:23 -0400 Received: from www.linutronix.de ([62.245.132.108]:48349 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756763Ab3E0TMW (ORCPT ); Mon, 27 May 2013 15:12:22 -0400 Received: from localhost ([127.0.0.1] helo=localhost.localdomain) by Galois.linutronix.de with esmtp (Exim 4.72) (envelope-from ) id 1Uh2qC-0008KD-VB; Mon, 27 May 2013 21:12:21 +0200 From: Sebastian Andrzej Siewior To: linux-input@vger.kernel.org, linux-iio@vger.kernel.org Cc: Samuel Ortiz , Jonathan Cameron , Dmitry Torokhov , Felipe Balbi , "Patil, Rachna" , Pantelis Antoniou , Sebastian Andrzej Siewior Subject: [PATCH 07/19] iio: adc: am335x: Add DT support Date: Mon, 27 May 2013 21:11:54 +0200 Message-Id: <1369681926-22185-8-git-send-email-bigeasy@linutronix.de> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1369681926-22185-1-git-send-email-bigeasy@linutronix.de> References: <1369681926-22185-1-git-send-email-bigeasy@linutronix.de> X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1, SHORTCIRCUIT=-0.0001 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org From: "Patil, Rachna" Add DT support for client ADC driver. [ panto@antoniou-consulting.com : use of_get_child_by_name instead of of_find_node_by_name ] Signed-off-by: Pantelis Antoniou Signed-off-by: Patil, Rachna Signed-off-by: Felipe Balbi [bigeasy: shift the code to the left] Signed-off-by: Sebastian Andrzej Siewior Acked-by: Jonathan Cameron --- drivers/iio/adc/ti_am335x_adc.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/drivers/iio/adc/ti_am335x_adc.c b/drivers/iio/adc/ti_am335x_adc.c index 5f9a7e7..e657709 100644 --- a/drivers/iio/adc/ti_am335x_adc.c +++ b/drivers/iio/adc/ti_am335x_adc.c @@ -22,6 +22,8 @@ #include #include #include +#include +#include #include #include @@ -141,11 +143,12 @@ static int tiadc_probe(struct platform_device *pdev) struct iio_dev *indio_dev; struct tiadc_device *adc_dev; struct ti_tscadc_dev *tscadc_dev = pdev->dev.platform_data; - struct mfd_tscadc_board *pdata; + struct mfd_tscadc_board *pdata = tscadc_dev->dev->platform_data; + struct device_node *node = tscadc_dev->dev->of_node; int err; + u32 val32; - pdata = tscadc_dev->dev->platform_data; - if (!pdata || !pdata->adc_init) { + if (!pdata && !node) { dev_err(&pdev->dev, "Could not find platform data\n"); return -EINVAL; } @@ -159,7 +162,19 @@ static int tiadc_probe(struct platform_device *pdev) adc_dev = iio_priv(indio_dev); adc_dev->mfd_tscadc = tscadc_dev; - adc_dev->channels = pdata->adc_init->adc_channels; + + if (pdata) + adc_dev->channels = pdata->adc_init->adc_channels; + else { + node = of_get_child_by_name(node, "adc"); + if (!node) + return -EINVAL; + err = of_property_read_u32(node, + "ti,adc-channels", &val32); + if (err < 0) + goto err_free_device; + adc_dev->channels = val32; + } indio_dev->dev.parent = &pdev->dev; indio_dev->name = dev_name(&pdev->dev);