From patchwork Thu Feb 18 15:04:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dejin Zheng X-Patchwork-Id: 385092 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=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 13B48C433DB for ; Thu, 18 Feb 2021 17:11:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BB43A64E3E for ; Thu, 18 Feb 2021 17:11:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233213AbhBRRLS (ORCPT ); Thu, 18 Feb 2021 12:11:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53662 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230234AbhBRPFv (ORCPT ); Thu, 18 Feb 2021 10:05:51 -0500 Received: from mail-pl1-x62a.google.com (mail-pl1-x62a.google.com [IPv6:2607:f8b0:4864:20::62a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4017FC06178B; Thu, 18 Feb 2021 07:05:10 -0800 (PST) Received: by mail-pl1-x62a.google.com with SMTP id d13so1418566plg.0; Thu, 18 Feb 2021 07:05: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=3kxktRBQIqSj+zk0vpHumiALZ+/o4VB4EHXXMPvQP28=; b=VkyxtNlZFEFNJAJ2P7dvFxXF5cdrKagWkdNp00zMAe7xvwcy7QLp/ItC2mDv0lC8OY XH4N9yenVOAbgqili73tXxSHi04SqObxU6qV/OXk6rMr+sduYqqNEzcfL/ZgaL2kdTjg 1sqodPYesCJGitUehcpG3znLgNYrnDzM+uCYSDUW6OM7QTpaX5rtdn38oaENS3ZYmF2J ctdssGafWxHRplxtqzKuiz1VngDDcrQ6w6gzWCzbKIC7km39bJm+Tc85It+mzwwew605 l/ltfNUzdfkDfNuqWKxlEscTVJ7s4em9FHznVqrPxRlG3/QvtQPcJd/Se4YQKqL1WZ6D UvLA== 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=3kxktRBQIqSj+zk0vpHumiALZ+/o4VB4EHXXMPvQP28=; b=DBTvKg25JpdmoBe+249FZgzu6vHJplOWZcl35ycTtZdL3Duv+zBPYEcNEVVLpFO8SJ yA8OCMzkeVBtFj3d1dg6cm8R4A9g7p7musZDXV24lTVNGgme70aazjVVto+R0n6l55+0 TcQofQ3MCFoyOlTQeQ62PvC/fhMGg73Ukyy//9gTL5uwKptOWD2kBisEQ70F9LeYSZCp Lp5b7CkDA3SCX9kkcx3XMRB99sDuKkJfzS0SYkncRKyCtvUYC484tkQmQr/cdU13Usri bY8lB2MrhTF7hIZlP8RdsTU2qm1x2vkowVjV8s0d2fcDEb4JxUvbu/S/N+f2lxSwPAiu FISQ== X-Gm-Message-State: AOAM5303g9VVT3i4Q6MLVQwQ8prIjGmwBflufm5Ugz6Qdni15jAxA2lD oZOHJVr50X3nsXec6OC335I= X-Google-Smtp-Source: ABdhPJz67CEpLNTi6csSIEuiUHR+RSd5h99nFYYbnki5U2w+Redsdux23GwnqeHG2F/meyHYSvMjYA== X-Received: by 2002:a17:90a:1f41:: with SMTP id y1mr4517759pjy.90.1613660709799; Thu, 18 Feb 2021 07:05:09 -0800 (PST) Received: from localhost (185.212.56.4.16clouds.com. [185.212.56.4]) by smtp.gmail.com with ESMTPSA id lx1sm5362175pjb.8.2021.02.18.07.05.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Feb 2021 07:05:09 -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 Cc: linux-kernel@vger.kernel.org, Dejin Zheng Subject: [PATCH v4 1/4] PCI: Introduce pcim_alloc_irq_vectors() Date: Thu, 18 Feb 2021 23:04:55 +0800 Message-Id: <20210218150458.798347-2-zhengdejin5@gmail.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20210218150458.798347-1-zhengdejin5@gmail.com> References: <20210218150458.798347-1-zhengdejin5@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-i2c@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 --- v3 -> v4: - No change 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 Thu Feb 18 15:04:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dejin Zheng X-Patchwork-Id: 384618 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 747CFC433DB for ; Thu, 18 Feb 2021 17:11:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2C28964E3E for ; Thu, 18 Feb 2021 17:11:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233264AbhBRRL0 (ORCPT ); Thu, 18 Feb 2021 12:11:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53678 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230253AbhBRPF4 (ORCPT ); Thu, 18 Feb 2021 10:05:56 -0500 Received: from mail-pl1-x62e.google.com (mail-pl1-x62e.google.com [IPv6:2607:f8b0:4864:20::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BE55EC06178C; Thu, 18 Feb 2021 07:05:14 -0800 (PST) Received: by mail-pl1-x62e.google.com with SMTP id a9so1398069plh.8; Thu, 18 Feb 2021 07:05:14 -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=HfgXzYXBFwpw+FA5Ggd2qrGjrZ5TTWoL87obfP5C5Z4=; b=CLxBnnZ/XGe8XizunrAEYHH/T2/Xxla3oEBSreJJ2McBImlbrrDvpShhSI+cHjC+Ev h/FB9VfT+I2YGR6mimtwVc27IIWRy8OOhz5rwy9iv3YhiYr29TriWVSwCuFNYCSDLPO9 c9fNi/Is3b66Elfj93H6aDmDoKDIo9SU5DVoJszmoLETTSs/lYhQI9OP1mlva46QfUhy 8Fe7rE05S88cu1r/WsjgS5oUP7gNO28nRAgJg3de9GUZtZqbnBpprZ+7oEA23OPxPqcb hBmxJSynmc9ZY/oErjFBTgNIKafbMAcB5zOg4GNrJoo1OoRkeBX091bMZcATPP7HpYxs 5+Ow== 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=HfgXzYXBFwpw+FA5Ggd2qrGjrZ5TTWoL87obfP5C5Z4=; b=YP1nUChvuWDak3DWTAEzrk0qfQwg+Sg3OTgEEyZGIGqUflw3vS4QvjvwcYtcFoKldZ yFQ/EkLywGDnY9XrTTdKYcjW2Pj5eB1k0FDOexjtocHk4IDYZt71zWA9JEOLJo6HfaLf JjlkjbK6WYEK07BbxKWD3n7I/8nIj6WzDYPQMsPjDHyjs0RChCr8ao6LjjDEm3WZsoA7 zNzEQ+Z+y+wLlasGxMnRNIftMXdSMjo//boaL4ZIl6XgoF6UiDYMPHWmGkPJNTVQIBK2 uuxgAUaC5E1eRrpDsKz2D81AZl7kIKdU3H8DRt9XWNhbJ6V0t1j4Sr4uoZ08oKApmT26 0rkg== X-Gm-Message-State: AOAM532oV9apscKgbUxdKjn/tVkTUeM4+cRczN4A9w0K/16jcDgS1VWa KwosfYvjvU805cB1T1h+lD4= X-Google-Smtp-Source: ABdhPJwUypqcCpt7WO55p8G28pXwLg5n3cdnovDqmB9PqASguOiNz44al5oQnLB+ybL2ZWp2b/0qnA== X-Received: by 2002:a17:90b:3689:: with SMTP id mj9mr4394617pjb.99.1613660714315; Thu, 18 Feb 2021 07:05:14 -0800 (PST) Received: from localhost (185.212.56.4.16clouds.com. [185.212.56.4]) by smtp.gmail.com with ESMTPSA id k31sm6026624pgi.5.2021.02.18.07.05.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Feb 2021 07:05:13 -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 Cc: linux-kernel@vger.kernel.org, Dejin Zheng Subject: [PATCH v4 2/4] Documentation: devres: Add pcim_alloc_irq_vectors() Date: Thu, 18 Feb 2021 23:04:56 +0800 Message-Id: <20210218150458.798347-3-zhengdejin5@gmail.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20210218150458.798347-1-zhengdejin5@gmail.com> References: <20210218150458.798347-1-zhengdejin5@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-i2c@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 --- v3 -> v4: - No change 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 Thu Feb 18 15:04:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dejin Zheng X-Patchwork-Id: 384617 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 62C59C433DB for ; Thu, 18 Feb 2021 17:12:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1DFE764E2E for ; Thu, 18 Feb 2021 17:12:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233344AbhBRRLp (ORCPT ); Thu, 18 Feb 2021 12:11:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54068 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230397AbhBRPHo (ORCPT ); Thu, 18 Feb 2021 10:07:44 -0500 Received: from mail-pj1-x1029.google.com (mail-pj1-x1029.google.com [IPv6:2607:f8b0:4864:20::1029]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2926BC061793; Thu, 18 Feb 2021 07:05:19 -0800 (PST) Received: by mail-pj1-x1029.google.com with SMTP id gx20so1644382pjb.1; Thu, 18 Feb 2021 07:05:19 -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=Qt3K9mg5dH0QQuZEd/KaPTOjklJDp5psAssg/8BuCoQ=; b=WT03oCVlXeCKVt9UKMFYjRxffZva2juISnIS6uhe2UoIF77jScIwyqm2ITTc9iujJ5 GZy6vR+60yczwFsFup/MjQCAxJfZfCmlR7CE3OoM/5hZMIU3VN1qUKIS7cH7zwJGzoMj lTL5va5ImLeXyLaLKG0IsoO78kM/JDV6KFJaerwBCRvod80hIEWntI0VrB1lUDY7ujJ6 Dn3HzaN7+k8uuuuQ6zThiHfM8frfKDI5l0Z07cjTDAh1pmDV9eM2tt2EukUM7INtqeZG IkehWD0E9U2N2EJBVsPR2NizbAFkHiK419NdxeXmwLzMVFQ3w32QcoTFGVO66sqYAGMa ExTg== 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=Qt3K9mg5dH0QQuZEd/KaPTOjklJDp5psAssg/8BuCoQ=; b=pRlqobnz7/TWMlPUuG81PjkbWnwbVojSo+JUxUQYtpIiRV8U2XC2ok1Cnqcc7p/imE o520pNwFX71myexTsAPPeijI3mhrcJJAD7RLcnLuIq7drJtxmtpn8snM1rtNPgHlKyhu NURhUSqHGUpDSb7clTu1gQvDTU9w/4VIA6TlUESSgRHgl5ncM/jn+pjWIMfvAsP8NE25 WjVqzAW70jbUHWsjY1Ea+fBhRVkJu08ydcPcHAbGJmEzyblmNslQyyPplzxMN4nZpeOu E9fn6lWv7kI/DSnXLew0rkDxjBqdQOA+gcOeMNyVqgHXDKvR/0pbkhF/H2lA3Sezj7Mm CYqg== X-Gm-Message-State: AOAM530ANQahZED2T5CJa69GsZQO5ELqa2Fn5e+57ySyavSrmswtRUfo OkQgP3/lXWVmsxB3rtgPvAq4+O71R5QalQ== X-Google-Smtp-Source: ABdhPJxZpd590tAK+mrCR9YzjUxRQ+P1CDlfHivgAwxiLSGY6tDc++YdKJruv/cjCf8PYFbXKjaxig== X-Received: by 2002:a17:902:8ec1:b029:dc:8ae1:7a22 with SMTP id x1-20020a1709028ec1b02900dc8ae17a22mr4493022plo.6.1613660718787; Thu, 18 Feb 2021 07:05:18 -0800 (PST) Received: from localhost (185.212.56.4.16clouds.com. [185.212.56.4]) by smtp.gmail.com with ESMTPSA id c12sm5915484pjq.48.2021.02.18.07.05.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Feb 2021 07:05:18 -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 Cc: linux-kernel@vger.kernel.org, Dejin Zheng Subject: [PATCH v4 3/4] i2c: designware: Use the correct name of device-managed function Date: Thu, 18 Feb 2021 23:04:57 +0800 Message-Id: <20210218150458.798347-4-zhengdejin5@gmail.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20210218150458.798347-1-zhengdejin5@gmail.com> References: <20210218150458.798347-1-zhengdejin5@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-i2c@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, Remove the pci_free_irq_vectors() function to simplify the error handling path. the freeing resources will take automatically when device is gone. Signed-off-by: Dejin Zheng Acked-by: Andy Shevchenko --- v3 -> v4: - add some commit comments. 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 Thu Feb 18 15:04:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dejin Zheng X-Patchwork-Id: 385091 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 D199AC433E0 for ; Thu, 18 Feb 2021 17:12:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 79B6064E3E for ; Thu, 18 Feb 2021 17:12:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233285AbhBRRLh (ORCPT ); Thu, 18 Feb 2021 12:11:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54070 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230398AbhBRPHo (ORCPT ); Thu, 18 Feb 2021 10:07:44 -0500 Received: from mail-pl1-x62c.google.com (mail-pl1-x62c.google.com [IPv6:2607:f8b0:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5246BC061794; Thu, 18 Feb 2021 07:05:23 -0800 (PST) Received: by mail-pl1-x62c.google.com with SMTP id f8so1404906plg.5; Thu, 18 Feb 2021 07:05:23 -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=gDQw0/8Ah6DAAnuC4tfOgLweLZLFJgkJo+lUVRcWr0E=; b=Zv8n1hO18ESYeeNpkWMIeO5GfC37Hd0xxnknbLELMqPld1g4ShosdhA9NaHeVRBo/W IGeBD0Pw9B2IrrPmx52WDU6ZRVk72wF1Mw3SCKcyfMxFXO0JR4IHhc/w9zNdgBw1c+D4 nzkCkr7kE/y9NLUQwoS9sw7ILMwIx3FvaxWYx+2iwSs3Au2tMFY2PeDV+1XMtQZCFru7 t0HgmyWttTPdo5PWNWV9RGHsLf/jRGQ01p4qs0cj2CBHJm02epfXxRy2PA4jZwE6qW01 L56YkK7X7e8UUNG/bxvmU3L5IuLEeuZgilPaSnWm5HvWAVeoOicFjy2jKQ3biVgfPAh3 L0Yg== 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=gDQw0/8Ah6DAAnuC4tfOgLweLZLFJgkJo+lUVRcWr0E=; b=luCR9hW837uwSppcTbPd8zE8WSkNR/ifPzdUoJ9ML2Nw2o8zDrKmwpGYB8gIIJGEEX 3wWlCQ/AKj1qtMvY9WLie7PueAqOpz8je1WAo1guKhaSPAZ1bI5cVpUml7PjGImNJ5J5 4PJUSxsO1PVqO/5H94Ndtiy2gADNXNfr8FeMabY/bSldeRWBGTr2JDCW9GODeesMNO+/ kFfj4wNmOQB7+xMuW8bTKZlb5LWA/7AqaPkRcZrZ1wQEV2w5GL6Jyk8cZt2NxbnmyKi3 ZrTDUUQyJX+QjoDMn2Xh8FUUcoPyKGgkckwcedhqN9TKvTBDrVKJazmbD9GanrQ/Zvvv sLiA== X-Gm-Message-State: AOAM530i/d0PzCF8wZKaZiaeoxkGeOB63iad0VT5MknxTNud1kOvlH7Q kHNDcQHW9v7PHMJvZbQ98IVcaRX/qjsMUw== X-Google-Smtp-Source: ABdhPJwUO3eNJCDhvCLC2wCC0wRPdXTo3dJMQFKQLX7vnOmE/k5gLgpZ+kSWFP3L5VsY02JJyi+syA== X-Received: by 2002:a17:90a:aa0d:: with SMTP id k13mr4609841pjq.210.1613660722893; Thu, 18 Feb 2021 07:05:22 -0800 (PST) Received: from localhost (185.212.56.4.16clouds.com. [185.212.56.4]) by smtp.gmail.com with ESMTPSA id i1sm6638269pfq.158.2021.02.18.07.05.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Feb 2021 07:05:22 -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 Cc: linux-kernel@vger.kernel.org, Dejin Zheng Subject: [PATCH v4 4/4] i2c: thunderx: Use the correct name of device-managed function Date: Thu, 18 Feb 2021 23:04:58 +0800 Message-Id: <20210218150458.798347-5-zhengdejin5@gmail.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20210218150458.798347-1-zhengdejin5@gmail.com> References: <20210218150458.798347-1-zhengdejin5@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-i2c@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 --- v3 -> v4: - No change. 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;