Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp102280imu; Tue, 8 Jan 2019 15:30:55 -0800 (PST) X-Google-Smtp-Source: ALg8bN7Rxg6nHzLD8yTIUhj4IoXGzYGhv3fYQZi++6u5L0pjADREdsf8Clse5Hye5d1saZYgNQIy X-Received: by 2002:a17:902:720c:: with SMTP id ba12mr3761574plb.79.1546990255885; Tue, 08 Jan 2019 15:30:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546990255; cv=none; d=google.com; s=arc-20160816; b=t4CwMruSLWDY3QiYDJnCGMlydwrr79IX4WluAAZNViQUBlv5hfarw0DiUouvaebXd3 GsTUIF1VN4qEuNJ39Uhr3xqjc4LoEhjHE2uJQGtuEyXG3MjUL+rDjVKsC5kEtQH9C7m2 phcUPH00Iei/Xn0MtA+aj4yIgtylaRhuNzMD3hYLc8zOkubA0fblZELkqJySowUmFA1P oXOgde5JwbOlGJZQfYgNXjBKueArzFD3DX1F8fdbQzVKrknePkbiCY0MHdEw6AeW21e0 MBN4u/25GbkPoFk7/HWU/nH8gWw2tEUnBB+LDadVFO9yyVWobGUj6VFJxOxHgG3Lj2vF E6cA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=L+hDZmqIwFrLHrxubY4hQtUGwP6knaPONK1VkY9V3GQ=; b=rnt7SrNdzncjEDBIxR8a7ln+GWM4bhvghGHzWaTI76/1m7hdG0Z/VFcPJ2N4YdDg2w aNjz/TN4Sz6Ehu8NBq4YoVpXJywUa0QSBsVqLM9zEqV+1mReDBG+X8f7ZP5HZuBhM/B9 sYpir8q1mNULXvRnPESWO4T/WwZOBYKNuU0wlf3Yonn3nb4iITxcnlStv/Uc3khMAdSP oraBLm89s4r+XckbNSEBsGP0iDb1t3nZFo8sNeBe+Y04ycYKr942fWQ1PFJ6hjI6awmk NknJp58xQJ7xrIkhBwxJ8NRjlWKE+PEfecZhtKcCuooJYVQNUagT/F6eUrEYAYC3I2Yv Jzjw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=bn6SpQuL; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r7si51826713pfb.237.2019.01.08.15.30.40; Tue, 08 Jan 2019 15:30:55 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=bn6SpQuL; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733036AbfAHUI0 (ORCPT + 99 others); Tue, 8 Jan 2019 15:08:26 -0500 Received: from mail.kernel.org ([198.145.29.99]:33656 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729669AbfAHT12 (ORCPT ); Tue, 8 Jan 2019 14:27:28 -0500 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 0C18A2070B; Tue, 8 Jan 2019 19:27:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1546975646; bh=nNUQS+Zyd1GTaVeaV69DmcD+c03QvLiOHbuNMj3FFkk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bn6SpQuLAbwtMQUcd/Cv2uIQ+zdJoal2+m0J5V/IhSQxjg3NgCwauxB9znN1KwzMU 793umgAA0k1+RDAXyxA265ztMRHt0Uh1e6lilmO+IzApnIGr+F8tUB4AQvXmDayqXo e/c3swKCN7zkKzMnzfK20j/N9t0V5ZcPYhQShDng= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Anatolij Gustschin , Greg Kroah-Hartman , Sasha Levin , linux-fpga@vger.kernel.org Subject: [PATCH AUTOSEL 4.20 031/117] fpga: altera-cvp: fix probing for multiple FPGAs on the bus Date: Tue, 8 Jan 2019 14:24:59 -0500 Message-Id: <20190108192628.121270-31-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190108192628.121270-1-sashal@kernel.org> References: <20190108192628.121270-1-sashal@kernel.org> MIME-Version: 1.0 X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Anatolij Gustschin [ Upstream commit 30522a951f9d02f261d0697c35cb42205b1fae17 ] Currently registering CvP managers works only for first probed CvP device, for all other devices it is refused due to duplicated chkcfg sysfs entry: fpga_manager fpga3: Altera CvP FPGA Manager @0000:0c:00.0 registered sysfs: cannot create duplicate filename '/bus/pci/drivers/altera-cvp/chkcfg' CPU: 0 PID: 3808 Comm: bash Tainted: G O 4.19.0-custom+ #5 Call Trace: dump_stack+0x46/0x5b sysfs_warn_dup+0x53/0x60 sysfs_add_file_mode_ns+0x16d/0x180 sysfs_create_file_ns+0x51/0x60 altera_cvp_probe+0x16f/0x2a0 [altera_cvp] local_pci_probe+0x3f/0xa0 ? pci_match_device+0xb1/0xf0 pci_device_probe+0x116/0x170 really_probe+0x21b/0x2c0 driver_probe_device+0x4b/0xe0 bind_store+0xcb/0x130 kernfs_fop_write+0xfd/0x180 __vfs_write+0x21/0x150 ? selinux_file_permission+0xdc/0x130 vfs_write+0xa8/0x1a0 ? find_vma+0xd/0x60 ksys_write+0x3d/0x90 do_syscall_64+0x44/0xf0 entry_SYSCALL_64_after_hwframe+0x44/0xa9 ... altera-cvp 0000:0c:00.0: Can't create sysfs chkcfg file fpga_manager fpga3: fpga_mgr_unregister Altera CvP FPGA Manager @0000:0c:00.0 Move chkcfg creation to module init as suggested by Alan. Signed-off-by: Anatolij Gustschin Acked-by: Alan Tull Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/fpga/altera-cvp.c | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/drivers/fpga/altera-cvp.c b/drivers/fpga/altera-cvp.c index 610a1558e0ed..d9fa7d4bf11f 100644 --- a/drivers/fpga/altera-cvp.c +++ b/drivers/fpga/altera-cvp.c @@ -466,14 +466,6 @@ static int altera_cvp_probe(struct pci_dev *pdev, if (ret) goto err_unmap; - ret = driver_create_file(&altera_cvp_driver.driver, - &driver_attr_chkcfg); - if (ret) { - dev_err(&pdev->dev, "Can't create sysfs chkcfg file\n"); - fpga_mgr_unregister(mgr); - goto err_unmap; - } - return 0; err_unmap: @@ -491,7 +483,6 @@ static void altera_cvp_remove(struct pci_dev *pdev) struct altera_cvp_conf *conf = mgr->priv; u16 cmd; - driver_remove_file(&altera_cvp_driver.driver, &driver_attr_chkcfg); fpga_mgr_unregister(mgr); pci_iounmap(pdev, conf->map); pci_release_region(pdev, CVP_BAR); @@ -500,7 +491,30 @@ static void altera_cvp_remove(struct pci_dev *pdev) pci_write_config_word(pdev, PCI_COMMAND, cmd); } -module_pci_driver(altera_cvp_driver); +static int __init altera_cvp_init(void) +{ + int ret; + + ret = pci_register_driver(&altera_cvp_driver); + if (ret) + return ret; + + ret = driver_create_file(&altera_cvp_driver.driver, + &driver_attr_chkcfg); + if (ret) + pr_warn("Can't create sysfs chkcfg file\n"); + + return 0; +} + +static void __exit altera_cvp_exit(void) +{ + driver_remove_file(&altera_cvp_driver.driver, &driver_attr_chkcfg); + pci_unregister_driver(&altera_cvp_driver); +} + +module_init(altera_cvp_init); +module_exit(altera_cvp_exit); MODULE_LICENSE("GPL v2"); MODULE_AUTHOR("Anatolij Gustschin "); -- 2.19.1