Re: [PATCH 1/2] pci_hotplug: add an uevent framework to pci_hotplug

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

 



Taku Izumi wrote:
> Kenji-san, Greg
> 
> Thank you for reviewing.
> I'll consider about what you pointed out for a while...
> 
> 
>> How about adding new file under sys/bus/pci/<slot name> directory
>> to indicate which php driver manages the slot, instead of adding
>> PCIHP_DRV_NAME environment variable. I had some experiences that
>> it was difficult to know the slot was manged by what php driver
>> in debugging. So the new file will be useful for debugging too.
> 
> Is what you say this?
> 

Yes, it is exactly what I thought.

Thanks,
Kenji Kaneshige


> ---
>  drivers/pci/hotplug/pci_hotplug_core.c |   40 +++++++++++++++++++++++++++++++++
>  1 file changed, 40 insertions(+)
> 
> Index: linux-next.29rc6/drivers/pci/hotplug/pci_hotplug_core.c
> ===================================================================
> --- linux-next.29rc6.orig/drivers/pci/hotplug/pci_hotplug_core.c
> +++ linux-next.29rc6/drivers/pci/hotplug/pci_hotplug_core.c
> @@ -347,6 +347,25 @@ static struct pci_slot_attribute hotplug
>  	.store = test_write_file
>  };
> 
> +static ssize_t owner_name_read_file(struct pci_slot *slot, char *buf)
> +{
> +	struct hotplug_slot_ops *ops = slot->hotplug->ops;
> +	int retval;
> +
> +	if (!try_module_get(ops->owner))
> +		return -ENODEV;
> +
> +	retval = sprintf(buf, "%s\n", ops->owner->name);
> +	module_put(ops->owner);
> +
> +	return retval;
> +}
> +
> +static struct pci_slot_attribute hotplug_slot_attr_owner_name = {
> +	.attr = {.name = "owner", .mode = S_IFREG | S_IRUGO},
> +	.show = owner_name_read_file,
> +};
> +
>  static int has_power_file(struct pci_slot *pci_slot)
>  {
>  	struct hotplug_slot *slot = pci_slot->hotplug;
> @@ -420,6 +439,16 @@ static int has_test_file(struct pci_slot
>  	return -ENOENT;
>  }
> 
> +static int has_owner_name_file(struct pci_slot *pci_slot)
> +{
> +	struct hotplug_slot *slot = pci_slot->hotplug;
> +	if ((!slot) || (!slot->ops))
> +		return -ENODEV;
> +	if (slot->ops->owner)
> +		return 0;
> +	return -ENOENT;
> +}
> +
>  static int fs_add_slot(struct pci_slot *slot)
>  {
>  	int retval = 0;
> @@ -472,8 +501,19 @@ static int fs_add_slot(struct pci_slot *
>  			goto exit_test;
>  	}
> 
> +	if (has_owner_name_file(slot) == 0) {
> +		retval = sysfs_create_file(&slot->kobj,
> +					   &hotplug_slot_attr_owner_name.attr);
> +		if (retval)
> +			goto exit_owner_name;
> +	}
> +
>  	goto exit;
> 
> +exit_owner_name:
> +	if (has_test_file(slot) == 0)
> +		sysfs_remove_file(&slot->kobj, &hotplug_slot_attr_test.attr);
> +
>  exit_test:
>  	if (has_cur_bus_speed_file(slot) == 0)
>  		sysfs_remove_file(&slot->kobj, &hotplug_slot_attr_cur_bus_speed.attr);
> 
> 
> 


--
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