Re: [PATCH 2/3] Introduce pci_slot

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

 



At Tue, 4 Mar 2008 17:48:40 -0700,
Alex Chiang <achiang@xxxxxx> wrote:
> 
> +struct pci_slot *pci_create_slot(struct pci_bus *parent, int slot_nr,
> +				 const char *name)
> +{
> +	struct pci_slot *slot;
> +	int err;
> +
> +	down_write(&pci_bus_sem);
> +
> +	/* If we've already created this slot, bump refcount and return. */
> +	for (slot = parent->slot; slot; slot = slot->next) {
> +		if (slot->number == slot_nr) {
> +			kobject_get(&slot->kobj);
> +			dbg("%s: bumped refcount to %d on %x:%d\n",
> +				__FUNCTION__, slot->kobj.kref.refcount,
> +				parent->number, slot_nr);
> +			goto out;
> +		}
> +	}
> +
> +	slot = kzalloc(sizeof(*slot), GFP_KERNEL);
> +	if (!slot) {
> +		slot = ERR_PTR(-ENOMEM);
> +		goto out;
> +	}
> +
> +	slot->bus = parent;
> +	slot->number = slot_nr;
> +
> +	slot->kobj.kset = pci_slots_kset;
> +	err = kobject_init_and_add(&slot->kobj, &pci_slot_ktype, NULL,
> +				   "%s", name);
> +	if (err) {
> +		printk(KERN_ERR "Unable to register kobject %s", name);

Add '\n', please.

> +		err = -EINVAL;
> +		goto err;
> +	}
> +
> +	err = create_sysfs_files(slot);
> +	if (err)
> +		goto unregister;
> +
> +	slot->next = parent->slot;
> +	parent->slot = slot;
> +
> +	dbg("%s: created pci_slot on %x:%d\n",
> +		__FUNCTION__, parent->number, slot_nr);
> +
> + out:
> +	up_write(&pci_bus_sem);
> +	return slot;
> +
> + unregister:
> +	kobject_put(&slot->kobj);
> + err:
> +	kfree(slot);
> +	slot = ERR_PTR(err);
> +	goto out;
> +}
> +EXPORT_SYMBOL_GPL(pci_create_slot);
> +
> +int pci_destroy_slot(struct pci_slot *slot)
> +{
> +	kobject_put(&slot->kobj);
> +
> +	dbg("%s: decreased refcount to %d on %x:%d\n", __FUNCTION__,
> +		slot->kobj.kref.refcount, slot->bus->number, slot->number);
> +	return 0;
> +}
> +EXPORT_SYMBOL_GPL(pci_destroy_slot);
> +
> +static int pci_slot_init(void)
> +{
> +	int result = 0;
> +	struct kset *pci_bus_kset;
> +
> +	pci_bus_kset = bus_get_kset(&pci_bus_type);
> +
> +	pci_slots_kset = kset_create_and_add("slots", NULL,
> +						&pci_bus_kset->kobj);
> +	if (!pci_slots_kset) {
> +		result = -ENOMEM;
> +		printk(KERN_ERR "PCI: Slot initialisation failure (%d)",
> +			result);

Ditto.

And 'initialisation' -> 'initialization' ?

> +	}
> +	return result;
> +}
> +
> +subsys_initcall(pci_slot_init);

Thanks,
MUNE
--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux IBM ACPI]     [Linux Power Management]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]     [Linux Resources]

  Powered by Linux