From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754357AbdA0SOI (ORCPT ); Fri, 27 Jan 2017 13:14:08 -0500 Received: from mail-qt0-f193.google.com ([209.85.216.193]:35074 "EHLO mail-qt0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754703AbdA0SNI (ORCPT ); Fri, 27 Jan 2017 13:13:08 -0500 MIME-Version: 1.0 In-Reply-To: References: <20170126215609.4272-1-andrew.smirnov@gmail.com> <20170126215609.4272-3-andrew.smirnov@gmail.com> From: Andrey Smirnov Date: Fri, 27 Jan 2017 10:13:07 -0800 Message-ID: Subject: Re: [PATCH 2/4] irqchip: Add IRQCHIP_DECLARE_DRIVER macro To: Marc Zyngier Cc: Andrey Yurovsky , Shawn Guo , Thomas Gleixner , Jason Cooper , linux-kernel Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org +Cc linux-kernel@vger.kernel.org since I messed up original distribution list On Fri, Jan 27, 2017 at 12:51 AM, Marc Zyngier wrote: > On 26/01/17 21:56, Andrey Smirnov wrote: >> Add IRQCHIP_DECLARE_DRIVER macro to allow having driver code that both >> registers irqchip and a platform driver. Based on analogous code of >> CLK_OF_DECLARE_DRIVER. >> >> Cc: yurovsky@gmail.com >> Cc: Shawn Guo >> Cc: Thomas Gleixner >> Cc: Jason Cooper >> Cc: Marc Zyngier >> Signed-off-by: Andrey Smirnov >> --- >> include/linux/irqchip.h | 16 ++++++++++++++++ >> 1 file changed, 16 insertions(+) >> >> diff --git a/include/linux/irqchip.h b/include/linux/irqchip.h >> index 89c34b2..611e8cc 100644 >> --- a/include/linux/irqchip.h >> +++ b/include/linux/irqchip.h >> @@ -27,6 +27,22 @@ >> #define IRQCHIP_DECLARE(name, compat, fn) OF_DECLARE_2(irqchip, name, compat, fn) >> >> /* >> + * Use this macro when you have a driver that requires two >> + * initialization routines, one at IRQCHIP_DECLARE, and one at >> + * platform device probe >> + */ >> +#define IRQCHIP_DECLARE_DRIVER(name, compat, fn) \ >> + static int __init \ >> + name##_of_irqchip_init_driver(struct device_node *np, \ >> + struct device_node *parent) \ >> + { \ >> + of_node_clear_flag(np, OF_POPULATED); \ >> + return fn(np, parent); \ >> + } \ >> + OF_DECLARE_2(irqchip, name, compat, name##_of_irqchip_init_driver) >> + >> + >> +/* >> * This macro must be used by the different irqchip drivers to declare >> * the association between their version and their initialization function. >> * >> > > Why do we need this new macro? What problem does it solve that would not > be solved by having proper dependency tracking? The problem that I was trying to solve was trying to associate a platform device with a DT-node that had a IRQCHIP_DECLARE declared for it. After a bit of digging around the codebase I found CLK_OF_DECLARE_DRIVER which seemed to exist to solve exactly the same kind of problem I was having so I took it as "inspiration" and created IRQCHIP_DECLARE_DRIVER. I am not sure what you mean by "proper dependency tracking"(most likely due to my ignorance), can you point me to a concrete example or explain what you mean a bit more? I'll be more happy to change the code and drop this macro if there's a better way to solve my original problem. Thanks you, Andrey Smirnov