From patchwork Thu Jun 16 21:26:20 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 70270 Delivered-To: patch@linaro.org Received: by 10.140.28.4 with SMTP id 4csp470852qgy; Thu, 16 Jun 2016 14:48:08 -0700 (PDT) X-Received: by 10.107.147.137 with SMTP id v131mr11360262iod.3.1466113688411; Thu, 16 Jun 2016 14:48:08 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id zf8si2071835pac.177.2016.06.16.14.48.08; Thu, 16 Jun 2016 14:48:08 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755227AbcFPVsF (ORCPT + 30 others); Thu, 16 Jun 2016 17:48:05 -0400 Received: from mail-wm0-f48.google.com ([74.125.82.48]:37941 "EHLO mail-wm0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754814AbcFPV2D (ORCPT ); Thu, 16 Jun 2016 17:28:03 -0400 Received: by mail-wm0-f48.google.com with SMTP id m124so86944231wme.1 for ; Thu, 16 Jun 2016 14:28:02 -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=LqlQMWjBZAmsCD5VQVAyB37iDW07d0JnixPADZr1/W8=; b=Og9EplhmT6Cu77w73yazRhd1IqmNqXrsfGUSq1/D9usODf4SLkK8oKAQTalt5aC9CQ KZBOfzU+yACyQOaF4vh4d1BX6unqQ72lZzWJ2gs2gGg79Kt/WIRHJ69UE6muidU6F6Kj hPdRWGF+SGmE4ccLtsbm7FKMZj0DWURpBq1ik= 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=LqlQMWjBZAmsCD5VQVAyB37iDW07d0JnixPADZr1/W8=; b=CPRKJkPksS4M6z6YCxlSdxIeTyEKlHStypE2gdw6K+j9cl+U3hymdN7JteflcdvCUg 7agXLiEs7mqJzG4ft79u4G17sspnMmI7e0TwTZB9Xhrh2gVlHUCRGpctg4WPLtC8Q/8n 3ab+5NapLmPOP1gsf9KYvMRt+88vYlqadyUvu2bcmNbg7OUlo+B+AKGcLujHdoAe0tbz p8Ws8dEaZkkbWHVWV3tdNYUN4mB8NEO04f4DblA3Bxtngc77YibDwYz9fNIVDh5cmmrm iIDeYpjtsBffinEpmmDFMDGm3sfaVurP7QIqS0elek7ZdxG3DYSybDc24TTVKSw5M9G2 80Qw== X-Gm-Message-State: ALyK8tI5drQjXzJZftqj0eYVG5ZdvwlfcPXVr+Y97Ac7liLZ5MXjHs/HYnIwTL4Gd3Rzg2iq X-Received: by 10.194.151.73 with SMTP id uo9mr1324869wjb.177.1466112481166; Thu, 16 Jun 2016 14:28:01 -0700 (PDT) Received: from localhost.localdomain (sju31-1-78-210-255-2.fbx.proxad.net. [78.210.255.2]) by smtp.gmail.com with ESMTPSA id x128sm16705606wmf.6.2016.06.16.14.27.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 16 Jun 2016 14:28:00 -0700 (PDT) From: Daniel Lezcano To: daniel.lezcano@linaro.org, tglx@linutronix.de Cc: linux-kernel@vger.kernel.org, Rob Herring , Frank Rowand , Grant Likely , devicetree@vger.kernel.org (open list:OPEN FIRMWARE AND...) Subject: [PATCH V2 01/63] of: Add a new macro to declare_of for one parameter function returning a value Date: Thu, 16 Jun 2016 23:26:20 +0200 Message-Id: <1466112442-31105-2-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1466112442-31105-1-git-send-email-daniel.lezcano@linaro.org> References: <1466112442-31105-1-git-send-email-daniel.lezcano@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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 --- include/linux/of.h | 3 +++ 1 file changed, 3 insertions(+) -- 1.9.1 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)