Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp281074pxb; Wed, 11 Nov 2020 03:37:57 -0800 (PST) X-Google-Smtp-Source: ABdhPJzm0RgVKcJyG3VBLmDI5cQkryy6B/maDYesV5/l66wgVuHaqGa8rOL9+alocqj88IIgImV6 X-Received: by 2002:a17:906:7f10:: with SMTP id d16mr24490678ejr.104.1605094677202; Wed, 11 Nov 2020 03:37:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605094677; cv=none; d=google.com; s=arc-20160816; b=B/LwHZfbPqE1abvxhF05LFx3cZbCkmwIYpBNA80/RzAdAmrJH2l6NzZo/2HfYf6JUV ZeIsLTNOZwZJK3Tz3RMJ53IKo5LiQYLgeb0WhQuN7bzVOEx8NL34Hkydn1RXuoc8/MFx uxHF0UiLJRqEGP2baMdrIc4gTXHvbxV7iR5c0Z250Sovx7quda0J+9xUEu5fei5abL3O eWzAT1Dp25Of4GXmJiR+C728kZd2dW+9FSD1LyCCrp4mGYK8jd9MNjdwLEDKNoowmOWV fH4GforHSvRykrtJwRrjJbozQ/UZzhAw+nU4KJZZS2ltA9jjFvykBocHai+8ZEw0m3Ci cThw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from; bh=DfrF4VrGjumZrObBXJkNHRaHfOYCjfviv7S893wmxmY=; b=qJICJ8t8XQqHFQFHDiPv1zwbeqPuPxcnomG89oHsmVfJXNkFCgP6jIN443swhoC9Xz 0ntJLMAOlnXM8qrSYcaO5ndbK1NEhC5o71eTMwyEG5f5Nq/MmH1VnHoboKEmOhWSdWMK Z57mw+GqFFK8Tg8M86H3WK6gzYUyKboNsTF2+5yUIGbmaEwcsDdG+ebeS2YgBht+4Q7Y G1ToMVle7c9h9hrh7kMAkSP5YDPBBMDCTh1IWxGvVhAf9GwrYijr5jnigkHwWrmHDWES J6nAuXMLpvxmgJlQXpgGhOdn0hDMyQ1M351qwXD1raHuio9le00sR3HPzuXkUVgRh2pl /vXw== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=analog.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gn19si1100705ejc.336.2020.11.11.03.37.32; Wed, 11 Nov 2020 03:37:57 -0800 (PST) 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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=analog.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726240AbgKKLdl (ORCPT + 99 others); Wed, 11 Nov 2020 06:33:41 -0500 Received: from mx0a-00128a01.pphosted.com ([148.163.135.77]:56728 "EHLO mx0a-00128a01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725909AbgKKLdh (ORCPT ); Wed, 11 Nov 2020 06:33:37 -0500 Received: from pps.filterd (m0167089.ppops.net [127.0.0.1]) by mx0a-00128a01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 0ABBVeHU019773; Wed, 11 Nov 2020 06:33:36 -0500 Received: from nwd2mta4.analog.com ([137.71.173.58]) by mx0a-00128a01.pphosted.com with ESMTP id 34nsc94xmj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 11 Nov 2020 06:33:36 -0500 Received: from ASHBMBX8.ad.analog.com (ASHBMBX8.ad.analog.com [10.64.17.5]) by nwd2mta4.analog.com (8.14.7/8.14.7) with ESMTP id 0ABBXZoC043115 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=FAIL); Wed, 11 Nov 2020 06:33:35 -0500 Received: from ASHBMBX9.ad.analog.com (10.64.17.10) by ASHBMBX8.ad.analog.com (10.64.17.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1779.2; Wed, 11 Nov 2020 06:33:34 -0500 Received: from zeus.spd.analog.com (10.66.68.11) by ASHBMBX9.ad.analog.com (10.64.17.10) with Microsoft SMTP Server id 15.1.1779.2 via Frontend Transport; Wed, 11 Nov 2020 06:33:34 -0500 Received: from localhost.localdomain ([10.48.65.12]) by zeus.spd.analog.com (8.15.1/8.15.1) with ESMTP id 0ABBXWKa031837; Wed, 11 Nov 2020 06:33:32 -0500 From: Alexandru Ardelean To: CC: , Alexandru Ardelean Subject: [PATCH] uio/uio_pci_generic: use device-managed function equivalents Date: Wed, 11 Nov 2020 13:38:28 +0200 Message-ID: <20201111113828.64992-1-alexandru.ardelean@analog.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Content-Type: text/plain X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.312,18.0.737 definitions=2020-11-11_02:2020-11-10,2020-11-11 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=1 spamscore=0 priorityscore=1501 bulkscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 phishscore=0 mlxlogscore=751 malwarescore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2011110066 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This driver can be easily converted to use the device-managed allocator function and the PCI managed enable function. With these conversions the probe error paths are no longer needed and neither is the remove function. Signed-off-by: Alexandru Ardelean --- drivers/uio/uio_pci_generic.c | 37 +++++++++-------------------------- 1 file changed, 9 insertions(+), 28 deletions(-) diff --git a/drivers/uio/uio_pci_generic.c b/drivers/uio/uio_pci_generic.c index dde5cbb27178..1c6c09e1280d 100644 --- a/drivers/uio/uio_pci_generic.c +++ b/drivers/uio/uio_pci_generic.c @@ -74,23 +74,19 @@ static int probe(struct pci_dev *pdev, struct uio_pci_generic_dev *gdev; int err; - err = pci_enable_device(pdev); + err = pcim_enable_device(pdev); if (err) { dev_err(&pdev->dev, "%s: pci_enable_device failed: %d\n", __func__, err); return err; } - if (pdev->irq && !pci_intx_mask_supported(pdev)) { - err = -ENODEV; - goto err_verify; - } + if (pdev->irq && !pci_intx_mask_supported(pdev)) + return -ENOMEM; - gdev = kzalloc(sizeof(struct uio_pci_generic_dev), GFP_KERNEL); - if (!gdev) { - err = -ENOMEM; - goto err_alloc; - } + gdev = devm_kzalloc(&pdev->dev, sizeof(struct uio_pci_generic_dev), GFP_KERNEL); + if (!gdev) + return -ENOMEM; gdev->info.name = "uio_pci_generic"; gdev->info.version = DRIVER_VERSION; @@ -105,34 +101,19 @@ static int probe(struct pci_dev *pdev, "no support for interrupts?\n"); } - err = uio_register_device(&pdev->dev, &gdev->info); + err = devm_uio_register_device(&pdev->dev, &gdev->info); if (err) - goto err_register; + return err; + pci_set_drvdata(pdev, gdev); return 0; -err_register: - kfree(gdev); -err_alloc: -err_verify: - pci_disable_device(pdev); - return err; -} - -static void remove(struct pci_dev *pdev) -{ - struct uio_pci_generic_dev *gdev = pci_get_drvdata(pdev); - - uio_unregister_device(&gdev->info); - pci_disable_device(pdev); - kfree(gdev); } static struct pci_driver uio_pci_driver = { .name = "uio_pci_generic", .id_table = NULL, /* only dynamic id's */ .probe = probe, - .remove = remove, }; module_pci_driver(uio_pci_driver); -- 2.17.1