From patchwork Thu Sep 11 09:38:09 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Martinez Canillas X-Patchwork-Id: 4884221 Return-Path: X-Original-To: patchwork-linux-samsung-soc@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 246B99F32E for ; Thu, 11 Sep 2014 09:38:50 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id EBBB0200F2 for ; Thu, 11 Sep 2014 09:38:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3E030201F7 for ; Thu, 11 Sep 2014 09:38:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753680AbaIKJif (ORCPT ); Thu, 11 Sep 2014 05:38:35 -0400 Received: from bhuna.collabora.co.uk ([93.93.135.160]:36138 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753900AbaIKJid (ORCPT ); Thu, 11 Sep 2014 05:38:33 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: javier) with ESMTPSA id AA29526880DF From: Javier Martinez Canillas To: Lee Jones Cc: Wolfram Sang , Dmitry Torokhov , Doug Anderson , Simon Glass , Bill Richardson , Andrew Bresticker , Derek Basehore , Todd Broch , Olof Johansson , Andreas Faerber , linux-i2c@vger.kernel.org, linux-samsung-soc@vger.kernel.org, Javier Martinez Canillas Subject: [PATCH v3 6/6] mfd: cros_ec: Instantiate sub-devices from device tree Date: Thu, 11 Sep 2014 11:38:09 +0200 Message-Id: <1410428289-18229-7-git-send-email-javier.martinez@collabora.co.uk> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1410428289-18229-1-git-send-email-javier.martinez@collabora.co.uk> References: <1410428289-18229-1-git-send-email-javier.martinez@collabora.co.uk> Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org X-Spam-Status: No, score=-9.4 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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 From: Todd Broch If the EC device tree node has sub-nodes, try to instantiate them as MFD sub-devices. We can configure the EC features provided by the board. Signed-off-by: Todd Broch Signed-off-by: Javier Martinez Canillas --- Changes since v2: - Drop if guards since of_node is unconditionally built. Suggested by Lee Jones - Drop unneeded comment about of_platform_populate(). Suggested by Lee Jones. - Fix error message if of_platform_populate() fails. Suggested by Lee Jones. Changes since v1: - Don't leave an empty struct mfd_cell array. Suggested by Lee Jones. - Just use of_platform_populate() instead of manually iterating through sub-devices and calling mfd_add_devices. Suggested by Lee Jones. --- drivers/mfd/cros_ec.c | 27 ++++++++------------------- 1 file changed, 8 insertions(+), 19 deletions(-) diff --git a/drivers/mfd/cros_ec.c b/drivers/mfd/cros_ec.c index 751af0b..7c533d2 100644 --- a/drivers/mfd/cros_ec.c +++ b/drivers/mfd/cros_ec.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -109,22 +110,10 @@ int cros_ec_cmd_xfer(struct cros_ec_device *ec_dev, } EXPORT_SYMBOL(cros_ec_cmd_xfer); -static const struct mfd_cell cros_devs[] = { - { - .name = "cros-ec-keyb", - .id = 1, - .of_compatible = "google,cros-ec-keyb", - }, - { - .name = "cros-ec-i2c-tunnel", - .id = 2, - .of_compatible = "google,cros-ec-i2c-tunnel", - }, -}; - int cros_ec_register(struct cros_ec_device *ec_dev) { struct device *dev = ec_dev->dev; + struct device_node *node = dev->of_node; int err = 0; if (ec_dev->din_size) { @@ -140,12 +129,12 @@ int cros_ec_register(struct cros_ec_device *ec_dev) mutex_init(&ec_dev->lock); - err = mfd_add_devices(dev, 0, cros_devs, - ARRAY_SIZE(cros_devs), - NULL, ec_dev->irq, NULL); - if (err) { - dev_err(dev, "failed to add mfd devices\n"); - return err; + if (node) { + err = of_platform_populate(node, NULL, NULL, dev); + if (err) { + dev_err(dev, "Failed to register subordinate devices"); + return err; + } } dev_info(dev, "Chrome EC device registered\n");