From patchwork Tue Feb 16 16:02:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Dejin Zheng X-Patchwork-Id: 12090205 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0D748C433E6 for ; Tue, 16 Feb 2021 16:03:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D5FB464D9F for ; Tue, 16 Feb 2021 16:03:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230352AbhBPQDq (ORCPT ); Tue, 16 Feb 2021 11:03:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43588 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230263AbhBPQDn (ORCPT ); Tue, 16 Feb 2021 11:03:43 -0500 Received: from mail-pj1-x102e.google.com (mail-pj1-x102e.google.com [IPv6:2607:f8b0:4864:20::102e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 58347C06174A; Tue, 16 Feb 2021 08:03:03 -0800 (PST) Received: by mail-pj1-x102e.google.com with SMTP id fa16so5950209pjb.1; Tue, 16 Feb 2021 08:03:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=SEY8lEZGS42JtvMA8omGE4HeCsllkcm6O1GjxwD/puQ=; b=SLvnWcWyt22Sv0apOdq4AeyyVojvsiukA1JWoFTxBpGP9pYnwlfKd56wAtUoQXKaRD x8U6cdxLWUhcM2NwoFeVTCeAJeSLeF9tQOB0faHRbJlo0QSEljEEW6gpJI3+q+HidTue ewgOzp996mf5MBgkcBkv6JvxpsJN+TceSkhkN02kLadcefpJraqa0ujZ0XwvuvknhWFC Xr+Oi6M1/Nj9M5nUJSdvc558ClRis1NDTPQV076NNxU+w8RPuMih9NasR+nvJ7uEVrg6 aoDeJBpYDe4RlK8DOIqvIsk5moiNk+fTv6u38oT6BqkDsFadgGSsKUhXWYduSxdMWKZF Inqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=SEY8lEZGS42JtvMA8omGE4HeCsllkcm6O1GjxwD/puQ=; b=CwIU1bVqr5OoRiwOtDnUfsnnrERNmxC+St/SvhIdN81+5avysvqfAU3OGm4bb8tYGH 3B7qlF2GTobuOFfLeBW03dMhgtOffsMZMh9/zkvo5AE+oaG4fbZEBiayvUCDD6NkTzFq CoxNPX3HxE8qHLWMtU7VDIdl1lKHT32X45xXSowtjcwlYvPbMSdGlMd0Cpo5JkntFwPD A/TjiqFcfJm7Vr71+Nc/D1qm+t1PTZiZ0EkCCIM3u8jtdFsJB/9ZKbSf7xmlQVpSqwXt K86hGtmkmVfyMisssLHRvhtSgK9uNQE2Qow7/08s0t58rtHBH2A23FHihaMmUhkcFgpJ dp5w== X-Gm-Message-State: AOAM531j2wNFeoeh3x+T/VuDqmogaRB8RaK+d7pz9vCk7SKJdnLctzhK VUid2oURvkNb+91NOT+sjxYTdGuBX/6qBA== X-Google-Smtp-Source: ABdhPJydthKBcD4fnX26mG7IXBsRFXO2WwBSkkinI0zQGvCd03M34HB9dEF9WYTQGa0Z6NnDliSktQ== X-Received: by 2002:a17:90a:8c87:: with SMTP id b7mr5024018pjo.158.1613491382978; Tue, 16 Feb 2021 08:03:02 -0800 (PST) Received: from localhost (185.212.56.4.16clouds.com. [185.212.56.4]) by smtp.gmail.com with ESMTPSA id z16sm2949472pgk.13.2021.02.16.08.03.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Feb 2021 08:03:02 -0800 (PST) From: Dejin Zheng To: corbet@lwn.net, jarkko.nikula@linux.intel.com, andriy.shevchenko@linux.intel.com, mika.westerberg@linux.intel.com, rric@kernel.org, bhelgaas@google.com, wsa@kernel.org, linux-doc@vger.kernel.org, linux-i2c@vger.kernel.org, linux-pci@vger.kernel.org, kw@linux.com Cc: linux-kernel@vger.kernel.org, Dejin Zheng Subject: [PATCH v3 1/4] PCI: Introduce pcim_alloc_irq_vectors() Date: Wed, 17 Feb 2021 00:02:46 +0800 Message-Id: <20210216160249.749799-2-zhengdejin5@gmail.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20210216160249.749799-1-zhengdejin5@gmail.com> References: <20210216160249.749799-1-zhengdejin5@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Introduce pcim_alloc_irq_vectors(), a device-managed version of pci_alloc_irq_vectors(). Introducing this function can simplify the error handling path in many drivers. And use pci_free_irq_vectors() to replace some code in pcim_release(), they are equivalent, and no functional change. It is more explicit that pcim_alloc_irq_vectors() is a device-managed function. Suggested-by: Andy Shevchenko Signed-off-by: Dejin Zheng Reviewed-by: Krzysztof Wilczyński --- v2 -> v3: - Add some commit comments for replace some codes in pcim_release() by pci_free_irq_vectors(). v1 -> v2: - Use pci_free_irq_vectors() to replace some code in pcim_release(). - Modify some commit messages. drivers/pci/pci.c | 33 +++++++++++++++++++++++++++++---- include/linux/pci.h | 3 +++ 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index b67c4327d307..db799d089c85 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -1969,10 +1969,7 @@ static void pcim_release(struct device *gendev, void *res) struct pci_devres *this = res; int i; - if (dev->msi_enabled) - pci_disable_msi(dev); - if (dev->msix_enabled) - pci_disable_msix(dev); + pci_free_irq_vectors(dev); for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) if (this->region_mask & (1 << i)) @@ -2054,6 +2051,34 @@ void pcim_pin_device(struct pci_dev *pdev) } EXPORT_SYMBOL(pcim_pin_device); +/** + * pcim_alloc_irq_vectors - a device-managed pci_alloc_irq_vectors() + * @dev: PCI device to operate on + * @min_vecs: minimum number of vectors required (must be >= 1) + * @max_vecs: maximum (desired) number of vectors + * @flags: flags or quirks for the allocation + * + * Return the number of vectors allocated, (which might be smaller than + * @max_vecs) if successful, or a negative error code on error. If less + * than @min_vecs interrupt vectors are available for @dev the function + * will fail with -ENOSPC. + * + * It depends on calling pcim_enable_device() to make IRQ resources + * manageable. + */ +int pcim_alloc_irq_vectors(struct pci_dev *dev, unsigned int min_vecs, + unsigned int max_vecs, unsigned int flags) +{ + struct pci_devres *dr; + + dr = find_pci_dr(dev); + if (!dr || !dr->enabled) + return -EINVAL; + + return pci_alloc_irq_vectors(dev, min_vecs, max_vecs, flags); +} +EXPORT_SYMBOL(pcim_alloc_irq_vectors); + /* * pcibios_add_device - provide arch specific hooks when adding device dev * @dev: the PCI device being added diff --git a/include/linux/pci.h b/include/linux/pci.h index 86c799c97b77..d75ba85ddfc5 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -1818,6 +1818,9 @@ pci_alloc_irq_vectors(struct pci_dev *dev, unsigned int min_vecs, NULL); } +int pcim_alloc_irq_vectors(struct pci_dev *dev, unsigned int min_vecs, + unsigned int max_vecs, unsigned int flags); + /* Include architecture-dependent settings and functions */ #include From patchwork Tue Feb 16 16:02:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Dejin Zheng X-Patchwork-Id: 12090207 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6E61AC433DB for ; Tue, 16 Feb 2021 16:04:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4738D614A5 for ; Tue, 16 Feb 2021 16:04:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230337AbhBPQDs (ORCPT ); Tue, 16 Feb 2021 11:03:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43598 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230353AbhBPQDq (ORCPT ); Tue, 16 Feb 2021 11:03:46 -0500 Received: from mail-pf1-x42c.google.com (mail-pf1-x42c.google.com [IPv6:2607:f8b0:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1A900C061756; Tue, 16 Feb 2021 08:03:06 -0800 (PST) Received: by mail-pf1-x42c.google.com with SMTP id b145so6412713pfb.4; Tue, 16 Feb 2021 08:03:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=vLYno5aciuzWdkhSYU1ddjoRMBsS1paz+F+v6wPI8Hc=; b=krRQBl1JLay6HNr6hIjHnM54AIGq/vAIjBaq9YbAtVKVxNGzu8E4zfhwqgtZDS+1pt x3gpiUR8q+gLTlW/P1UGuyaYsQFkpSwxHPR3xFrbWc+qGFeWONa5i1ZrNKBfP3+rfHXZ 3oPIyekKvvf5S2HhMQisIKWESRJLvlPXN07gXex7D8PWBPXoGwUQG8Iik+moR1MckGAf mzDHrEdXm1pzlyiTdsFhckV4Kyy10A9YkocU1+wg44nOJ0Nl+Tz3upI6/QXRf8YZ6nLA vxkb4r7p0x5klG4h5xIw1HKSteVzFK7LwqqtBsVqOj51Vw6WNE4E5wWsMct3n1s6tBrt xxbg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=vLYno5aciuzWdkhSYU1ddjoRMBsS1paz+F+v6wPI8Hc=; b=RT5IA/zLGPuGKlgKBjrNp+goueY+DY3SyAuLiHbOFNIoULiJ4XgQqVoQ/YUWf+59P+ A6lr96P+oIWL/SIVKiB+z3NvnBbDiKC4fs2wSbs8wfsM4hIZ1uIDQCXaCBfAm3no/Dch L+89ZfOAO1AluNVHLSZDtOw62p4KuymJzRRrC02EgdKUuD0iDgmBWMPpEwUgOpjIlhPQ 0DeRGT2HevPFyF/PqssNXobXEEIyDgplw5HKlxCIJ5Gk4fSi4sDR1wtCS5lW+7BZgGA5 Ni85p6PXt2IMcg55L+Oy6m7T2qla76WRjQTyOmckuvI++HqKXwRAgT/89OoNcHgzP3dK 1wVw== X-Gm-Message-State: AOAM531Nc9Ex1EBGG7f03as9Rzexzn8gwK8qjXwSqEqyElSo6cjx5plp zUyV44i0GE88soC05kBsEHE= X-Google-Smtp-Source: ABdhPJxYGWys9szZhDZBKBrk8Fc7ZjUgWYbHqr34rbhGZ2C6OGUU6ANP2huG0CSkTO41JQRuOUxboA== X-Received: by 2002:a62:e804:0:b029:1dd:cf18:bdee with SMTP id c4-20020a62e8040000b02901ddcf18bdeemr20780783pfi.63.1613491385721; Tue, 16 Feb 2021 08:03:05 -0800 (PST) Received: from localhost (185.212.56.4.16clouds.com. [185.212.56.4]) by smtp.gmail.com with ESMTPSA id g8sm3579464pjj.41.2021.02.16.08.03.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Feb 2021 08:03:05 -0800 (PST) From: Dejin Zheng To: corbet@lwn.net, jarkko.nikula@linux.intel.com, andriy.shevchenko@linux.intel.com, mika.westerberg@linux.intel.com, rric@kernel.org, bhelgaas@google.com, wsa@kernel.org, linux-doc@vger.kernel.org, linux-i2c@vger.kernel.org, linux-pci@vger.kernel.org, kw@linux.com Cc: linux-kernel@vger.kernel.org, Dejin Zheng Subject: [PATCH v3 2/4] Documentation: devres: Add pcim_alloc_irq_vectors() Date: Wed, 17 Feb 2021 00:02:47 +0800 Message-Id: <20210216160249.749799-3-zhengdejin5@gmail.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20210216160249.749799-1-zhengdejin5@gmail.com> References: <20210216160249.749799-1-zhengdejin5@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Add pcim_alloc_irq_vectors(), a device-managed version of pci_alloc_irq_vectors(). introducing this function can simplify the error handling path in many drivers. Signed-off-by: Dejin Zheng Reviewed-by: Krzysztof Wilczyński --- v2 -> v3: - No change v1 -> v2: - Modify some commit messages. Documentation/driver-api/driver-model/devres.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/Documentation/driver-api/driver-model/devres.rst b/Documentation/driver-api/driver-model/devres.rst index cd8b6e657b94..a52f65b6352f 100644 --- a/Documentation/driver-api/driver-model/devres.rst +++ b/Documentation/driver-api/driver-model/devres.rst @@ -380,6 +380,7 @@ PCI devm_pci_alloc_host_bridge() : managed PCI host bridge allocation devm_pci_remap_cfgspace() : ioremap PCI configuration space devm_pci_remap_cfg_resource() : ioremap PCI configuration space resource + pcim_alloc_irq_vectors() : managed IRQ vectors allocation pcim_enable_device() : after success, all PCI ops become managed pcim_pin_device() : keep PCI device enabled after release From patchwork Tue Feb 16 16:02:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Dejin Zheng X-Patchwork-Id: 12090209 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 39A8CC4332B for ; Tue, 16 Feb 2021 16:04:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 11E1E64D9F for ; Tue, 16 Feb 2021 16:04:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230153AbhBPQDy (ORCPT ); Tue, 16 Feb 2021 11:03:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43614 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230397AbhBPQDs (ORCPT ); Tue, 16 Feb 2021 11:03:48 -0500 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 7F79AC0613D6; Tue, 16 Feb 2021 08:03:08 -0800 (PST) Received: by mail-pl1-x629.google.com with SMTP id s16so1806623plr.9; Tue, 16 Feb 2021 08:03:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=VG6dKCG2ODrov9EapJ5ufxyScu+BNsG2De21xAJ5VII=; b=pYmnxO75ygukI3bZfYQlhKS4QVfSjfAFSgKoEEKv3Cz0rCb+CG3gp/Z8Wi2NDUd7lU icWFzdJnJc7tpkPk0vN16bCJtYwB4jSAztRO+iMm4XVawgAnHJ6eue+4C4d5g1GryRNV 6GvxDDImKiOpqgqjlMDpc97OUj8exidRyPDVMp6gCOP1xfDVTFWOWCfz29ZbHiko59mt BC8EUOJTcm0xxfTnxFGt/4xdFZEMBT5pu8xuZ992LSXpX/My+0a6zh2h8IUzHW59UhTE Im6oBmR4par5vYFdfb1T2i91GtFA0QBudyJ4dHxm4r04hdqM+pHHG5y2bl6fFEbtht+1 azcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=VG6dKCG2ODrov9EapJ5ufxyScu+BNsG2De21xAJ5VII=; b=YY7kD1a6BoPiS3o+mrGFoi4GV9rP6YAVx26BMnPpdMpP4rIZxJzes2x/dx05mmEsDB l5DrSoOUTXrCGwMTFc2WeZumknLK1cEObfUlVUKdlfYvEc+QfOYwOapUUZg+a7hx0UgS YdZogdECDdaya4WCwOmKu14dtzZ9sC7+uhLemFnqZFUYLDuhHRC+/3g6e5RAfLiYelIn cPwgVb7Lca3UF+LTxNX5b3fRvU0PTZHY0yBItw/kU83nrrVHOPyRmhHKlFr7KnDD/1Qz wWaQ2pWtZtrkrd62rFj1OFO50wB0j2kuQlv2Yqjsnunga53J/m1aWYzjJZ+j6NuZMCJb cfNQ== X-Gm-Message-State: AOAM533RZ8Sy4Cr3lb/X920Hy8028lTl8LaSQyjrOkbfFqzkPc/x07l5 fE41/a6T/sXwNjNoq0OZ3FM= X-Google-Smtp-Source: ABdhPJzEPaIyEQLYsXmdZAkNzBYfMzCW1L4BaD4xF/8z8sioVcNFm6B/ACj69VqAJMO0x+kgsLqPEw== X-Received: by 2002:a17:90a:a585:: with SMTP id b5mr4876912pjq.110.1613491388153; Tue, 16 Feb 2021 08:03:08 -0800 (PST) Received: from localhost (185.212.56.4.16clouds.com. [185.212.56.4]) by smtp.gmail.com with ESMTPSA id u15sm5446404pfm.130.2021.02.16.08.03.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Feb 2021 08:03:07 -0800 (PST) From: Dejin Zheng To: corbet@lwn.net, jarkko.nikula@linux.intel.com, andriy.shevchenko@linux.intel.com, mika.westerberg@linux.intel.com, rric@kernel.org, bhelgaas@google.com, wsa@kernel.org, linux-doc@vger.kernel.org, linux-i2c@vger.kernel.org, linux-pci@vger.kernel.org, kw@linux.com Cc: linux-kernel@vger.kernel.org, Dejin Zheng Subject: [PATCH v3 3/4] i2c: designware: Use the correct name of device-managed function Date: Wed, 17 Feb 2021 00:02:48 +0800 Message-Id: <20210216160249.749799-4-zhengdejin5@gmail.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20210216160249.749799-1-zhengdejin5@gmail.com> References: <20210216160249.749799-1-zhengdejin5@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Use the new function pcim_alloc_irq_vectors() to allocate IRQ vectors, the pcim_alloc_irq_vectors() function, an explicit device-managed version of pci_alloc_irq_vectors(). If pcim_enable_device() has been called before, then pci_alloc_irq_vectors() is actually a device-managed function. It is used here as a device-managed function, So replace it with pcim_alloc_irq_vectors(). At the same time, simplify the error handling path. Signed-off-by: Dejin Zheng Reviewed-by: Krzysztof Wilczyński --- v2 -> v3: - simplify the error handling path. v1 -> v2: - Modify some commit messages. drivers/i2c/busses/i2c-designware-pcidrv.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/drivers/i2c/busses/i2c-designware-pcidrv.c b/drivers/i2c/busses/i2c-designware-pcidrv.c index 55c83a7a24f3..620b41e373b6 100644 --- a/drivers/i2c/busses/i2c-designware-pcidrv.c +++ b/drivers/i2c/busses/i2c-designware-pcidrv.c @@ -219,7 +219,7 @@ static int i2c_dw_pci_probe(struct pci_dev *pdev, if (!dev) return -ENOMEM; - r = pci_alloc_irq_vectors(pdev, 1, 1, PCI_IRQ_ALL_TYPES); + r = pcim_alloc_irq_vectors(pdev, 1, 1, PCI_IRQ_ALL_TYPES); if (r < 0) return r; @@ -234,10 +234,8 @@ static int i2c_dw_pci_probe(struct pci_dev *pdev, if (controller->setup) { r = controller->setup(pdev, controller); - if (r) { - pci_free_irq_vectors(pdev); + if (r) return r; - } } i2c_dw_adjust_bus_speed(dev); @@ -246,10 +244,8 @@ static int i2c_dw_pci_probe(struct pci_dev *pdev, i2c_dw_acpi_configure(&pdev->dev); r = i2c_dw_validate_speed(dev); - if (r) { - pci_free_irq_vectors(pdev); + if (r) return r; - } i2c_dw_configure(dev); @@ -269,10 +265,8 @@ static int i2c_dw_pci_probe(struct pci_dev *pdev, adap->nr = controller->bus_num; r = i2c_dw_probe(dev); - if (r) { - pci_free_irq_vectors(pdev); + if (r) return r; - } pm_runtime_set_autosuspend_delay(&pdev->dev, 1000); pm_runtime_use_autosuspend(&pdev->dev); @@ -292,7 +286,6 @@ static void i2c_dw_pci_remove(struct pci_dev *pdev) i2c_del_adapter(&dev->adapter); devm_free_irq(&pdev->dev, dev->irq, dev); - pci_free_irq_vectors(pdev); } /* work with hotplug and coldplug */ From patchwork Tue Feb 16 16:02:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dejin Zheng X-Patchwork-Id: 12090211 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5066AC4332E for ; Tue, 16 Feb 2021 16:04:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 398BB614A5 for ; Tue, 16 Feb 2021 16:04:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230216AbhBPQDz (ORCPT ); Tue, 16 Feb 2021 11:03:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43622 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230264AbhBPQDv (ORCPT ); Tue, 16 Feb 2021 11:03:51 -0500 Received: from mail-pj1-x1031.google.com (mail-pj1-x1031.google.com [IPv6:2607:f8b0:4864:20::1031]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D898FC061786; Tue, 16 Feb 2021 08:03:10 -0800 (PST) Received: by mail-pj1-x1031.google.com with SMTP id kr16so1285984pjb.2; Tue, 16 Feb 2021 08:03:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=hHuRwf2TdnMlb69qCWHCGaaZJgBzN1vXiSlYH3WgE1I=; b=RTX2JZ0LfFB+vJQkvu8Ry+s8sAaHG2DRIKvxP+DcYQy+ATKBoJxQ2cqoQ6Vhsv0ZPH Ku/FsOrpdSdhdgbI1/uJp3iBhhLPWHcN1Hl6lHlvexvjWSCw6cFlZf+sAwNSOVX0lZ+/ 1JITHXBf1uZlxLnKX7VweTPjDasm8kNeNlXJwAzpv97izrMxzZjDk9VnpvPBx0SpMCuL mVxCfJy3o3068IlsqR9ts/ify76qxephAt/CX2fmjfafPvL8dWhqO8Lgd92NQojpHeLf iRrzms+LFeqeAiVG6SH2iLLls2vgNY8gLfFHYCd81xz0waQk/0nnCFrYEORogFXVMBGA 9BTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=hHuRwf2TdnMlb69qCWHCGaaZJgBzN1vXiSlYH3WgE1I=; b=j2Cf7Gaf18pYibGP3/cvMZN0qOs56fE9sm0OVQ9feuS5AXwVeoRq+LxMdhHSjRKhNm d3+aBdgRUiocVbJ+lLTpUh9+qPeIn660bJU88v/ZJPi8NGDlGoAK9YpH/N/rIcpxisPu yFc31eUttPbxj2v6KXJb3De811MVMDx8zwwauZUh8HneGPqF4E0Go2+8kBLy415hjtw0 6Da9kUqMsHXJJD5Zx/ZkA+aj7UTgDunPAjld58KvUmQ+0hKAKr+kA16S8GrHKXu37BpA GjwQyST7y5AJdYVPXuXif1i5596m2FkUMDFKDREY64PsEJ35cPvL3E+UeavVmBKmQcRL aZ8g== X-Gm-Message-State: AOAM530WByOBEkPM9gVIHdcOXzEIYK7wpTjFdXz+ka1yIuromnxNQ0zA ccHtjJy55mTr6eKZ7CiImeI= X-Google-Smtp-Source: ABdhPJwYdmqIcde3VGwF41I/uukrGzb1eKNviqwJLoZTUw0NI0c24qLxgqGPQmGPDZ36D50BCBY6nQ== X-Received: by 2002:a17:90a:7e0a:: with SMTP id i10mr4754761pjl.152.1613491390486; Tue, 16 Feb 2021 08:03:10 -0800 (PST) Received: from localhost (185.212.56.4.16clouds.com. [185.212.56.4]) by smtp.gmail.com with ESMTPSA id t21sm23457321pfc.92.2021.02.16.08.03.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Feb 2021 08:03:10 -0800 (PST) From: Dejin Zheng To: corbet@lwn.net, jarkko.nikula@linux.intel.com, andriy.shevchenko@linux.intel.com, mika.westerberg@linux.intel.com, rric@kernel.org, bhelgaas@google.com, wsa@kernel.org, linux-doc@vger.kernel.org, linux-i2c@vger.kernel.org, linux-pci@vger.kernel.org, kw@linux.com Cc: linux-kernel@vger.kernel.org, Dejin Zheng Subject: [PATCH v3 4/4] i2c: thunderx: Use the correct name of device-managed function Date: Wed, 17 Feb 2021 00:02:49 +0800 Message-Id: <20210216160249.749799-5-zhengdejin5@gmail.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20210216160249.749799-1-zhengdejin5@gmail.com> References: <20210216160249.749799-1-zhengdejin5@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Use the new function pcim_alloc_irq_vectors() to allocate IRQ vectors, the pcim_alloc_irq_vectors() function, an explicit device-managed version of pci_alloc_irq_vectors(). If pcim_enable_device() has been called before, then pci_alloc_irq_vectors() is actually a device-managed function. It is used here as a device-managed function, So replace it with pcim_alloc_irq_vectors(). Signed-off-by: Dejin Zheng --- v2 -> v3: - No change. v1 -> v2: - Modify some commit messages. drivers/i2c/busses/i2c-thunderx-pcidrv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/i2c/busses/i2c-thunderx-pcidrv.c b/drivers/i2c/busses/i2c-thunderx-pcidrv.c index 12c90aa0900e..63354e9fb726 100644 --- a/drivers/i2c/busses/i2c-thunderx-pcidrv.c +++ b/drivers/i2c/busses/i2c-thunderx-pcidrv.c @@ -192,7 +192,7 @@ static int thunder_i2c_probe_pci(struct pci_dev *pdev, i2c->hlc_int_enable = thunder_i2c_hlc_int_enable; i2c->hlc_int_disable = thunder_i2c_hlc_int_disable; - ret = pci_alloc_irq_vectors(pdev, 1, 1, PCI_IRQ_MSIX); + ret = pcim_alloc_irq_vectors(pdev, 1, 1, PCI_IRQ_MSIX); if (ret < 0) goto error;