Re: [PATCH 1/3] pci: add rescan to /sys/.../pci_bus/.../

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

 



On Mon, 02 May 2011 16:14:43 -0700
Yinghai Lu <yinghai@xxxxxxxxxx> wrote:

> 
> After remove the device from /sys, we have to rescan all or
> find out the bridge and access /sys../device/rescan there.
> 
> this patch add /sys/.../pci_bus/.../rescan. So user can rescan more easy.
> that is more clean and easy to understand.
> 
> like after remove 0000:c4:00.0, you can rescan 0000:c4 directly.
> 
> Signed-off-by: Yinghai Lu <yinghai@xxxxxxxxxx>

I like the idea, and agree that bus rescanning makes sense.  Comments
below.

> ===================================================================
> --- linux-2.6.orig/drivers/pci/bus.c
> +++ linux-2.6/drivers/pci/bus.c
> @@ -163,6 +163,12 @@ int pci_bus_add_child(struct pci_bus *bu
>  
>  	bus->is_added = 1;
>  
> +#ifdef CONFIG_HOTPLUG
> +	retval = device_create_file(&bus->dev, &dev_attr_rescan);
> +	if (retval)
> +		return retval;
> +#endif
> +
>  	retval = device_create_file(&bus->dev, &dev_attr_cpuaffinity);
>  	if (retval)
>  		return retval;

Can you make this a separate function with a !CONFIG_HOTPLUG version so
we don't have an #ifdef inside this function?

> Index: linux-2.6/drivers/pci/pci.h
> ===================================================================
> --- linux-2.6.orig/drivers/pci/pci.h
> +++ linux-2.6/drivers/pci/pci.h
> @@ -159,6 +159,7 @@ extern struct device_attribute pci_dev_a
>  extern struct device_attribute dev_attr_cpuaffinity;
>  extern struct device_attribute dev_attr_cpulistaffinity;
>  #ifdef CONFIG_HOTPLUG
> +extern struct device_attribute dev_attr_rescan;
>  extern struct bus_attribute pci_bus_attrs[];
>  #else
>  #define pci_bus_attrs	NULL
> Index: linux-2.6/drivers/pci/probe.c
> ===================================================================
> --- linux-2.6.orig/drivers/pci/probe.c
> +++ linux-2.6/drivers/pci/probe.c
> @@ -1471,6 +1471,11 @@ struct pci_bus * pci_create_bus(struct d
>  	error = device_create_file(&b->dev, &dev_attr_cpuaffinity);
>  	if (error)
>  		goto dev_create_file_err;
> +#ifdef CONFIG_HOTPLUG
> +	error = device_create_file(&b->dev, &dev_attr_rescan);
> +	if (error)
> +		goto dev_create_bus_rescan_err;
> +#endif

Same here.

>  
>  	/* Create legacy_io and legacy_mem files for this bus */
>  	pci_create_legacy_files(b);
> @@ -1481,6 +1486,10 @@ struct pci_bus * pci_create_bus(struct d
>  
>  	return b;
>  
> +#ifdef CONFIG_HOTPLUG
> +dev_create_bus_rescan_err:
> +	device_remove_file(&b->dev, &dev_attr_cpuaffinity);
> +#endif

Without the ifdef above, this could be unconditional; it just won't be
hit in the !CONFIG_HOTPLUG case.

Thanks,
-- 
Jesse Barnes, Intel Open Source Technology Center
--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[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