From patchwork Mon Aug 25 13:40:07 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: 4775071 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 E7F569F38D for ; Mon, 25 Aug 2014 13:40:43 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E9378200CF for ; Mon, 25 Aug 2014 13:40:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C6EB4200D6 for ; Mon, 25 Aug 2014 13:40:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932419AbaHYNkj (ORCPT ); Mon, 25 Aug 2014 09:40:39 -0400 Received: from bhuna.collabora.co.uk ([93.93.135.160]:46166 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932365AbaHYNki (ORCPT ); Mon, 25 Aug 2014 09:40:38 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: javier) with ESMTPSA id 080BC26880BA 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 , linux-i2c@vger.kernel.org, linux-input@vger.kernel.org, linux-samsung-soc@vger.kernel.org, Javier Martinez Canillas Subject: [PATCH v2 6/7] mfd: cros_ec: Instantiate sub-devices from device tree Date: Mon, 25 Aug 2014 15:40:07 +0200 Message-Id: <1408974008-17184-7-git-send-email-javier.martinez@collabora.co.uk> X-Mailer: git-send-email 2.0.1 In-Reply-To: <1408974008-17184-1-git-send-email-javier.martinez@collabora.co.uk> References: <1408974008-17184-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=-6.9 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 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 | 35 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/drivers/mfd/cros_ec.c b/drivers/mfd/cros_ec.c index cd0c93c..ab70791 100644 --- a/drivers/mfd/cros_ec.c +++ b/drivers/mfd/cros_ec.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -107,22 +108,12 @@ 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; +#ifdef CONFIG_OF + struct device_node *node = dev->of_node; +#endif int err = 0; if (ec_dev->din_size) { @@ -138,13 +129,19 @@ 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; +#ifdef CONFIG_OF + /* + * Add sub-devices declared in the device tree. NOTE they should NOT be + * declared in cros_devs + */ + if (node) { + err = of_platform_populate(node, NULL, NULL, dev); + if (err) { + dev_err(dev, "fail to add %s\n", node->full_name); + return err; + } } +#endif dev_info(dev, "Chrome EC device registered\n");