On Wed, Aug 11, 2021 at 10:06:33AM +0200, Uwe Kleine-K??nig wrote:
static inline const char *eeh_driver_name(struct pci_dev *pdev)
{
- return (pdev && pdev->driver) ? pdev->driver->name : "<null>";
+ const char *drvstr = pdev ? dev_driver_string(&pdev->dev) : "";
+
+ if (*drvstr == '\0')
+ return "<null>";
+
+ return drvstr;
This looks rather obsfucated due to the fact that dev_driver_string
never returns '\0', and due to the strange mix of a tenary operation
and the if on a related condition.
quoted hunk ↗ jump to hunk
}
#endif /* CONFIG_EEH */
diff --git a/drivers/bcma/host_pci.c b/drivers/bcma/host_pci.c
index 69c10a7b7c61..dc2ffa686964 100644
--- a/drivers/bcma/host_pci.c
+++ b/drivers/bcma/host_pci.c
@@ -175,9 +175,10 @@ static int bcma_host_pci_probe(struct pci_dev *dev,
if (err)
goto err_kfree_bus;
- name = dev_name(&dev->dev);
- if (dev->driver && dev->driver->name)
- name = dev->driver->name;
+ name = dev_driver_string(&dev->dev);
+ if (*name == '\0')
+ name = dev_name(&dev->dev);
Where does this '\0' check come from?
+
+ name = dev_driver_string(&dev->dev);
+ if (*name == '\0')
+ name = dev_name(&dev->dev);
+
More of this weirdness.