From patchwork Sun Jul 3 19:40:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lad, Prabhakar" X-Patchwork-Id: 12904457 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8171BC43334 for ; Sun, 3 Jul 2022 19:41:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232847AbiGCTlx (ORCPT ); Sun, 3 Jul 2022 15:41:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52678 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232809AbiGCTlt (ORCPT ); Sun, 3 Jul 2022 15:41:49 -0400 Received: from mail-pl1-x629.google.com (mail-pl1-x629.google.com [IPv6:2607:f8b0:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8D3BF6157; Sun, 3 Jul 2022 12:41:47 -0700 (PDT) Received: by mail-pl1-x629.google.com with SMTP id z1so1057044plb.1; Sun, 03 Jul 2022 12:41:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=XI0bxFBrEKRBuDqtanZl8S03OsomJgySRxxoYC8Ucrc=; b=BMRuLECs2RX8B6S5+IZV8fP93sQaUeK4uPrhUKicuUsLE9HU0FKZbfklpf6VirX9lg 9DCIhzlSiWlXIR09aOkB1etop/nGQ2JVntWXMNI6BYXbDZ9HxM4BTi6NqLFEqYAPCqxc evfCU8JZ4TeOuxzq1Z8Z3SK7FDZ7C4LW3FPjfkTGGG2FXFfkgnj3jWLQ46QgxSdYFnr8 56zMstllAfIfejEk13ksSdnSKnnNCtlgQ+3sVsrRCtoQunL1VR3PAUGJH7oBTWYlod3l CoGaIWQYtZasb9muld9wqIkOQvxQGl7pbEng/KsLHt6eVjmrmYTTgw5+boH+lgqR/IQo O5kQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=XI0bxFBrEKRBuDqtanZl8S03OsomJgySRxxoYC8Ucrc=; b=CgPR+DwRAussj78jccWiQo8LClR04YQ5dwGcxAZdJlx3wWE3iKw0cQupaobeMdjKur 0XJABIlvylFG1ArpXItZwnBJGoj0r7bq9F29blsX/TDF6s4MY08L/0cbSrBAF4gMnOLr j5pmpCe8xH2t4sVF5CnkxqNVoc2bhSC3X2ToBH/dDCJLcXXg/f2sb/+95TgxUa16akmT lgGlibMnoY5gLrhBwAZs3Y/3iXgXtV1TEghaJfNgsTENufk0wn2YteuB4ouiOxjYGFC9 zWN3OmYS8C9j0qlE6VFMnU4U8ffct7lr266nCiJB386gtP2w2JLFsVK5SewqI1Z6jhyT DPSg== X-Gm-Message-State: AJIora+0TjeAkyXfWPLVUuIbSGUEEMahhFgBcbM4Fe8PczoR8aB3Fa+N ndIIYjuedEAtLMwPb/W1yOs= X-Google-Smtp-Source: AGRyM1tcLiw1b5SdWvCYRgaGNtv6D8+BAF8MpHbHdXcwoN9JYPJuqM+yVkIbHGghRgjIqW9rBqW3XA== X-Received: by 2002:a17:90a:9401:b0:1ee:e31f:7523 with SMTP id r1-20020a17090a940100b001eee31f7523mr29827184pjo.175.1656877307226; Sun, 03 Jul 2022 12:41:47 -0700 (PDT) Received: from prasmi.domain.name ([103.219.60.86]) by smtp.gmail.com with ESMTPSA id y19-20020a17090aca9300b001e0c5da6a51sm10656104pjt.50.2022.07.03.12.41.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Jul 2022 12:41:46 -0700 (PDT) From: Lad Prabhakar X-Google-Original-From: Lad Prabhakar To: Marc Zyngier , Thomas Gleixner , Rob Herring , Krzysztof Kozlowski , Geert Uytterhoeven , Linus Walleij , Bartosz Golaszewski , Philipp Zabel , devicetree@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-gpio@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Prabhakar , Biju Das , Lad Prabhakar Subject: [PATCH v7 3/5] gpio: gpiolib: Allow free() callback to be overridden Date: Sun, 3 Jul 2022 20:40:18 +0100 Message-Id: <20220703194020.78701-4-prabhakar.mahadev-lad.rj@bp.renesas.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220703194020.78701-1-prabhakar.mahadev-lad.rj@bp.renesas.com> References: <20220703194020.78701-1-prabhakar.mahadev-lad.rj@bp.renesas.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org Allow free() callback to be overridden from irq_domain_ops for hierarchical chips. This allows drivers to free up resources which are allocated during child_to_parent_hwirq()/populate_parent_alloc_arg() callbacks. On Renesas RZ/G2L platform a bitmap is maintained for TINT slots, a slot is allocated in child_to_parent_hwirq() callback which is freed up in free callback hence this override. Signed-off-by: Lad Prabhakar Reviewed-by: Geert Uytterhoeven --- drivers/gpio/gpiolib.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index bfde94243752..68d9f95d7799 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -1181,15 +1181,18 @@ static void gpiochip_hierarchy_setup_domain_ops(struct irq_domain_ops *ops) ops->activate = gpiochip_irq_domain_activate; ops->deactivate = gpiochip_irq_domain_deactivate; ops->alloc = gpiochip_hierarchy_irq_domain_alloc; - ops->free = irq_domain_free_irqs_common; /* - * We only allow overriding the translate() function for + * We only allow overriding the translate() and free() functions for * hierarchical chips, and this should only be done if the user - * really need something other than 1:1 translation. + * really need something other than 1:1 translation for translate() + * callback and free if user wants to free up any resources which + * were allocated during callbacks, for example populate_parent_alloc_arg. */ if (!ops->translate) ops->translate = gpiochip_hierarchy_irq_domain_translate; + if (!ops->free) + ops->free = irq_domain_free_irqs_common; } static int gpiochip_hierarchy_add_domain(struct gpio_chip *gc)