Re: [PATCH 10/18] PCI: Export pcie_get_speed() using the code from sysfs PCI link speed show function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Feb 06, 2023 at 01:50:52PM -0700, Dave Jiang wrote:
> Move the logic in current_link_speed_show() to a common function and export
> that functiuon as pcie_get_speed() to allow other drivers to to retrieve
> the current negotiated link speed.
[...]
> --- a/drivers/pci/pci.c
> +++ b/drivers/pci/pci.c
> @@ -6215,6 +6215,26 @@ enum pcie_link_width pcie_get_width_cap(struct pci_dev *dev)
>  }
>  EXPORT_SYMBOL(pcie_get_width_cap);
>  
> +/**
> + * pcie_get_speed - query for the PCI device's current link speed
> + * @dev: PCI device to query
> + *
> + * Query the PCI device current link speed.
> + */
> +enum pci_bus_speed pcie_get_speed(struct pci_dev *dev)
> +{
> +	u16 linkstat, cls;
> +	int err;
> +
> +	err = pcie_capability_read_word(dev, PCI_EXP_LNKSTA, &linkstat);
> +	if (err)
> +		return PCI_SPEED_UNKNOWN;
> +
> +	cls = FIELD_GET(PCI_EXP_LNKSTA_CLS, linkstat);
> +	return pcie_link_speed[cls];
> +}
> +EXPORT_SYMBOL(pcie_get_speed);

It seems we're already caching the current speed in dev->bus->cur_bus_speed.
Is that not sufficient?  If it isn't, that should be explained in the
commit message.

Thanks,

Lukas



[Index of Archives]     [DMA Engine]     [Linux Coverity]     [Linux USB]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Greybus]

  Powered by Linux