From patchwork Wed Jun 21 17:49:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 111242 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp4550680vqr; Wed, 21 Jun 2023 11:08:24 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4Rz2XJStZ9JFdfWivH+CGWmbB+nSIyEkq8/pohrsX+RUGveV2p09X9Uqb2PQ4fKCLDMWu3 X-Received: by 2002:a05:6a20:a583:b0:123:828f:680 with SMTP id bc3-20020a056a20a58300b00123828f0680mr988176pzb.33.1687370903709; Wed, 21 Jun 2023 11:08:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687370903; cv=none; d=google.com; s=arc-20160816; b=r5GhJVeY4e+bdCdeVhO3ajvbJsmudhctYPLRJVepTY9HM7HXPVqqMoDqy4FV0/NCN3 4oj8s+tBRcF0vpZLqNza/7qM0+4y64uiomEKjEAfz8AJjbwNUF5y+12umO0E9G783aAP ZsZPDrfrhT1kwRJv5/xe282P4kPlyY+OE+ebuy3YANmePkXYg1vZx1qBwdCdcrVrcqTa GabnjI+v8xl+YT5tGFHs7ghr7jvzrCIGSOPDVd689UbN3Cq/fT7NNJu0rN/5tdr0KHmI q02Ou2TJl7MBZS+G3jz9dNx2prN0QAie+ECdM3w9rGSmAYGYjkaN2bz/Ekhw+XBNMX/5 q4gA== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=jWos1rWTP13bZObOY5B9ZOKDYxznjxJ4rRUrFgkRmP4=; b=gyU0vfrq/RojAv5RwAJHbG/2JJj/ZA6wLG1fzFWX9ssawu0vNJIQeX3+2hULO97YYh 3LAwn5SdKsIuJD+nuJgYBVPxKfbNFZH0OrDbFIJWbraIukbU1CQfZyHWTnhOTeBz2qey 7dJskHB9CnZ4hmO9tqGjtxUMMuHX8ySOwyxhdckiraX0tN/8etue1aVQYwVfkEnFPedp nsGmkZaTJCsQLMEXTsOa+58pExysq+TSsLOYKua8kpT1r5eW5wxaTcBMJdXAeUd835uo lC4rxP+wb8Ntugp01DJ8FcDctnfNEyRLO9p/53xJ0bppi+hZg2R33QOyNKUKiOlu7Ze+ Cbow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=AvEmWQPF; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b13-20020a63d80d000000b00544b88dda25si4791645pgh.64.2023.06.21.11.08.09; Wed, 21 Jun 2023 11:08:23 -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=AvEmWQPF; 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 S231520AbjFURuW (ORCPT + 99 others); Wed, 21 Jun 2023 13:50:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51312 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231357AbjFURtq (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 BB9FE1731; 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:mime-version: content-transfer-encoding; bh=UcbQzh/QfOhvEjVYIh628xUqEPTf7XQWOJPKRRENFlQ=; b=AvEmWQPFlSEaJHw05r1oH/rLykS+/0cVsbEtzYbzd6/VZMqin5X7htSf h+9jcYEIbRc4nK80aIpA3enD0WxT79cZ06F6WQBKfOn4DrVf1anm+u5YX 1V5cg18pcx9qiPJJkXSVcm4a3wIe2KHA8/vBNySKIGT3EksPdpjpPAant kHanXyEGozh239wRSn+ziprWzEPvIpUOLARMlciAhwIaUu+ggWm95FN+1 3Sp9L52o6E7kuJCeBw7PMQ/a0Tf9J+hI0D+MqNuRPINVUpB1LpPUCtgGB 0QWBRWQJV02Jl3q6qibmJ8SeHwCNPDVunVDCCXa7tyoV362QbFKgMm8Za w==; X-IronPort-AV: E=McAfee;i="6600,9927,10748"; a="389819298" X-IronPort-AV: E=Sophos;i="6.00,261,1681196400"; d="scan'208";a="389819298" 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="691928085" X-IronPort-AV: E=Sophos;i="6.00,261,1681196400"; d="scan'208";a="691928085" 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 73CD9195; 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 1/5] gpiolib: Make gpiochip_hierarchy_add_domain() return domain Date: Wed, 21 Jun 2023 20:49:39 +0300 Message-Id: <20230621174943.30302-1-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.40.0.1.gaa8946217a0b MIME-Version: 1.0 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769336632792042246?= X-GMAIL-MSGID: =?utf-8?q?1769336632792042246?= As a preparatory patch and for the sake of consistency, make gpiochip_hierarchy_add_domain() return IRQ domain. While at it, rename it to gpiochip_hierarchy_create_domain() to show the change. Signed-off-by: Andy Shevchenko Reviewed-by: Linus Walleij --- drivers/gpio/gpiolib.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 0d25d9d439a2..058deaa1aa36 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -1289,12 +1289,14 @@ static void gpiochip_hierarchy_setup_domain_ops(struct irq_domain_ops *ops) ops->free = irq_domain_free_irqs_common; } -static int gpiochip_hierarchy_add_domain(struct gpio_chip *gc) +static struct irq_domain *gpiochip_hierarchy_create_domain(struct gpio_chip *gc) { + struct irq_domain *domain; + if (!gc->irq.child_to_parent_hwirq || !gc->irq.fwnode) { chip_err(gc, "missing irqdomain vital data\n"); - return -EINVAL; + return ERR_PTR(-EINVAL); } if (!gc->irq.child_offset_to_irq) @@ -1306,7 +1308,7 @@ static int gpiochip_hierarchy_add_domain(struct gpio_chip *gc) gpiochip_hierarchy_setup_domain_ops(&gc->irq.child_irq_domain_ops); - gc->irq.domain = irq_domain_create_hierarchy( + domain = irq_domain_create_hierarchy( gc->irq.parent_domain, 0, gc->ngpio, @@ -1314,12 +1316,12 @@ static int gpiochip_hierarchy_add_domain(struct gpio_chip *gc) &gc->irq.child_irq_domain_ops, gc); - if (!gc->irq.domain) - return -ENOMEM; + if (!domain) + return ERR_PTR(-ENOMEM); gpiochip_set_hierarchical_irqchip(gc, gc->irq.chip); - return 0; + return domain; } static bool gpiochip_hierarchy_is_hierarchical(struct gpio_chip *gc) @@ -1363,9 +1365,9 @@ EXPORT_SYMBOL_GPL(gpiochip_populate_parent_fwspec_fourcell); #else -static int gpiochip_hierarchy_add_domain(struct gpio_chip *gc) +static struct irq_domain *gpiochip_hierarchy_create_domain(struct gpio_chip *gc) { - return -EINVAL; + return ERR_PTR(-EINVAL); } static bool gpiochip_hierarchy_is_hierarchical(struct gpio_chip *gc) @@ -1664,9 +1666,9 @@ static int gpiochip_add_irqchip(struct gpio_chip *gc, /* If a parent irqdomain is provided, let's build a hierarchy */ if (gpiochip_hierarchy_is_hierarchical(gc)) { - int ret = gpiochip_hierarchy_add_domain(gc); - if (ret) - return ret; + gc->irq.domain = gpiochip_hierarchy_create_domain(gc); + if (IS_ERR(gc->irq.domain)) + return PTR_ERR(gc->irq.domain); } else { gc->irq.domain = irq_domain_create_simple(fwnode, gc->ngpio, 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: 111237 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp4547445vqr; Wed, 21 Jun 2023 11:03:48 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4N+wxxzGOiycL9a2fnwfWgq/tC6sfOfhomKs1+aT9cfB4a1QvNE6wggkDyLzbinyjmBjLw X-Received: by 2002:a05:6a20:4288:b0:11f:4412:fc77 with SMTP id o8-20020a056a20428800b0011f4412fc77mr6576723pzj.17.1687370627863; Wed, 21 Jun 2023 11:03:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687370627; cv=none; d=google.com; s=arc-20160816; b=DcoWtlPolbmAkzhlXCfdLY7tL1ZWwK9jDKjV/auVymKxgDowxMZcPbxBC6I5Oyq+PB KQH+pbId3vTumVJ3gqYlwrr28vIMT90QSe6MNOeodd3U4sAIgwiCnYkR9TGvBTt4jqiz 7JAn+kmwYxpdfBiI/u/BMHANtK7KJe6ABHL7OwKhBqj+Btng3gR1/VUZwqEF582ICyb1 CKKwfEcp9NzFn/QSdb3I9If2EQUon1gccJsd4tZ219BV7dq8lDqKLhzu0PFOcJT7xrkx EjypM0FpAZbpeBGVraA9Rj88VxASS7TZCx4nr4Uyy9C0bbROB0DedgvQGQVcmh+ZY3Kk AOtA== 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=AcOoaKYWtnXVk0k+hK8RP3KkSMP7FlPHQIbKB3NJEDQ=; b=o1MBphFLFy/zXawrdWRND3tEzJALRpeLJvA0k3ZmdV+HPPlJ+h4fB9MlfIk026UfTi 4sEZ5lduXCWiBtFH7tkbEGc20VcpzHoCRQK7Y4znWqZUm5XZwcr0i+GZlm2uJ83Kxn7W 1XuOfSx2/pb1cMzWZ1bwIolhxzp4UpsoLG0ercMJUxuGGJMkJzJv/6s78qLlvhsNUuey ZEC5xF/DWYEqMvuV+sHE7QxI2fpCiAsycg5vgKn1cM/4SruPzsoLXyzQIi+SAfOdbkYk hCecN31Mmb0TiLh1KizVVDBD2y56wFk9cLYql1IngZopJSeUCf0YYyWY3rWVbAH/l39N DV5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=XJObtDWv; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bv64-20020a632e43000000b00553c2f59c1esi1098926pgb.193.2023.06.21.11.03.34; Wed, 21 Jun 2023 11:03:47 -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=XJObtDWv; 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 S231305AbjFURto (ORCPT + 99 others); Wed, 21 Jun 2023 13:49:44 -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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769336343639237418?= X-GMAIL-MSGID: =?utf-8?q?1769336343639237418?= As a preparatory patch and for the sake of consistency, factor out gpiochip_simple_create_domain(). Signed-off-by: Andy Shevchenko Reviewed-by: Linus Walleij --- 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) { From patchwork Wed Jun 21 17:49:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 111234 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp4544042vqr; Wed, 21 Jun 2023 10:59:43 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7cxC6AKhLABCosUnWvCw0AGlNRpU7K3bgOrhyNgAd/WAyxNpBlvLpzJHw9TQw1/kQxqVTC X-Received: by 2002:a05:6a20:54aa:b0:112:2843:b546 with SMTP id i42-20020a056a2054aa00b001122843b546mr21202165pzk.58.1687370383392; Wed, 21 Jun 2023 10:59:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687370383; cv=none; d=google.com; s=arc-20160816; b=gvCPR7aIxiSeEaI9ZeQni4nlwoJUtU2RPio4lIeCHQqgcVUAM9GwzLxEiXSVF+2R9z R0Au8TKXyt6/HxZnH7JUufO6TfcCcf5OmJdSrltenjIEVr7RfkE5RtdxtXYWvMnfRUX/ SkAHwAVN/Kb6Nc6OspQ44zi/ar5QNB5mw4VHIhm2ybAAR3c8Rj4QdO5u495rfPDI0kIw NrWAonjTpF17zlSOCQWuiOx4ViIfi7nA9Ryj527XuwRT2KuB0s+QYk666Z6z1wMbGDFy U4Tys6OPBFpGqKjl7fi/09aztJ81INzX8wxJxQt5TX6bLGG7fN1qgMHyo88mLO7CPJRY koEw== 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=0OEiqXZhWHH9FeDquqCGZsoRuVpkNMSYCcDKLH82Cgc=; b=x7pDYKBGphrEyR6ZLLSyvMVoN9+ocVUfAAO28rzyQUZsL0Rac2qDRK8JCYb8kwP1XV aQRL0oBS8Hlv1YOl04qZAbQ7B2wWBJA6m8kEUYUx0+qZXCLEiDWY3R9ca1XykwVPWBqp gTgeKDelZd/u0bzHlWVIBN3fGaNW30RY1+jhUGKYQFwFyizMwwc6OVKfvPumUfwffj1a dJ3boECLrIAro0t5DyN1+YV97qCtOXY4yQ50dPLr/AHcXplWp4O97sZIzBvEf2gyhuZ4 bNbi7xa1nGmW5zWOYcobtX+F9IISIP8laflrTFeC0EN04w5a8KIV0VqbjldEN9xrBwyS MoOA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=VZZtPqFf; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y19-20020a63b513000000b005538a669b5fsi4458860pge.212.2023.06.21.10.59.28; Wed, 21 Jun 2023 10:59:43 -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=VZZtPqFf; 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 S231629AbjFURuZ (ORCPT + 99 others); Wed, 21 Jun 2023 13:50:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51544 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231646AbjFURty (ORCPT ); Wed, 21 Jun 2023 13:49:54 -0400 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C8C7A1BC3; Wed, 21 Jun 2023 10:49:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1687369790; x=1718905790; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=MGD3tk/qL1WcZv7h1naypCRcwmKu0ejHb+zaSupSua4=; b=VZZtPqFf3pVdiiAF8njYL2CJbWrufuHyp65jOfg4x60PMPSXh/pdkhSF FKlGqDyXiZg7YypEXuNeQU60xjTO3zar32DSi3lsxYrKJgU1/hqHUNkA8 rM+mHyn4s3w4+79Z8c+tie2RO2DOQufUTnHtC3qRJdlkLoiUz1IBEGO8l B91OSM2ZTrCZIP5mA4UusHX+lUtnvEI1gg2DtOOITDhH8hO3jaHYtctEe Yovlizl9AtmSpU0i/AVoSasS9VucVxWVXxhGOD/geiUzG6G2ptB9J4Sq1 8rufD7F3GAL19MTBYnC9Lg2UhQGpZRFYGTMB5YJwOTFJN4Shi6T+9vwVk Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10748"; a="344988562" X-IronPort-AV: E=Sophos;i="6.00,261,1681196400"; d="scan'208";a="344988562" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga106.jf.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="888775360" X-IronPort-AV: E=Sophos;i="6.00,261,1681196400"; d="scan'208";a="888775360" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga005.jf.intel.com with ESMTP; 21 Jun 2023 10:49:39 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 84880241; 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 3/5] gpiolib: Do not assign error pointer to the GPIO IRQ chip domain Date: Wed, 21 Jun 2023 20:49:41 +0300 Message-Id: <20230621174943.30302-3-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 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769336087440906778?= X-GMAIL-MSGID: =?utf-8?q?1769336087440906778?= Check domain for being an error pointer before assigning it to the GPIO IRQ chip domain. Signed-off-by: Andy Shevchenko Reviewed-by: Linus Walleij --- drivers/gpio/gpiolib.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index fac1124d5016..0e40f9a44519 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -1647,6 +1647,7 @@ static int gpiochip_add_irqchip(struct gpio_chip *gc, { struct fwnode_handle *fwnode = dev_fwnode(&gc->gpiodev->dev); struct irq_chip *irqchip = gc->irq.chip; + struct irq_domain *domain; unsigned int type; unsigned int i; @@ -1679,14 +1680,13 @@ static int gpiochip_add_irqchip(struct gpio_chip *gc, /* If a parent irqdomain is provided, let's build a hierarchy */ if (gpiochip_hierarchy_is_hierarchical(gc)) { - gc->irq.domain = gpiochip_hierarchy_create_domain(gc); - if (IS_ERR(gc->irq.domain)) - return PTR_ERR(gc->irq.domain); + domain = gpiochip_hierarchy_create_domain(gc); } else { - gc->irq.domain = gpiochip_simple_create_domain(gc); - if (IS_ERR(gc->irq.domain)) - return PTR_ERR(gc->irq.domain); + domain = gpiochip_simple_create_domain(gc); } + if (IS_ERR(domain)) + return PTR_ERR(domain); + gc->irq.domain = domain; if (gc->irq.parent_handler) { for (i = 0; i < gc->irq.num_parents; i++) { From patchwork Wed Jun 21 17:49:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 111229 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp4540667vqr; Wed, 21 Jun 2023 10:52:47 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ48FtM0TbLgp8a10g7W6eufs/g3SmoIm0qaE19o3Kc5yTwFMzdlh2dAZtlHK37SQii1lyZl X-Received: by 2002:a05:6808:1792:b0:39e:b986:6609 with SMTP id bg18-20020a056808179200b0039eb9866609mr16113238oib.38.1687369966865; Wed, 21 Jun 2023 10:52:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687369966; cv=none; d=google.com; s=arc-20160816; b=zqmc4UWTcFsMFGuOLz71o2fTaT5TNOtomRhY2N104ePwCoskdgTd5m1MUTrrySDZh1 9qulWsErUDxTudmFd8Rlm2HxiknVNoo2QtrS1vioHYIIbUyHaanlmS6Im/i0YPPmkN1I yuivjNsIh7jjFEJ3RhrRQQEoLnN5m/+W8l29fmaenORiVh6kVx9ibypOj7gBhHNdu0E3 NquLZcJF8xTeK5eDSVyPaDryMu8nrqjmd09mTo3UAoRdt/zHWwY7LMEwBMGHJWyzV1lj +Gl5NaX/pVJBpUO7UQDk7I02Nr0gxWcSjavDAUW1hFvFZzaRpa/Btnm0n/HQ9pV7Cqwe YhNQ== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d7-20020a633607000000b0053439c1712esi955962pga.713.2023.06.21.10.52.33; Wed, 21 Jun 2023 10:52:46 -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 S231234AbjFURtt (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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769335650091244426?= X-GMAIL-MSGID: =?utf-8?q?1769335650091244426?= The gpiochip_irqchip_add_allocated_domain() can be used in another place in the code. Signed-off-by: Andy Shevchenko Reviewed-by: Linus Walleij --- 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); From patchwork Wed Jun 21 17:49:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 111228 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp4540626vqr; Wed, 21 Jun 2023 10:52:42 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7t2iBAupt7+86ux1oV/bl7x7Ckycv9XzKL5FeRrQK8cnIHr9dZjRScUB063L2kMyh7QxfY X-Received: by 2002:a05:6a20:244c:b0:10a:e8b1:34bb with SMTP id t12-20020a056a20244c00b0010ae8b134bbmr12240580pzc.56.1687369961834; Wed, 21 Jun 2023 10:52:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687369961; cv=none; d=google.com; s=arc-20160816; b=pFh33vIs71pPwKgM08LCih07Csp4O+vs05G2q2gYDpY1jfhv/Q+ZK7m7v1ZoCbp/1n 0oyhDf8pKLjb7KepHbVpqYOOV06b5fiR4jTqirXjUPzvweGF812M/0QLzTIqqI6h1si8 HGKZbXl/icKnhIp/XgeON++U84DKsOkw001yd4R3s8PKjiR5zQ31XFZlK+BSFjtYeuyj mIIMpjzoj8HEpmXZ0Hv7KlGaREpnKymESOsXKCa5E7HTNsApKfASl4e+gzkIoalWTTUU qNa3/gzD52v4X1184ISTsCdV0TFwgyX7CvBTh647Lc9oY/BQcbOZSgxeaiFozoUzHT9J heBQ== 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=BUZKYQOU8fR/Tj7xqTOYL35WDHuQXDQlcCtv+svrSu8=; b=TGOnDarXiSr1RUaMa0a5bnDATdcg6NffWpqMCBQLlNgB4ECruduVd45o8jTrcmhSk0 o7+/AyZXvZUDgDV1qHoxmxUGNvtEXk/UBpNvCVckh3p6G0iauol0WhqnF/RlslYw79Hm TsR/CRKcG4duElLPVy4KFDAAF5WDVKeZ4YbiLcz6h4ieOmlS2iTGAA3u2dKUiHtyRPcA uNGsVITXcL9U2pUtrItAk2a1nmW+Ogz874hssTdbKk+G+0bZXk1tsFI+pOIHWIHYKbOt xKxhtJ1AXsHu2xH1eVppoxZ8q9RKM0P/O6GX9Vbs6CqN55gdGyo7NGF2ijvzS40LmJrH ef2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Zqlqvaks; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 21-20020a621815000000b006662fba14a9si4508258pfy.73.2023.06.21.10.52.29; Wed, 21 Jun 2023 10:52:41 -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=Zqlqvaks; 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 S231450AbjFURtr (ORCPT + 99 others); Wed, 21 Jun 2023 13:49:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51310 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231465AbjFURtp (ORCPT ); Wed, 21 Jun 2023 13:49:45 -0400 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C91F81733; Wed, 21 Jun 2023 10:49:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1687369782; x=1718905782; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=N75xiFEB2l7sDxs1N2ykos/S0hCXGE4VnACWdbw7VI8=; b=Zqlqvaks/91GNYVJOgsnKR0T7jdDpb9cPmH1rnvkxcgM2YwhYeoYo9NB rTPYS4Xpx1TNH48vXOExYsDsBQ+/4Eg9ho4OS/xShY/BbNc67HsDjYV0U ZsuzVntAnsPBMquD0439gGBqw9pZKII458BXMGOUgOA7CJzZacqxi+KkQ gedDk4CVwiJ2cF1ntt6OK81QszzwPFUTkwA7y7Xqnv7G4wkp+DzAXg2KD kHlcr/OKzZHDZfjnAROPa+eBU/zPaIHga/UrVJZn7Gg84Orh5IGFZSS2P CHQtNqmhBxkeGakdEd6Yv5urzybaELouc8V3j5HGoVbWjYvz3KhdlYh6i Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10748"; a="389819289" X-IronPort-AV: E=Sophos;i="6.00,261,1681196400"; d="scan'208";a="389819289" 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="691928081" X-IronPort-AV: E=Sophos;i="6.00,261,1681196400"; d="scan'208";a="691928081" 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 8FCDA1FD; 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 5/5] gpiolib: Replace open coded gpiochip_irqchip_add_allocated_domain() Date: Wed, 21 Jun 2023 20:49:43 +0300 Message-Id: <20230621174943.30302-5-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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769335644796794441?= X-GMAIL-MSGID: =?utf-8?q?1769335644796794441?= Replace open coded variant of gpiochip_irqchip_add_allocated_domain() in gpiochip_add_irqchip(). Signed-off-by: Andy Shevchenko Reviewed-by: Linus Walleij --- drivers/gpio/gpiolib.c | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 59d87e60b108..bc8b9d6afe0e 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -1642,6 +1642,9 @@ static int gpiochip_irqchip_add_allocated_domain(struct gpio_chip *gc, if (!domain) return -EINVAL; + if (gc->to_irq) + chip_warn(gc, "to_irq is redefined in %s and you shouldn't rely on it\n", __func__); + gc->to_irq = gpiochip_to_irq; gc->irq.domain = domain; gc->irq.domain_is_allocated_externally = allocated_externally; @@ -1672,6 +1675,7 @@ static int gpiochip_add_irqchip(struct gpio_chip *gc, struct irq_domain *domain; unsigned int type; unsigned int i; + int ret; if (!irqchip) return 0; @@ -1692,10 +1696,6 @@ static int gpiochip_add_irqchip(struct gpio_chip *gc, "%pfw: Ignoring %u default trigger\n", fwnode, type)) type = IRQ_TYPE_NONE; - if (gc->to_irq) - chip_warn(gc, "to_irq is redefined in %s and you shouldn't rely on it\n", __func__); - - gc->to_irq = gpiochip_to_irq; gc->irq.default_type = type; gc->irq.lock_key = lock_key; gc->irq.request_key = request_key; @@ -1708,7 +1708,6 @@ static int gpiochip_add_irqchip(struct gpio_chip *gc, } if (IS_ERR(domain)) return PTR_ERR(domain); - gc->irq.domain = domain; if (gc->irq.parent_handler) { for (i = 0; i < gc->irq.num_parents; i++) { @@ -1732,14 +1731,9 @@ static int gpiochip_add_irqchip(struct gpio_chip *gc, gpiochip_set_irq_hooks(gc); - /* - * Using barrier() here to prevent compiler from reordering - * gc->irq.initialized before initialization of above - * GPIO chip irq members. - */ - barrier(); - - gc->irq.initialized = true; + ret = gpiochip_irqchip_add_allocated_domain(gc, domain, false); + if (ret) + return ret; acpi_gpiochip_request_interrupts(gc);