Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2381172pxj; Sun, 6 Jun 2021 00:08:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxNnaxW+nft1xCiwhGA9M2k9WJAKlF89UxmpGhUQeyAv8tjjLa0Dl6J+o9Iw4MEbwsM9Qi7 X-Received: by 2002:aa7:c4d0:: with SMTP id p16mr14367156edr.150.1622963300363; Sun, 06 Jun 2021 00:08:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622963300; cv=none; d=google.com; s=arc-20160816; b=ePYKaJ4hSm5tuBdDvUIQV6EW5o7aMBGPb9YedQEho3EtjK0+Fjnlq4N2qEq1G5rud3 2/k/M16Ehciy3WIftRnzSrLsB4KRmqWpFGbq8rN9a6C4F4RfFZMdPk6hQmK2KvS6X09T AN+vcAD2fJmCS+S3C1Ajmm7K6hGHIu//0sqVxohCyXibAfD6uWJ5BtC0J+t1QaTFq22/ NjBJH3Cu60gTr35wj+UrUXh2dXV7WVPaMe9vR+Mz5ex3+01FkVruJ9vibjGHMi4xKak+ StvR6/THW0byfsc9Ge1GTdHWCTwvjjCq4pA20K3bfzv+BiB8yVqCe6hl70kLbczxFl+d sK4Q== 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=Wu9gAwlAOwgKiPmTDPbi3wWguWilh1MHvLSLhPDONu4=; b=UrV7pxsMHT1q72/4bvwsmMU+iUBZ23RyVe+B8UXtL0QSGt3bSvD0phGNoN58Dykbm4 VVQaL/hZcN1JMDjmwUZaFPS110yIGvCws7T/FbY3PlA+R8+7BwWOx4oJEMBT039j27Cy ayV1u/oNSEdi6nL02LBRr6vPhAN3GC/rYayOnDph0jtpjg6Hw6hat8sHUBnlicP04rkU aYS3aVLAIzocpKTkQ4RCeK1HjGShKqREmwfXkLIjuNsHpzjvWUXaQ8TLOkP74svsIPiK bht42e6lILiyaqtl7fg4Jo30Hm13K/RdlSaXEcSCHCbqg5uplSpaLF/B7GOInXrlDD4w 3B2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Oef098bU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dn21si2881409edb.483.2021.06.06.00.07.57; Sun, 06 Jun 2021 00:08:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Oef098bU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230178AbhFFHHU (ORCPT + 99 others); Sun, 6 Jun 2021 03:07:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39406 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229478AbhFFHHT (ORCPT ); Sun, 6 Jun 2021 03:07:19 -0400 Received: from mail-pg1-x536.google.com (mail-pg1-x536.google.com [IPv6:2607:f8b0:4864:20::536]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 34A13C061766; Sun, 6 Jun 2021 00:05:30 -0700 (PDT) Received: by mail-pg1-x536.google.com with SMTP id n12so11321785pgs.13; Sun, 06 Jun 2021 00:05:30 -0700 (PDT) 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=Wu9gAwlAOwgKiPmTDPbi3wWguWilh1MHvLSLhPDONu4=; b=Oef098bUXUmCFjfJdLdw3CRK0xzTkHa7Xwq8DgY7PtmZYyaDguYw22UNe/f7dJmmVd XtF/lMEmL1M3tB+XFuctn/HFVfirB5JS94/45WzcvUrouktg6lGp8yz0ryeKs/z50cwY W6r5MHozgBDCYYzCDb55tQk6UIuqU5imqjA21yCSVwEYydlQFXdtYGC4GULATkFloCxo kgx8Atfzl0GPHAWcPOoeEJoPU+6j3XWqWx7eIHid4nAgyw6/Tb3UWoz4/k0QbBVCEbq2 fcSZL053MlwOO7L+EFqNbfOfAyja7WfhAjrc3j19m59sBhG+C1Z8ofHIT8S/ijDY8131 hV4g== 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=Wu9gAwlAOwgKiPmTDPbi3wWguWilh1MHvLSLhPDONu4=; b=VtN9yi7HBZqlKBuWlekcYc07FTZAH6cNhB0tX4l7dhdLAzNcmiD8CXT8VZYlmB62h4 m04BWZbtokwRP/ztEfak+VtmL5DS1RdxOyKprEM9C6LCqD0w/ky4s2T9XIzjxRcrHyiP nYMKxxHGOe8SeeKtWUZ+Yk/4QxMUBPMJVP5kxDHCxgasPntAqpToblK6xXng74a9vrVP ZMwIYx/I1BqoipH08VOyWuc1tS8RR9ravCtfG5mG8v9bqonK/uwb3zIISAZRZiOZ+rNB BwN/mb7TL2F6kBLTqmfXLgdENgRiTPAWAYMLmsPbWkxs3d3n5hSkqhJLcy9Qp1GhxmdA EhMQ== X-Gm-Message-State: AOAM532SEJLi3eWLcQseqitl8ZGkNobIhDi6luDJAJVhDxFAIb1Vknec Z1JyOO8uSZTLFPH9znIV4zw= X-Received: by 2002:a62:5288:0:b029:2e3:fd7d:267a with SMTP id g130-20020a6252880000b02902e3fd7d267amr12260409pfb.21.1622963128174; Sun, 06 Jun 2021 00:05:28 -0700 (PDT) Received: from localhost (185.212.56.112.16clouds.com. [185.212.56.112]) by smtp.gmail.com with ESMTPSA id s13sm207808pgi.36.2021.06.06.00.05.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 06 Jun 2021 00:05:27 -0700 (PDT) From: Dejin Zheng To: helgaas@kernel.org, corbet@lwn.net, jarkko.nikula@linux.intel.com, andriy.shevchenko@linux.intel.com, mika.westerberg@linux.intel.com, rric@kernel.org, bhelgaas@google.com, 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 v6 3/4] i2c: designware: Use pcim_alloc_irq_vectors() to allocate IRQ vectors Date: Sun, 6 Jun 2021 15:05:10 +0800 Message-Id: <20210606070511.778487-4-zhengdejin5@gmail.com> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210606070511.778487-1-zhengdejin5@gmail.com> References: <20210606070511.778487-1-zhengdejin5@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Reviewed-by: Robert Richter Acked-by: Andy Shevchenko Acked-by: Jarkko Nikula Signed-off-by: Dejin Zheng --- v5 -> v6: - rebase to 5.13-rc4 v4 -> v5: - Modify the subject name. 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 0f409a4c2da0..2b1ef0934445 100644 --- a/drivers/i2c/busses/i2c-designware-pcidrv.c +++ b/drivers/i2c/busses/i2c-designware-pcidrv.c @@ -268,7 +268,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; @@ -283,10 +283,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); @@ -295,10 +293,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); @@ -318,10 +314,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; - } if ((dev->flags & MODEL_MASK) == MODEL_AMD_NAVI_GPU) { r = navi_amd_register_client(dev); @@ -349,7 +343,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 */ -- 2.30.1