mirror of
https://github.com/torvalds/linux.git
synced 2026-09-23 22:14:03 +02:00
PCI: Add public pcie_valid_speed() for shared validation
Extract the PCIe speed validation logic from bwctrl.c's static pcie_valid_speed() into a public static inline function in pci.h. This allows consistent speed range checks (2.5GT/s to 64.0GT/s) across multiple drivers and functions, avoiding duplicate code and ensuring validation consistency as per PCIe specifications. Signed-off-by: Hans Zhang <18255117159@163.com> Signed-off-by: Manivannan Sadhasivam <mani@kernel.org> Reviewed-by: Shawn Lin <shawn.lin@rock-chips.com> Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Acked-by: Bjorn Helgaas <bhelgaas@google.com> Link: https://patch.msgid.link/20260407130450.1489318-2-18255117159@163.com
This commit is contained in:
parent
dc59e4fea9
commit
e1c1eb1d89
|
|
@ -599,6 +599,11 @@ void pci_bus_put(struct pci_bus *bus);
|
|||
(speed) == PCIE_SPEED_2_5GT ? 2500*8/10 : \
|
||||
0)
|
||||
|
||||
static inline bool pcie_valid_speed(enum pci_bus_speed speed)
|
||||
{
|
||||
return (speed >= PCIE_SPEED_2_5GT) && (speed <= PCIE_SPEED_64_0GT);
|
||||
}
|
||||
|
||||
static inline int pcie_dev_speed_mbps(enum pci_bus_speed speed)
|
||||
{
|
||||
switch (speed) {
|
||||
|
|
|
|||
|
|
@ -48,11 +48,6 @@ struct pcie_bwctrl_data {
|
|||
/* Prevent port removal during Link Speed changes. */
|
||||
static DECLARE_RWSEM(pcie_bwctrl_setspeed_rwsem);
|
||||
|
||||
static bool pcie_valid_speed(enum pci_bus_speed speed)
|
||||
{
|
||||
return (speed >= PCIE_SPEED_2_5GT) && (speed <= PCIE_SPEED_64_0GT);
|
||||
}
|
||||
|
||||
static u16 pci_bus_speed2lnkctl2(enum pci_bus_speed speed)
|
||||
{
|
||||
static const u8 speed_conv[] = {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user