From patchwork Thu Jul 7 08:00:44 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 71504 Delivered-To: patch@linaro.org Received: by 10.140.28.4 with SMTP id 4csp1270995qgy; Thu, 7 Jul 2016 01:03:01 -0700 (PDT) X-Received: by 10.98.83.68 with SMTP id h65mr2969674pfb.112.1467878577634; Thu, 07 Jul 2016 01:02:57 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k26si2943788pfk.85.2016.07.07.01.02.57; Thu, 07 Jul 2016 01:02:57 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1030224AbcGGICw (ORCPT + 7 others); Thu, 7 Jul 2016 04:02:52 -0400 Received: from mail-wm0-f42.google.com ([74.125.82.42]:35753 "EHLO mail-wm0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1030215AbcGGICt (ORCPT ); Thu, 7 Jul 2016 04:02:49 -0400 Received: by mail-wm0-f42.google.com with SMTP id z126so138026584wme.0 for ; Thu, 07 Jul 2016 01:02:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Y1tOJuR43IFTfAqW2QfUdzQWIEcvkLEXbcPQm7FafFU=; b=KI48vR5vDvRp25/ZmoIWKNP9s4kzdNkcimxWZ6QfVo95OZ6LzMXom9FcqzXF04QcXy WHO+RdVQqUatGAy0ImvA14JAeEyKuq8Xg4NdBvYH7Hhq4ROaw5Qrcu0QEkSXvuTR8+Ti r2GbZH8Wx2kbWV2dDoaPKz8G/B3rPC8PmFIAA= 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:in-reply-to :references; bh=Y1tOJuR43IFTfAqW2QfUdzQWIEcvkLEXbcPQm7FafFU=; b=KzYc6bTP7nKaKVKHZs+k8zWiGU4xjCPbPCSY0IvwwqkAO0NA66bjcrQxgWy7/RkEy+ A/fP3VG1VPRLY0NGn46vLItagBJlfmPCRkMpiScZHkXQuwkdEEQmRgxEEsG6vb3BnaVV up9hb7+fRE/RpbUtxQi4g/d0nvK1iKvBVJdFbnNLrMcjTpvrlnJ4XPOQQBxATREzxdfI YlOXlgp9UT9+OTco6iDkxSnSivyVaWnGIfGh3BkF3Pi7bmoPPRGrGgaKjHgLbxW8PIP3 og+/gqzLECikLKgyU3B55pTzldgyggWIjkCuQUR4dSJeTSzXEIud2+8vCpDlTC2EmX3o G7RA== X-Gm-Message-State: ALyK8tJSt948iWIM13ZqimKuMogUQBAKXdDz/vfTpS+SZXwE+1BhhNFQ17pNt7I6KQLmNp4R X-Received: by 10.28.39.132 with SMTP id n126mr26860305wmn.27.1467878563370; Thu, 07 Jul 2016 01:02:43 -0700 (PDT) Received: from localhost.localdomain (lft31-1-88-121-166-205.fbx.proxad.net. [88.121.166.205]) by smtp.gmail.com with ESMTPSA id v70sm51327wmf.18.2016.07.07.01.02.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 07 Jul 2016 01:02:42 -0700 (PDT) From: Daniel Lezcano To: tglx@linutronix.de, daniel.lezcano@linaro.org Cc: linux-kernel@vger.kernel.org, Rob Herring , devicetree@vger.kernel.org Subject: [PATCH 11/93] of: Add a new macro to declare_of for one parameter function returning a value Date: Thu, 7 Jul 2016 10:00:44 +0200 Message-Id: <1467878526-1238-11-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1467878526-1238-1-git-send-email-daniel.lezcano@linaro.org> References: <577E0BED.3020608@linaro.org> <1467878526-1238-1-git-send-email-daniel.lezcano@linaro.org> Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org The macro OF_DECLARE_1 expect a void (*func)(struct device_node *) while the OF_DECLARE_2 expect a int (*func)(struct device_node *, struct device_node *). The second one allows to pass an init function returning a value, which make possible to call the functions in the table and check the return value in order to catch at a higher level the errors and handle them from there instead of doing a panic in each driver (well at least this is the case for the clkevt). Unfortunately the OF_DECLARE_1 does not allow that and that lead to some code duplication and crappyness in the drivers. The OF_DECLARE_1 is used by all the clk drivers and the clocksource/clockevent drivers. It is not possible to do the change in one shot as we have to change all the init functions. The OF_DECLARE_2 specifies an init function prototype with two parameters with the node and its parent. The latter won't be used, ever, in the timer drivers. Introduce a OF_DECLARE_1_RET macro to be used, and hopefully we can smoothly and iteratively change the users of OF_DECLARE_1 to use the new macro instead. Signed-off-by: Daniel Lezcano Acked-by: Rob Herring --- include/linux/of.h | 3 +++ 1 file changed, 3 insertions(+) -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/include/linux/of.h b/include/linux/of.h index c7292e8..552943d 100644 --- a/include/linux/of.h +++ b/include/linux/of.h @@ -1009,10 +1009,13 @@ static inline int of_get_available_child_count(const struct device_node *np) #endif typedef int (*of_init_fn_2)(struct device_node *, struct device_node *); +typedef int (*of_init_fn_1_ret)(struct device_node *); typedef void (*of_init_fn_1)(struct device_node *); #define OF_DECLARE_1(table, name, compat, fn) \ _OF_DECLARE(table, name, compat, fn, of_init_fn_1) +#define OF_DECLARE_1_RET(table, name, compat, fn) \ + _OF_DECLARE(table, name, compat, fn, of_init_fn_1_ret) #define OF_DECLARE_2(table, name, compat, fn) \ _OF_DECLARE(table, name, compat, fn, of_init_fn_2)