Re: [PATCH net-next v6 2/2] dinghai: add hardware register access and PCI? capability scanning

From: Andrew Lunn

Date: Tue Jun 16 2026 - 15:50:12 EST


> +int zxdh_pf_common_cfg_init(struct dh_core_dev *dh_dev)
> +{
> + struct zxdh_pf_device *pf_dev = dh_dev->priv;
> + struct pci_dev *pdev = dh_dev->pdev;
> + int common;
> +
> + /* check for a common config: if not, use legacy mode (bar 0). */
> + common = zxdh_pf_pci_find_capability(pdev, ZXDH_PCI_CAP_COMMON_CFG,
> + IORESOURCE_IO | IORESOURCE_MEM,
> + &pf_dev->modern_bars);
> + if (common == 0) {
> + dev_err(dh_dev->device,
> + "missing capabilities %i, leaving for legacy driver\n",
> + common);

That looks double odd. Normally you would use !common. Also, you know
common is 0, so why use "%i", when it could be just '0'.

> +int zxdh_pf_notify_cfg_init(struct dh_core_dev *dh_dev)
> +{
> + struct zxdh_pf_device *pf_dev = dh_dev->priv;
> + struct pci_dev *pdev = dh_dev->pdev;
> + u32 notify_length;
> + u32 notify_offset;
> + int notify;
> +
> + /* If common is there, these should be too... */
> + notify = zxdh_pf_pci_find_capability(pdev, ZXDH_PCI_CAP_NOTIFY_CFG,
> + IORESOURCE_IO | IORESOURCE_MEM,
> + &pf_dev->modern_bars);
> + if (notify == 0) {
> + dev_err(dh_dev->device, "missing capabilities %i\n", notify);
> + return -EINVAL;
> + }
> +

Same again.

Andrew

---
pw-bot: cr