From patchwork Wed Jun 21 17:49:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 694803 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 9CFA5EB64D8 for ; Wed, 21 Jun 2023 17:49:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229452AbjFURtn (ORCPT ); Wed, 21 Jun 2023 13:49:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51262 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230371AbjFURtm (ORCPT ); Wed, 21 Jun 2023 13:49:42 -0400 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EC3811718; Wed, 21 Jun 2023 10:49:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1687369781; x=1718905781; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=kdcUcjY6P739bulIvEkWeV/vSYtThvEuSEz95gNk9Zw=; b=XJObtDWvvw/ga0sMmuK91gESfw48jbl9XYWALd1P5jcGqzSXLngK03LW 3qV/PBFX3pFHXgi0WgBiasPutU8LwxfJb9gZWz4oMAu0oTYj4lAdzk2KT F1FzFELyxqWKydkKAyzX0DiNUyH6rN7f0gSwBX8tOARLjq6Bm1oQF1Xr7 jmzz38slUaPmuN1GhNUDUs1EXO+PTYf8sI8jaY2r0OI4rQX/JvTY+fRbL cuWUbjkmTfPcUJpRldllAVWW0gEfuVhJNfXyZyxCc5x+YEL7ZI85qJ/U2 4xIvof1bm37ag46Jmioh8d0IIooEMH4bp4OWKqHZ5CNzVJ3O2DK1L1qts g==; X-IronPort-AV: E=McAfee;i="6600,9927,10748"; a="389819283" X-IronPort-AV: E=Sophos;i="6.00,261,1681196400"; d="scan'208";a="389819283" 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="691928082" X-IronPort-AV: E=Sophos;i="6.00,261,1681196400"; d="scan'208";a="691928082" 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 7D689193; 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 2/5] gpiolib: Factor out gpiochip_simple_create_domain() Date: Wed, 21 Jun 2023 20:49:40 +0300 Message-Id: <20230621174943.30302-2-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 Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org As a preparatory patch and for the sake of consistency, factor out gpiochip_simple_create_domain(). Signed-off-by: Andy Shevchenko --- drivers/gpio/gpiolib.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 058deaa1aa36..fac1124d5016 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -1444,6 +1444,19 @@ static const struct irq_domain_ops gpiochip_domain_ops = { .xlate = irq_domain_xlate_twocell, }; +static struct irq_domain *gpiochip_simple_create_domain(struct gpio_chip *gc) +{ + struct fwnode_handle *fwnode = dev_fwnode(&gc->gpiodev->dev); + struct irq_domain *domain; + + domain = irq_domain_create_simple(fwnode, gc->ngpio, gc->irq.first, + &gpiochip_domain_ops, gc); + if (!domain) + return ERR_PTR(-EINVAL); + + return domain; +} + /* * TODO: move these activate/deactivate in under the hierarchicial * irqchip implementation as static once SPMI and SSBI (all external @@ -1670,13 +1683,9 @@ static int gpiochip_add_irqchip(struct gpio_chip *gc, if (IS_ERR(gc->irq.domain)) return PTR_ERR(gc->irq.domain); } else { - gc->irq.domain = irq_domain_create_simple(fwnode, - gc->ngpio, - gc->irq.first, - &gpiochip_domain_ops, - gc); - if (!gc->irq.domain) - return -EINVAL; + gc->irq.domain = gpiochip_simple_create_domain(gc); + if (IS_ERR(gc->irq.domain)) + return PTR_ERR(gc->irq.domain); } if (gc->irq.parent_handler) {