Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754033AbdHRAzA (ORCPT ); Thu, 17 Aug 2017 20:55:00 -0400 Received: from mail-cys01nam02on0075.outbound.protection.outlook.com ([104.47.37.75]:46231 "EHLO NAM02-CY1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753892AbdHRAxr (ORCPT ); Thu, 17 Aug 2017 20:53:47 -0400 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=David.Daney@cavium.com; From: David Daney To: Linus Walleij , Alexandre Courbot , Mark Rutland , Marc Zyngier , Thomas Gleixner , linux-gpio@vger.kernel.org Cc: linux-kernel@vger.kernel.org, David Daney Subject: [PATCH v8 3/7] irqdomain: Factor out code to add and remove items to and from the revmap Date: Thu, 17 Aug 2017 17:53:32 -0700 Message-Id: <1503017616-3252-4-git-send-email-david.daney@cavium.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1503017616-3252-1-git-send-email-david.daney@cavium.com> References: <1503017616-3252-1-git-send-email-david.daney@cavium.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [50.233.148.156] X-ClientProxiedBy: CO2PR07CA0061.namprd07.prod.outlook.com (10.174.192.29) To CY4PR07MB3493.namprd07.prod.outlook.com (10.171.252.150) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b2af913c-23d7-41e8-ecfd-08d4e5d3944a X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254152)(300000503095)(300135400095)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095);SRVR:CY4PR07MB3493; X-Microsoft-Exchange-Diagnostics: 1;CY4PR07MB3493;3:lb93IHCrHReqsgbDaKJWMjgT+TBNFluo+aw10+F39cAGcJQQrFvsgVixNWbIZc/AvLq1vwnIARYfsQpg0olM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fP0nRZqklArkiVytQ/9uj8eBXKymC50GOYRWnQBUL0PKT5r6BKfxrhIRA6XlDvWwiuNKFnRR2lWkd9+MNUeH+guYhsJPrrS7b3QLLcyyQURArTTtUf/OxxQk4TmMHnqLGSn2Km3aj85o/S5SqNqDLN4Ywj0eW3JACCsrbt68YR4+ANq9BE24oMwcZHSWvYe35h4TGVXZ/GpBf71MKtKp1Iys3Cd7CjNx6YQFSNfW2JfRg54X+81c0dKr8DuAn2CMhni/R7fz;4:wPPeMr67aQWhYDxZE8vkHdUdDH71BMXnytA2093ReIr03q2QNM//gNgL1Ymii6k6VQFFeEkriL8PaMrw3BDJ0OMOKVuQFhWsBKpw9cGBkTDt5lCQdoqbsk/9ft3OgPoD5DBqGwu54Z5cR78v9MJB8AJ5b+grpF45kAacjA+CkheOCANpwcPAoDLdqK/EUA7JfsSuOU0gNKpSx3eMKuosa1SACnDj8HLnQR/CcNyqkLFn2ZXQ6ndN05WmFSxPICYO X-Exchange-Antispam-Report-Test: UriScan:; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(5005006)(8121501046)(10201501046)(3002001)(100000703101)(100105400095)(93006095)(93001095)(6041248)(20161123562025)(20161123564025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123555025)(20161123560025)(20161123558100)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:CY4PR07MB3493;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:CY4PR07MB3493; X-Forefront-PRVS: 040359335D X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(4630300001)(7370300001)(6009001)(189002)(199003)(69596002)(72206003)(50226002)(6116002)(3846002)(4326008)(105586002)(42186005)(2950100002)(6666003)(5003940100001)(4720700003)(76176999)(50986999)(5660300001)(189998001)(7350300001)(53416004)(33646002)(101416001)(53936002)(478600001)(6512007)(50466002)(2906002)(48376002)(7736002)(68736007)(107886003)(66066001)(25786009)(86362001)(47776003)(97736004)(36756003)(106356001)(6486002)(6506006)(305945005)(81156014)(81166006)(8676002);DIR:OUT;SFP:1101;SCL:1;SRVR:CY4PR07MB3493;H:ubuntu.caveonetworks.com;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;CY4PR07MB3493;23:w2I+p8TSFwzOj+qleOgxLLl0RMjvXnsRYhtvaKok+?= =?us-ascii?Q?600mC8U3CVAara53T4z9KZR0jCRuBoe/e293xwsfm3ch5QqB/0oAZnXQKbAx?= =?us-ascii?Q?l8TkpmBCZukDG7NYDQ/Ehuxq0dCGTeGrpKLM7+kdZF82Gq7dANz8XIuqkEhv?= =?us-ascii?Q?fWbhNMijlMFqGktopBab1KullX48+3UcpcMf3dDwoErvqTbi/mv5o/0wvrw4?= =?us-ascii?Q?pjXRvzws4A08kPHpKBt0LFai1W7zxyooXspNkIsygSrMBZZ4WP+HGF+NewK6?= =?us-ascii?Q?V+/mZxbHAtwvVqAr/PvcQ86ZCj6LV4+5yrV6cFVEp0FTG6accEvTsRx2UXQe?= =?us-ascii?Q?pLRsIFdZCz3vJzoP0Lr3AAYWauJL1WYjkxJLrg/8f+HzdJHkQFnhhYbJc4BM?= =?us-ascii?Q?FI+UHMAFTwr7ifKn7mviYBWQynxhJz/6X0dtKZt0uu71QUsHyF5V428PInBV?= =?us-ascii?Q?AcEW7tIk48e/GdHvg6+8WRK+lRK/FM8+h4chVhbe3Xj/goIuQMeg8GPsrRG/?= =?us-ascii?Q?HV1JTDXwf5A/zGBBd17IQsJOuko6vl2P60ByB5KdvTGme4ED1KiBSaa6vSX7?= =?us-ascii?Q?dmNPXD7L3NsjHKtYyPCIS7CuvY0uzGYDdtz0pb12rlpmYOx/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3cbgSGDSW4U63GOLTJvDUaBbSLQkd8colQ6CpAcqP2E4svA2IjrXO0FKBublQeIJVBHbBtgKesG+lwqhfb+2jrqA7xNVuL4ALBkBbcls8a+4hpBjFQkawORMWpsfINw==;24:ye4ETwSD9MNiPC2As+KtArZtbXIPi/LEgOtQ6wGJtT2UtOQlZ5fLJvjJVMAyE9LVpErI3DPYjVZN2tSvsQewJd5eMQyggxNC/CfWSU6+/e0=;7:pKHbHtSR57K3ciA3Zz91Ybri8R/4UfuoSdZgqRqrpDUiyLmeIEw05xwyErUjEzhseEuRJZKQA7IUiL1m8NmQBuHlbKIGAa25Ok0l4rhlVztecL/TPnr5Z7SCOhONyRuR2xFECHyCfAzYIv9rIVQSXDlol0Ee1bVGkbcd8AywqZUAw49/4lLQWAWlVQMSuEla8qjbYJTjK6sJjLHqiZG0ELZFfh6qr2ENNUcsB/xxarI= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: cavium.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Aug 2017 00:53:45.0247 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR07MB3493 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3518 Lines: 112 The code to add and remove items to and from the revmap occurs several times. In preparation for the follow on patches that add more uses of this code, factor this out in to separate static functions. Signed-off-by: David Daney --- kernel/irq/irqdomain.c | 58 +++++++++++++++++++++++++------------------------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c index f1f2514..2093b88 100644 --- a/kernel/irq/irqdomain.c +++ b/kernel/irq/irqdomain.c @@ -455,6 +455,31 @@ void irq_set_default_host(struct irq_domain *domain) } EXPORT_SYMBOL_GPL(irq_set_default_host); +static void irq_domain_clear_mapping(struct irq_domain *domain, + irq_hw_number_t hwirq) +{ + if (hwirq < domain->revmap_size) { + domain->linear_revmap[hwirq] = 0; + } else { + mutex_lock(&revmap_trees_mutex); + radix_tree_delete(&domain->revmap_tree, hwirq); + mutex_unlock(&revmap_trees_mutex); + } +} + +static void irq_domain_set_mapping(struct irq_domain *domain, + irq_hw_number_t hwirq, + struct irq_data *irq_data) +{ + if (hwirq < domain->revmap_size) { + domain->linear_revmap[hwirq] = irq_data->irq; + } else { + mutex_lock(&revmap_trees_mutex); + radix_tree_insert(&domain->revmap_tree, hwirq, irq_data); + mutex_unlock(&revmap_trees_mutex); + } +} + void irq_domain_disassociate(struct irq_domain *domain, unsigned int irq) { struct irq_data *irq_data = irq_get_irq_data(irq); @@ -483,13 +508,7 @@ void irq_domain_disassociate(struct irq_domain *domain, unsigned int irq) domain->mapcount--; /* Clear reverse map for this hwirq */ - if (hwirq < domain->revmap_size) { - domain->linear_revmap[hwirq] = 0; - } else { - mutex_lock(&revmap_trees_mutex); - radix_tree_delete(&domain->revmap_tree, hwirq); - mutex_unlock(&revmap_trees_mutex); - } + irq_domain_clear_mapping(domain, hwirq); } int irq_domain_associate(struct irq_domain *domain, unsigned int virq, @@ -533,13 +552,7 @@ int irq_domain_associate(struct irq_domain *domain, unsigned int virq, } domain->mapcount++; - if (hwirq < domain->revmap_size) { - domain->linear_revmap[hwirq] = virq; - } else { - mutex_lock(&revmap_trees_mutex); - radix_tree_insert(&domain->revmap_tree, hwirq, irq_data); - mutex_unlock(&revmap_trees_mutex); - } + irq_domain_set_mapping(domain, hwirq, irq_data); mutex_unlock(&irq_domain_mutex); irq_clear_status_flags(virq, IRQ_NOREQUEST); @@ -1138,16 +1151,9 @@ static void irq_domain_insert_irq(int virq) for (data = irq_get_irq_data(virq); data; data = data->parent_data) { struct irq_domain *domain = data->domain; - irq_hw_number_t hwirq = data->hwirq; domain->mapcount++; - if (hwirq < domain->revmap_size) { - domain->linear_revmap[hwirq] = virq; - } else { - mutex_lock(&revmap_trees_mutex); - radix_tree_insert(&domain->revmap_tree, hwirq, data); - mutex_unlock(&revmap_trees_mutex); - } + irq_domain_set_mapping(domain, data->hwirq, data); /* If not already assigned, give the domain the chip's name */ if (!domain->name && data->chip) @@ -1171,13 +1177,7 @@ static void irq_domain_remove_irq(int virq) irq_hw_number_t hwirq = data->hwirq; domain->mapcount--; - if (hwirq < domain->revmap_size) { - domain->linear_revmap[hwirq] = 0; - } else { - mutex_lock(&revmap_trees_mutex); - radix_tree_delete(&domain->revmap_tree, hwirq); - mutex_unlock(&revmap_trees_mutex); - } + irq_domain_clear_mapping(domain, hwirq); } } -- 1.8.3.1