From patchwork Wed Jun 1 08:34: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: 68983 Delivered-To: patch@linaro.org Received: by 10.140.92.199 with SMTP id b65csp2402354qge; Wed, 1 Jun 2016 01:36:01 -0700 (PDT) X-Received: by 10.98.102.25 with SMTP id a25mr6397078pfc.30.1464770160905; Wed, 01 Jun 2016 01:36:00 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f191si49677911pfc.101.2016.06.01.01.36.00; Wed, 01 Jun 2016 01:36:00 -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 S1757743AbcFAIfi (ORCPT + 30 others); Wed, 1 Jun 2016 04:35:38 -0400 Received: from mail-wm0-f45.google.com ([74.125.82.45]:38433 "EHLO mail-wm0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757298AbcFAIfe (ORCPT ); Wed, 1 Jun 2016 04:35:34 -0400 Received: by mail-wm0-f45.google.com with SMTP id a20so16531835wma.1 for ; Wed, 01 Jun 2016 01:35:33 -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=sB2JrSLsMX4SgX43j3St71orgac+iGQScpiaf/PlBW0=; b=hjRIjBnYVoUMIss5LmURIPRxiV3SpQPyCQD//Fhpy4iZX9+hm/QnB+NIewJdkav8OS 4f3zbSM4OpvMNyZ/4XzqAAhuofGcvteUMZqzHgeinJFapY+TtksPxKkWSc/P+BAA3+5t VOkwPVgQjGqstFiFW2QBnZ9peaDGYLszn6zOI= 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=sB2JrSLsMX4SgX43j3St71orgac+iGQScpiaf/PlBW0=; b=O/gwgs5j10zlt8HmXFTt7vE/ztUuOFrE4R0/hcxJ1E0uYKk99MINQDPYQzmTqtxrev cKgNzIfWGchTqHQXeTFRAFlZM52uCvI+bic1oPPdhpzbl8HPUKvcaKi0HPb3ua7SAPeW oKEW1uH5CXcRa0m6Vbnw78l9As8OeZR89FEiQfl7TwqoF/EHv6YHsPRPoVkX+X3cxFxj ft4UEQZ+8Dgfkj2j4aK2PUUSNY6kw7qKsVG5OYqzA7p1S8Ib8GDfkmolrNust+gbK1b9 rCxXnKxOM4CuEANGImUI1XpgONQ7v2lbIbcRF1U4tfgBiogH0QODAf3cpahH4JDY5pv9 4xng== X-Gm-Message-State: ALyK8tJsZSn/dX+EszR4dFrOgdvdjaV0p4UwagWToLAxjfyguSEv9rNEeiJZyTMT/qNgQm9p X-Received: by 10.194.11.97 with SMTP id p1mr2235748wjb.159.1464770132436; Wed, 01 Jun 2016 01:35:32 -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 t3sm33542865wmf.20.2016.06.01.01.35.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 01 Jun 2016 01:35:31 -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 1/9] of: Add a new macro to declare_of for one parameter function returning a value Date: Wed, 1 Jun 2016 10:34:44 +0200 Message-Id: <1464770093-12667-2-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1464770093-12667-1-git-send-email-daniel.lezcano@linaro.org> References: <1464770093-12667-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 7fcb681..5b396d7 100644 --- a/include/linux/of.h +++ b/include/linux/of.h @@ -944,10 +944,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)