Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp9717951rwd; Wed, 21 Jun 2023 10:52:44 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5dGaHlIkwkKm5UOwYtkQoFUyrzzAkxgKZBHtLmRgvXsdv6kwf+It7m0dxKn5laMDTgKV7+ X-Received: by 2002:a17:90a:20e:b0:260:e256:27c7 with SMTP id c14-20020a17090a020e00b00260e25627c7mr3112690pjc.15.1687369964247; Wed, 21 Jun 2023 10:52:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687369964; cv=none; d=google.com; s=arc-20160816; b=dOl+8mcOT80bciJZ5SG+e+t/qaIlNAEscTKKnFDuqQNT0wcR+Nwplz+5DiYByjVsIQ 0KpuDQVRV/U6f/5vPBq00puZcsiVi3kAi/12jqwKaPVTWwJx9SGdMSQpitOBuA8fU1lk jEtBskjJRFQ+mKA61VyjlJqf/umGAITFYqr1oQMGWNPV9TJV0L2oL189DnUe1AnrzaER QrbLVx61gTVWpjWmrNrqIlbt1u7H/jPcRVWOJdmfXkminXMGKqQ+7ShI+VXHZTYvyXLO tPmtDD4S+WjSjqvBbLmPDSZRn+/iiPHSw/IByJK18De3hL6Mh7IpcXqrqnRaEplsv4aL TiHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=p3njItrX5M+4F8L2ogEJ/2tgpwnTJrebl3ROfX8YUgs=; b=oY/cCbqtu/zSBDc1DSqMgbcvjvibBch9XMitfsHzftKaClINjPIvmLhYy/pSgUfTmY o/izA48DW7/4yw4+5GOBH6p01ih2hJdyEC5fr0RDIS8O2nk97Dkd+mtrduJ5upY9YFLo hTU1kQMfqJxGtjzk+NscxlCpx/MUFvL38bMt3cyXqm52tiWb0iqOhkPnyLRTqhaPAokZ JV4GB6sDuv3AByWcVNTVqF+dY5KCH3lKLiVCIyY4r08z/GIviC992EAf4R5EOKloB1hr eV4fgHPxnjaZd+VllXDFCs8/oAlO7Sp8lLrs7HIIyUSIBc7FcNGuU0fx7eLngnVdB9RF n1vg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=OqmVu7Q6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v20-20020a17090ac91400b002534f4ce2b6si12039699pjt.125.2023.06.21.10.52.30; Wed, 21 Jun 2023 10:52:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=OqmVu7Q6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229723AbjFURtt (ORCPT + 99 others); Wed, 21 Jun 2023 13:49:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51306 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230106AbjFURtq (ORCPT ); Wed, 21 Jun 2023 13:49:46 -0400 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 87503E41; Wed, 21 Jun 2023 10:49:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1687369785; x=1718905785; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=YP5QjbCjQUTAvk5hMhdqtzeImdCvYuUXEySMOpba5Mw=; b=OqmVu7Q66+2sbiw2uQOy4m1b+D4DTg8mDzR5TYCxv6YOwgIpvSvoEIA0 oX3DTqBEhgnDc6gPAfc50xfXega4/2Vap0rLMqsL56jjt0vWwrf+ZweIF e6zOHKYT4Uof0b35TmjrIehw1NvKVWGQQQK4eUuNFYhspzHFo12qhT7o3 g0TEyOSZ30liOzwvt5pcKZPzgh2XiQeoGWYkxepMIobsTaZ/AiRJRnTsm 4qO5sNI9kimHdqHgpE2t8uW1BTABoXKDQmweX2FTta4A2nbdBIj/GUstI QQ0uamSvtKPom7f918GGZRbp8o6YCOv/mAgI03TVLwbzxHY4GkrAucbno w==; X-IronPort-AV: E=McAfee;i="6600,9927,10748"; a="389819294" X-IronPort-AV: E=Sophos;i="6.00,261,1681196400"; d="scan'208";a="389819294" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Jun 2023 10:49:41 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10748"; a="691928084" X-IronPort-AV: E=Sophos;i="6.00,261,1681196400"; d="scan'208";a="691928084" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga006.jf.intel.com with ESMTP; 21 Jun 2023 10:49:39 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 8B3902C7; Wed, 21 Jun 2023 20:49:49 +0300 (EEST) From: Andy Shevchenko To: Andy Shevchenko , Bartosz Golaszewski , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Linus Walleij , Bartosz Golaszewski , Andy Shevchenko Subject: [PATCH v1 4/5] gpiolib: Split out gpiochip_irqchip_add_allocated_domain() helper Date: Wed, 21 Jun 2023 20:49:42 +0300 Message-Id: <20230621174943.30302-4-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.40.0.1.gaa8946217a0b In-Reply-To: <20230621174943.30302-1-andriy.shevchenko@linux.intel.com> References: <20230621174943.30302-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The gpiochip_irqchip_add_allocated_domain() can be used in another place in the code. Signed-off-by: Andy Shevchenko --- drivers/gpio/gpiolib.c | 39 +++++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 0e40f9a44519..59d87e60b108 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -1635,6 +1635,28 @@ static void gpiochip_set_irq_hooks(struct gpio_chip *gc) } } +static int gpiochip_irqchip_add_allocated_domain(struct gpio_chip *gc, + struct irq_domain *domain, + bool allocated_externally) +{ + if (!domain) + return -EINVAL; + + gc->to_irq = gpiochip_to_irq; + gc->irq.domain = domain; + gc->irq.domain_is_allocated_externally = allocated_externally; + + /* + * Using barrier() here to prevent compiler from reordering + * gc->irq.initialized before adding irqdomain. + */ + barrier(); + + gc->irq.initialized = true; + + return 0; +} + /** * gpiochip_add_irqchip() - adds an IRQ chip to a GPIO chip * @gc: the GPIO chip to add the IRQ chip to @@ -1788,22 +1810,7 @@ static void gpiochip_irqchip_remove(struct gpio_chip *gc) int gpiochip_irqchip_add_domain(struct gpio_chip *gc, struct irq_domain *domain) { - if (!domain) - return -EINVAL; - - gc->to_irq = gpiochip_to_irq; - gc->irq.domain = domain; - gc->irq.domain_is_allocated_externally = true; - - /* - * Using barrier() here to prevent compiler from reordering - * gc->irq.initialized before adding irqdomain. - */ - barrier(); - - gc->irq.initialized = true; - - return 0; + return gpiochip_irqchip_add_allocated_domain(gc, domain, true); } EXPORT_SYMBOL_GPL(gpiochip_irqchip_add_domain); -- 2.40.0.1.gaa8946217a0b