Received: by 2002:a05:7412:8d11:b0:fa:4934:9f with SMTP id bj17csp576024rdb; Mon, 15 Jan 2024 06:50:17 -0800 (PST) X-Google-Smtp-Source: AGHT+IFCGcUROPj+lquToXPkMxTrC0HRyozZUSBUDmIns4Zp+6HFMFhxEUTz5wRfC09qZgj9aoFz X-Received: by 2002:ad4:5bea:0:b0:681:565e:366 with SMTP id k10-20020ad45bea000000b00681565e0366mr4784301qvc.30.1705330217449; Mon, 15 Jan 2024 06:50:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705330217; cv=none; d=google.com; s=arc-20160816; b=lDJv/hiawfac4TLYpIiKbkOP+958rbAZQjGTo+wUvcvE5Vy11SbGmWbV79+K+Bfzja 0VhA3SId8QCyvb+Dfm5Gb6qm9Z9fwwBYkWLlPD0yX9Fq8cVa5q8D0RCmrE/SGNAwtrlb ovds/8P0c5lXHn0bLiWs8myO7WPJhYt4uH3Q0wN8ANMeWPSaOzmmWjtri+C6Ap0/eLCK L2AoqJx2HKDVtxgMvYhFf2GWIeFZ4hWLrPoXJ12+ac+U0uT/66AQKx0Gj8oG+bdZMiE1 jf2pFlWMrQ5lZWI2G5aIEt2UXXwUWP84l61KxVFgEliNuHWFIU5V4WpsPhvsW3a0IRyv FQng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=6EAnPeJipP0+07a3Rzv2/tb0sjf4e9bqcclnBtzQ1Hw=; fh=AY1J9PDScN0xrIvhrMJy8TMRSbPeq4owI1m0lsalYQU=; b=UAfs6qMiZdtwwtdxPAM/tO4ODTE9x11LOjSYeiWd9B8stKiMmHijHG/5bAuruonMO/ aSIaHMjhJsHywZXIBMDLJ52OeSnR3QtD9KZkW0DUNKP0prOgjs5zc2YXpsC66i4H39BF eSU36DIZcmHkZkMX7AAtF25Se6FqGaeiI3AVMrDiU5Yu5gCpi/13zjiCQtbH9YxiTQOm PQ6ftJLZvwY+1zEzdPfzpq4GwevetJxa/AiJpIE3Lme8kZ/qjTUpx9exn4bwD2Kx+7xf IQG5oNW5dA40UtEYHVn0p4O0df5HVVzdM15u7t9Q5pCqbD0l8ftXbSGOHCWDECSjLoay EOtw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ZKQ3noT3; spf=pass (google.com: domain of linux-kernel+bounces-26133-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-26133-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id c2-20020a0ce142000000b006812aec8373si956015qvl.430.2024.01.15.06.50.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jan 2024 06:50:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-26133-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ZKQ3noT3; spf=pass (google.com: domain of linux-kernel+bounces-26133-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-26133-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 7FE001C21C94 for ; Mon, 15 Jan 2024 14:50:13 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EDF221864E; Mon, 15 Jan 2024 14:47:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="ZKQ3noT3" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8443718054 for ; Mon, 15 Jan 2024 14:47:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1705330055; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6EAnPeJipP0+07a3Rzv2/tb0sjf4e9bqcclnBtzQ1Hw=; b=ZKQ3noT3lMoVquehcRddhaUCwGV6ujheO9KpWFHab+hmC6hI3flsI6pCuKys4shfIyBBqN baBenEE2mvEKS4NbrYPik3cvmQ2Kf8oIQENcet3PGysWAZOK1jdGPA9Uw6se1EqK1wG2w0 AeJ9ZD4eVynshdmzT7EPi84UsGog8HA= Received: from mail-yw1-f199.google.com (mail-yw1-f199.google.com [209.85.128.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-119-1vqw7SufOvyTCfaorb1p3w-1; Mon, 15 Jan 2024 09:47:34 -0500 X-MC-Unique: 1vqw7SufOvyTCfaorb1p3w-1 Received: by mail-yw1-f199.google.com with SMTP id 00721157ae682-5fbfa11838cso5004567b3.1 for ; Mon, 15 Jan 2024 06:47:34 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705330054; x=1705934854; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=6EAnPeJipP0+07a3Rzv2/tb0sjf4e9bqcclnBtzQ1Hw=; b=gWB8l5xwervuu3qJG/lYwXiZSbAK0w3VnHjYpRKheNR8yPQ0/QmgpdJ44+UyYRKb+f Ef5e+LC+ROr4Im37WvNkxDWbkLQ3Jd2GZrEQrfzKRV+jeaWrE5Q8V9LLbXz/yUHeklK+ Y0hbSm408T14QBqHNJ7gImhnO7twQN6GoOpuYUzqu708mD3IRGmpnQPzg9umBBuZu9Qr A2uj66zSLTrkVteSKcVm82vS6ryNSNFVMyrWiCRNl5zzKmNhTdP42DZE9xgN1wJRaHyt wE3VSZOP8yPDzOEdZYVKro2Dp8eFMtdl7YVL/coUW5If+1TKkhm3mHEAGcj80oH+D7O0 8MHw== X-Gm-Message-State: AOJu0YzWsyluPl5TDhDcaVWiAVCJfHJBoM1O2IvCb1zAhDuWj7WlPxvC 8W2NNABqGHM6BxS+vQnazWiqcx385YghNAYu29QO9k2ygF+5mxoN2G8XTzd1+N6ZjEn9dkfd2/3 OrvJ4n3aTTlnlEwfEwDVs2t1+VxquQcKC X-Received: by 2002:a81:9201:0:b0:5af:778e:d53b with SMTP id j1-20020a819201000000b005af778ed53bmr4653018ywg.0.1705330053950; Mon, 15 Jan 2024 06:47:33 -0800 (PST) X-Received: by 2002:a81:9201:0:b0:5af:778e:d53b with SMTP id j1-20020a819201000000b005af778ed53bmr4653002ywg.0.1705330053647; Mon, 15 Jan 2024 06:47:33 -0800 (PST) Received: from pstanner-thinkpadt14sgen1.muc.redhat.com (nat-pool-muc-t.redhat.com. [149.14.88.26]) by smtp.gmail.com with ESMTPSA id ne13-20020a056214424d00b006815cf9a644sm1020720qvb.55.2024.01.15.06.47.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jan 2024 06:47:33 -0800 (PST) From: Philipp Stanner To: Jonathan Corbet , Hans de Goede , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Bjorn Helgaas , Philipp Stanner , Sam Ravnborg , dakr@redhat.com Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-pci@vger.kernel.org Subject: [PATCH 09/10] pci: devres: remove legacy pcim_release() Date: Mon, 15 Jan 2024 15:46:20 +0100 Message-ID: <20240115144655.32046-11-pstanner@redhat.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240115144655.32046-2-pstanner@redhat.com> References: <20240115144655.32046-2-pstanner@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Thanks to preceding cleanup steps, pcim_release() is now not needed anymore and can be replaced by pcim_disable_device(), which is the exact counterpart to pcim_enable_device(). This permits removing further parts of the old devres API. Replace pcim_release() with pcim_disable_device(). Remove the now surplus get_dr() function. Signed-off-by: Philipp Stanner --- drivers/pci/devres.c | 38 ++++++++------------------------------ 1 file changed, 8 insertions(+), 30 deletions(-) diff --git a/drivers/pci/devres.c b/drivers/pci/devres.c index 7c4edcaeb8fe..87bc62be21eb 100644 --- a/drivers/pci/devres.c +++ b/drivers/pci/devres.c @@ -464,48 +464,26 @@ int pcim_intx(struct pci_dev *pdev, int enable) } EXPORT_SYMBOL_GPL(pcim_intx); -static void pcim_release(struct device *gendev, void *res) +static void pcim_disable_device(void *pdev_raw) { - struct pci_dev *dev = to_pci_dev(gendev); - - if (!dev->pinned) - pci_disable_device(dev); -} - -static struct pci_devres *get_pci_dr(struct pci_dev *pdev) -{ - struct pci_devres *dr, *new_dr; - - dr = devres_find(&pdev->dev, pcim_release, NULL, NULL); - if (dr) - return dr; + struct pci_dev *pdev = pdev_raw; - new_dr = devres_alloc(pcim_release, sizeof(*new_dr), GFP_KERNEL); - if (!new_dr) - return NULL; - return devres_get(&pdev->dev, new_dr, NULL, NULL); + if (!pdev->pinned) + pci_disable_device(pdev); } /** * pcim_enable_device - Managed pci_enable_device() * @pdev: PCI device to be initialized * - * Managed pci_enable_device(). + * Managed pci_enable_device(). Device will automatically be disabled on + * driver detach. */ int pcim_enable_device(struct pci_dev *pdev) { - struct pci_devres *dr; - int rc; - - dr = get_pci_dr(pdev); - if (unlikely(!dr)) - return -ENOMEM; - - rc = pci_enable_device(pdev); - if (!rc) - pdev->is_managed = 1; + devm_add_action(&pdev->dev, pcim_disable_device, pdev); - return rc; + return pci_enable_device(pdev); } EXPORT_SYMBOL(pcim_enable_device); -- 2.43.0