Re: [PATCH 1/2] PCI: Update BAR # and window messages

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

 



On Sat, Nov 06, 2021 at 04:56:05PM +0530, Puranjay Mohan wrote:
> +		switch (i) {
> +		case 0: return "BAR 0";
> +		case 1: return "BAR 1";
> +		case 2: return "BAR 2";
> +		case 3: return "BAR 3";
> +		case 4: return "BAR 4";
> +		case 5: return "BAR 5";
> +		case PCI_ROM_RESOURCE: return "ROM";
> +		#ifdef CONFIG_PCI_IOV
> +		case PCI_IOV_RESOURCES + 0: return "VF BAR 0";
> +		case PCI_IOV_RESOURCES + 1: return "VF BAR 1";
> +		case PCI_IOV_RESOURCES + 2: return "VF BAR 2";
> +		case PCI_IOV_RESOURCES + 3: return "VF BAR 3";
> +		case PCI_IOV_RESOURCES + 4: return "VF BAR 4";
> +		case PCI_IOV_RESOURCES + 5: return "VF BAR 5";
> +		#endif
> +		}

Use a static const array of char * instead of a switch/case ladder
to reduce LoC count and improve performance.

See pcie_to_hpx3_type[] or state_conv[] in drivers/pci/pci-acpi.c
for an example.

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