On Mon, Jun 29, 2020 at 08:45:25PM +0300, Paraschiv, Andra-Irina wrote:
What do you mean by "codebase"? You control this driver, just do all of
On 29/06/2020 19:20, Greg KH wrote:
On Mon, Jun 22, 2020 at 11:03:18PM +0300, Andra Paraschiv wrote:This check is mainly here in the case any codebase is added before the pci
+static int __init ne_init(void)Ick, that's a _very_ old-school way of binding to a pci device. Please
+{
+ struct pci_dev *pdev = pci_get_device(PCI_VENDOR_ID_AMAZON,
+ PCI_DEVICE_ID_NE, NULL);
+ int rc = -EINVAL;
+
+ if (!pdev)
+ return -ENODEV;
just be a "real" pci driver and your probe function will be called if
your hardware is present (or when it shows up.) To do it this way
prevents your driver from being auto-loaded for when your hardware is
seen in the system, as well as lots of other things.
driver register call below.
the logic in the probe() function, no need to do this in the module init
call.
And if we log any error with dev_err() instead of pr_err() before the driverDon't do that.
register.
That check was only for logging purposes, if done with dev_err(). I removedAgain, don't do it :)
the check in v5.
Again, just don't do it and then you don't have to worry about any ofYes, the pci get device call needs its pair - pci_dev_put(). I added it here+Nice, you did it right here, but why the above crazy test?
+ if (!zalloc_cpumask_var(&ne_cpu_pool.avail, GFP_KERNEL))
+ return -ENOMEM;
+
+ mutex_init(&ne_cpu_pool.mutex);
+
+ rc = pci_register_driver(&ne_pci_driver);
+ if (rc < 0) {You leaked a reference on that pci device, didn't you? Not good :(
+ dev_err(&pdev->dev,
+ "Error in pci register driver [rc=%d]\n", rc);
+
+ goto free_cpumask;
+ }
+
+ return 0;
and for the other occurrences where it was missing.
this.