Re: [PATCH v5 1/2] platform/x86: p2sb: Allow p2sb_bar() calls during PCI device probe

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

 



On Fri, Jan 05, 2024 at 08:18:05AM +0000, Shinichiro Kawasaki wrote:
> --- a/drivers/platform/x86/p2sb.c
> +++ b/drivers/platform/x86/p2sb.c
> @@ -150,6 +153,14 @@ static int p2sb_cache_resources(void)
>  	if (!bus)
>  		return -ENODEV;
>  
> +	/*
> +	 * When a device with same devfn exists and it is not P2SB, do not
> +	 * touch it.
> +	 */
> +	pci_bus_read_config_dword(bus, devfn_p2sb, PCI_CLASS_REVISION, &class);
> +	if (!PCI_POSSIBLE_ERROR(class) && class >> 8 != P2SB_CLASS_CODE)
> +		return -ENODEV;
> +

The function should probably return if PCI_POSSIBLE_ERROR() is true.
Also I think you can use PCI_CLASS_MEMORY_OTHER, so how about:

	if (PCI_POSSIBLE_ERROR(class) || class >> 16 != PCI_CLASS_MEMORY_OTHER)
		return -ENODEV;

Can alternatively use "class >> 8 != PCI_CLASS_MEMORY_OTHER << 8" if you
want to ensure the lowest byte is 0x00.

Thanks,

Lukas




[Index of Archives]     [Linux GPIO]     [Linux SPI]     [Linux Hardward Monitoring]     [LM Sensors]     [Linux USB Devel]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux