[GIT PATCH] driver core patches against 2.6.26 - Kernel

This is a discussion on [GIT PATCH] driver core patches against 2.6.26 - Kernel ; Use the proper class iterator function instead of mucking around in the internals of the class structures. Cc: Kay Sievers Signed-off-by: Greg Kroah-Hartman --- block/genhd.c | 25 +++++++++++++------------ 1 files changed, 13 insertions(+), 12 deletions(-) diff --git a/block/genhd.c b/block/genhd.c index ...

+ Reply to Thread
Page 2 of 4 FirstFirst 1 2 3 4 LastLast
Results 21 to 40 of 79

Thread: [GIT PATCH] driver core patches against 2.6.26

  1. [PATCH 39/79] block: make /proc/partitions and /proc/diskstats use class_find_device()

    Use the proper class iterator function instead of mucking around in the
    internals of the class structures.

    Cc: Kay Sievers
    Signed-off-by: Greg Kroah-Hartman
    ---
    block/genhd.c | 25 +++++++++++++------------
    1 files changed, 13 insertions(+), 12 deletions(-)

    diff --git a/block/genhd.c b/block/genhd.c
    index 70f1d70..c13cc77 100644
    --- a/block/genhd.c
    +++ b/block/genhd.c
    @@ -317,17 +317,21 @@ static void *part_start(struct seq_file *part, loff_t *pos)
    return NULL;
    }

    +static int find_next(struct device *dev, void *data)
    +{
    + if (dev->type == &disk_type)
    + return 1;
    + return 0;
    +}
    +
    static void *part_next(struct seq_file *part, void *v, loff_t *pos)
    {
    struct gendisk *gp = v;
    struct device *dev;
    ++*pos;
    - list_for_each_entry(dev, &gp->dev.node, node) {
    - if (&dev->node == &block_class.devices)
    - return NULL;
    - if (dev->type == &disk_type)
    - return dev_to_disk(dev);
    - }
    + dev = class_find_device(&block_class, &gp->dev, NULL, find_next);
    + if (dev)
    + return dev_to_disk(dev);
    return NULL;
    }

    @@ -578,12 +582,9 @@ static void *diskstats_next(struct seq_file *part, void *v, loff_t *pos)
    struct device *dev;

    ++*pos;
    - list_for_each_entry(dev, &gp->dev.node, node) {
    - if (&dev->node == &block_class.devices)
    - return NULL;
    - if (dev->type == &disk_type)
    - return dev_to_disk(dev);
    - }
    + dev = class_find_device(&block_class, &gp->dev, NULL, find_next);
    + if (dev)
    + return dev_to_disk(dev);
    return NULL;
    }

    --
    1.5.6.3

    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  2. [PATCH 51/79] driver core: remove KOBJ_NAME_LEN define

    From: Kay Sievers

    Kobjects do not have a limit in name size since a while, so stop
    pretending that they do.

    Signed-off-by: Kay Sievers
    Signed-off-by: Greg Kroah-Hartman
    ---
    arch/arm/plat-omap/mailbox.c | 2 +-
    arch/sparc64/kernel/vio.c | 2 +-
    drivers/message/fusion/mptbase.c | 3 ++-
    drivers/message/fusion/mptbase.h | 4 ++--
    drivers/message/fusion/mptfc.c | 4 ++--
    drivers/pci/hotplug/acpiphp.h | 4 ++--
    drivers/scsi/hosts.c | 4 ++--
    drivers/scsi/scsi_transport_fc.c | 9 +++++----
    drivers/scsi/scsi_transport_iscsi.c | 4 ++--
    fs/partitions/check.c | 2 +-
    include/linux/device.h | 3 +--
    include/linux/kobject.h | 1 -
    include/linux/spi/spi.h | 2 +-
    include/scsi/scsi_host.h | 2 +-
    include/scsi/scsi_transport_fc.h | 4 ++--
    include/scsi/scsi_transport_iscsi.h | 2 +-
    16 files changed, 26 insertions(+), 26 deletions(-)

    diff --git a/arch/arm/plat-omap/mailbox.c b/arch/arm/plat-omap/mailbox.c
    index 6f33f58..848fdca 100644
    --- a/arch/arm/plat-omap/mailbox.c
    +++ b/arch/arm/plat-omap/mailbox.c
    @@ -334,7 +334,7 @@ static int omap_mbox_init(struct omap_mbox *mbox)
    }

    mbox->dev.class = &omap_mbox_class;
    - strlcpy(mbox->dev.bus_id, mbox->name, KOBJ_NAME_LEN);
    + strlcpy(mbox->dev.bus_id, mbox->name, BUS_ID_SIZE);
    dev_set_drvdata(&mbox->dev, mbox);

    ret = device_register(&mbox->dev);
    diff --git a/arch/sparc64/kernel/vio.c b/arch/sparc64/kernel/vio.c
    index e78b351..ecbb8b6 100644
    --- a/arch/sparc64/kernel/vio.c
    +++ b/arch/sparc64/kernel/vio.c
    @@ -224,7 +224,7 @@ static struct vio_dev *vio_create_one(struct mdesc_handle *hp, u64 mp,
    if (!strcmp(type, "domain-services-port"))
    bus_id_name = "ds";

    - if (strlen(bus_id_name) >= KOBJ_NAME_LEN - 4) {
    + if (strlen(bus_id_name) >= BUS_ID_SIZE - 4) {
    printk(KERN_ERR "VIO: bus_id_name [%s] is too long.\n",
    bus_id_name);
    return NULL;
    diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c
    index 75e599b..34402c4 100644
    --- a/drivers/message/fusion/mptbase.c
    +++ b/drivers/message/fusion/mptbase.c
    @@ -1670,7 +1670,8 @@ mpt_attach(struct pci_dev *pdev, const struct pci_device_id *id)
    INIT_DELAYED_WORK(&ioc->fault_reset_work, mpt_fault_reset_work);
    spin_lock_init(&ioc->fault_reset_work_lock);

    - snprintf(ioc->reset_work_q_name, KOBJ_NAME_LEN, "mpt_poll_%d", ioc->id);
    + snprintf(ioc->reset_work_q_name, sizeof(ioc->reset_work_q_name),
    + "mpt_poll_%d", ioc->id);
    ioc->reset_work_q =
    create_singlethread_workqueue(ioc->reset_work_q_name);
    if (!ioc->reset_work_q) {
    diff --git a/drivers/message/fusion/mptbase.h b/drivers/message/fusion/mptbase.h
    index 6adab64..dff048c 100644
    --- a/drivers/message/fusion/mptbase.h
    +++ b/drivers/message/fusion/mptbase.h
    @@ -707,12 +707,12 @@ typedef struct _MPT_ADAPTER
    u8 fc_link_speed[2];
    spinlock_t fc_rescan_work_lock;
    struct work_struct fc_rescan_work;
    - char fc_rescan_work_q_name[KOBJ_NAME_LEN];
    + char fc_rescan_work_q_name[20];
    struct workqueue_struct *fc_rescan_work_q;
    struct scsi_cmnd **ScsiLookup;
    spinlock_t scsi_lookup_lock;

    - char reset_work_q_name[KOBJ_NAME_LEN];
    + char reset_work_q_name[20];
    struct workqueue_struct *reset_work_q;
    struct delayed_work fault_reset_work;
    spinlock_t fault_reset_work_lock;
    diff --git a/drivers/message/fusion/mptfc.c b/drivers/message/fusion/mptfc.c
    index fc31ca6..b36cae9 100644
    --- a/drivers/message/fusion/mptfc.c
    +++ b/drivers/message/fusion/mptfc.c
    @@ -1326,8 +1326,8 @@ mptfc_probe(struct pci_dev *pdev, const struct pci_device_id *id)

    /* initialize workqueue */

    - snprintf(ioc->fc_rescan_work_q_name, KOBJ_NAME_LEN, "mptfc_wq_%d",
    - sh->host_no);
    + snprintf(ioc->fc_rescan_work_q_name, sizeof(ioc->fc_rescan_work_q_name),
    + "mptfc_wq_%d", sh->host_no);
    ioc->fc_rescan_work_q =
    create_singlethread_workqueue(ioc->fc_rescan_work_q_name);
    if (!ioc->fc_rescan_work_q)
    diff --git a/drivers/pci/hotplug/acpiphp.h b/drivers/pci/hotplug/acpiphp.h
    index eecf7cb..5a58b07 100644
    --- a/drivers/pci/hotplug/acpiphp.h
    +++ b/drivers/pci/hotplug/acpiphp.h
    @@ -36,7 +36,7 @@
    #define _ACPIPHP_H

    #include
    -#include /* for KOBJ_NAME_LEN */
    +#include
    #include
    #include

    @@ -51,7 +51,7 @@
    #define warn(format, arg...) printk(KERN_WARNING "%s: " format, MY_NAME , ## arg)

    /* name size which is used for entries in pcihpfs */
    -#define SLOT_NAME_SIZE KOBJ_NAME_LEN /* {_SUN} */
    +#define SLOT_NAME_SIZE 20 /* {_SUN} */

    struct acpiphp_bridge;
    struct acpiphp_slot;
    diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
    index 78dad28..fed0b02 100644
    --- a/drivers/scsi/hosts.c
    +++ b/drivers/scsi/hosts.c
    @@ -232,8 +232,8 @@ int scsi_add_host(struct Scsi_Host *shost, struct device *dev)
    }

    if (shost->transportt->create_work_queue) {
    - snprintf(shost->work_q_name, KOBJ_NAME_LEN, "scsi_wq_%d",
    - shost->host_no);
    + snprintf(shost->work_q_name, sizeof(shost->work_q_name),
    + "scsi_wq_%d", shost->host_no);
    shost->work_q = create_singlethread_workqueue(
    shost->work_q_name);
    if (!shost->work_q) {
    diff --git a/drivers/scsi/scsi_transport_fc.c b/drivers/scsi/scsi_transport_fc.c
    index 5fd64e7..a272b9a 100644
    --- a/drivers/scsi/scsi_transport_fc.c
    +++ b/drivers/scsi/scsi_transport_fc.c
    @@ -417,15 +417,16 @@ static int fc_host_setup(struct transport_container *tc, struct device *dev,
    fc_host->next_vport_number = 0;
    fc_host->npiv_vports_inuse = 0;

    - snprintf(fc_host->work_q_name, KOBJ_NAME_LEN, "fc_wq_%d",
    - shost->host_no);
    + snprintf(fc_host->work_q_name, sizeof(fc_host->work_q_name),
    + "fc_wq_%d", shost->host_no);
    fc_host->work_q = create_singlethread_workqueue(
    fc_host->work_q_name);
    if (!fc_host->work_q)
    return -ENOMEM;

    - snprintf(fc_host->devloss_work_q_name, KOBJ_NAME_LEN, "fc_dl_%d",
    - shost->host_no);
    + snprintf(fc_host->devloss_work_q_name,
    + sizeof(fc_host->devloss_work_q_name),
    + "fc_dl_%d", shost->host_no);
    fc_host->devloss_work_q = create_singlethread_workqueue(
    fc_host->devloss_work_q_name);
    if (!fc_host->devloss_work_q) {
    diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
    index 06748f3..043c392 100644
    --- a/drivers/scsi/scsi_transport_iscsi.c
    +++ b/drivers/scsi/scsi_transport_iscsi.c
    @@ -247,8 +247,8 @@ static int iscsi_setup_host(struct transport_container *tc, struct device *dev,
    atomic_set(&ihost->nr_scans, 0);
    mutex_init(&ihost->mutex);

    - snprintf(ihost->scan_workq_name, KOBJ_NAME_LEN, "iscsi_scan_%d",
    - shost->host_no);
    + snprintf(ihost->scan_workq_name, sizeof(ihost->scan_workq_name),
    + "iscsi_scan_%d", shost->host_no);
    ihost->scan_workq = create_singlethread_workqueue(
    ihost->scan_workq_name);
    if (!ihost->scan_workq)
    diff --git a/fs/partitions/check.c b/fs/partitions/check.c
    index 6149e4b..efef715 100644
    --- a/fs/partitions/check.c
    +++ b/fs/partitions/check.c
    @@ -401,7 +401,7 @@ void register_disk(struct gendisk *disk)
    disk->dev.parent = disk->driverfs_dev;
    disk->dev.devt = MKDEV(disk->major, disk->first_minor);

    - strlcpy(disk->dev.bus_id, disk->disk_name, KOBJ_NAME_LEN);
    + strlcpy(disk->dev.bus_id, disk->disk_name, BUS_ID_SIZE);
    /* ewww... some of these buggers have / in the name... */
    s = strchr(disk->dev.bus_id, '/');
    if (s)
    diff --git a/include/linux/device.h b/include/linux/device.h
    index 0e1d24c..fba1bb0 100644
    --- a/include/linux/device.h
    +++ b/include/linux/device.h
    @@ -29,8 +29,7 @@
    /* DEVICE_NAME_HALF is really less than half to accommodate slop */
    #define DEVICE_NAME_HALF __stringify(20)
    #define DEVICE_ID_SIZE 32
    -#define BUS_ID_SIZE KOBJ_NAME_LEN
    -
    +#define BUS_ID_SIZE 20

    struct device;
    struct device_driver;
    diff --git a/include/linux/kobject.h b/include/linux/kobject.h
    index 39e709f..d542faa 100644
    --- a/include/linux/kobject.h
    +++ b/include/linux/kobject.h
    @@ -26,7 +26,6 @@
    #include
    #include

    -#define KOBJ_NAME_LEN 20
    #define UEVENT_HELPER_PATH_LEN 256
    #define UEVENT_NUM_ENVP 32 /* number of env pointers */
    #define UEVENT_BUFFER_SIZE 2048 /* buffer for the variables */
    diff --git a/include/linux/spi/spi.h b/include/linux/spi/spi.h
    index 387e428..b9a76c9 100644
    --- a/include/linux/spi/spi.h
    +++ b/include/linux/spi/spi.h
    @@ -733,7 +733,7 @@ struct spi_board_info {
    * controller_data goes to spi_device.controller_data,
    * irq is copied too
    */
    - char modalias[KOBJ_NAME_LEN];
    + char modalias[32];
    const void *platform_data;
    void *controller_data;
    int irq;
    diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h
    index 1834fdf..a594bac 100644
    --- a/include/scsi/scsi_host.h
    +++ b/include/scsi/scsi_host.h
    @@ -623,7 +623,7 @@ struct Scsi_Host {
    /*
    * Optional work queue to be utilized by the transport
    */
    - char work_q_name[KOBJ_NAME_LEN];
    + char work_q_name[20];
    struct workqueue_struct *work_q;

    /*
    diff --git a/include/scsi/scsi_transport_fc.h b/include/scsi/scsi_transport_fc.h
    index 06f72ba..878373c 100644
    --- a/include/scsi/scsi_transport_fc.h
    +++ b/include/scsi/scsi_transport_fc.h
    @@ -489,9 +489,9 @@ struct fc_host_attrs {
    u16 npiv_vports_inuse;

    /* work queues for rport state manipulation */
    - char work_q_name[KOBJ_NAME_LEN];
    + char work_q_name[20];
    struct workqueue_struct *work_q;
    - char devloss_work_q_name[KOBJ_NAME_LEN];
    + char devloss_work_q_name[20];
    struct workqueue_struct *devloss_work_q;
    };

    diff --git a/include/scsi/scsi_transport_iscsi.h b/include/scsi/scsi_transport_iscsi.h
    index f5444e0..8b6c91d 100644
    --- a/include/scsi/scsi_transport_iscsi.h
    +++ b/include/scsi/scsi_transport_iscsi.h
    @@ -198,7 +198,7 @@ struct iscsi_cls_host {
    atomic_t nr_scans;
    struct mutex mutex;
    struct workqueue_struct *scan_workq;
    - char scan_workq_name[KOBJ_NAME_LEN];
    + char scan_workq_name[20];
    };

    extern void iscsi_host_for_each_session(struct Scsi_Host *shost,
    --
    1.5.6.3

    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  3. [PATCH 43/79] class: move driver core specific parts to a private structure

    This moves the portions of struct class that are dynamic (kobject and
    lock and lists) out of the main structure and into a dynamic, private,
    structure.


    Cc: Kay Sievers
    Signed-off-by: Greg Kroah-Hartman
    ---
    drivers/base/base.h | 27 +++++++++++++++
    drivers/base/class.c | 87 ++++++++++++++++++++++++++---------------------
    drivers/base/core.c | 57 ++++++++++++++++---------------
    include/linux/device.h | 7 +---
    4 files changed, 107 insertions(+), 71 deletions(-)

    diff --git a/drivers/base/base.h b/drivers/base/base.h
    index 2c9ae43..0ec372a 100644
    --- a/drivers/base/base.h
    +++ b/drivers/base/base.h
    @@ -36,6 +36,33 @@ struct driver_private {
    };
    #define to_driver(obj) container_of(obj, struct driver_private, kobj)

    +
    +/**
    + * struct class_private - structure to hold the private to the driver core portions of the class structure.
    + *
    + * @subsys - the struct kset that defines this class. This is the main kobject
    + * @children - list of class_devices associated with this class
    + * @devices - list of devices associated with this class
    + * @interfaces - list of class_interfaces associated with this class
    + * @class_dirs -
    + * @sem - semaphore to protect the children, devices, and interfaces lists.
    + * @class - pointer back to the struct class that this structure is associated
    + * with.
    + *
    + * This structure is the one that is the actual kobject allowing struct
    + * class to be statically allocated safely. Nothing outside of the driver
    + * core should ever touch these fields.
    + */
    +struct class_private {
    + struct kset subsys;
    + struct list_head devices;
    + struct list_head interfaces;
    + struct kset class_dirs;
    + struct semaphore sem;
    + struct class *class;
    +};
    +#define to_class(obj) container_of(obj, struct class_private, subsys.kobj)
    +
    /* initialisation functions */
    extern int devices_init(void);
    extern int buses_init(void);
    diff --git a/drivers/base/class.c b/drivers/base/class.c
    index 3918d0e..06f09c9 100644
    --- a/drivers/base/class.c
    +++ b/drivers/base/class.c
    @@ -21,17 +21,16 @@
    #include "base.h"

    #define to_class_attr(_attr) container_of(_attr, struct class_attribute, attr)
    -#define to_class(obj) container_of(obj, struct class, subsys.kobj)

    static ssize_t class_attr_show(struct kobject *kobj, struct attribute *attr,
    char *buf)
    {
    struct class_attribute *class_attr = to_class_attr(attr);
    - struct class *dc = to_class(kobj);
    + struct class_private *cp = to_class(kobj);
    ssize_t ret = -EIO;

    if (class_attr->show)
    - ret = class_attr->show(dc, buf);
    + ret = class_attr->show(cp->class, buf);
    return ret;
    }

    @@ -39,17 +38,18 @@ static ssize_t class_attr_store(struct kobject *kobj, struct attribute *attr,
    const char *buf, size_t count)
    {
    struct class_attribute *class_attr = to_class_attr(attr);
    - struct class *dc = to_class(kobj);
    + struct class_private *cp = to_class(kobj);
    ssize_t ret = -EIO;

    if (class_attr->store)
    - ret = class_attr->store(dc, buf, count);
    + ret = class_attr->store(cp->class, buf, count);
    return ret;
    }

    static void class_release(struct kobject *kobj)
    {
    - struct class *class = to_class(kobj);
    + struct class_private *cp = to_class(kobj);
    + struct class *class = cp->class;

    pr_debug("class '%s': release.\n", class->name);

    @@ -78,7 +78,7 @@ int class_create_file(struct class *cls, const struct class_attribute *attr)
    {
    int error;
    if (cls)
    - error = sysfs_create_file(&cls->subsys.kobj, &attr->attr);
    + error = sysfs_create_file(&cls->p->subsys.kobj, &attr->attr);
    else
    error = -EINVAL;
    return error;
    @@ -87,21 +87,20 @@ int class_create_file(struct class *cls, const struct class_attribute *attr)
    void class_remove_file(struct class *cls, const struct class_attribute *attr)
    {
    if (cls)
    - sysfs_remove_file(&cls->subsys.kobj, &attr->attr);
    + sysfs_remove_file(&cls->p->subsys.kobj, &attr->attr);
    }

    static struct class *class_get(struct class *cls)
    {
    if (cls)
    - return container_of(kset_get(&cls->subsys),
    - struct class, subsys);
    - return NULL;
    + kset_get(&cls->p->subsys);
    + return cls;
    }

    static void class_put(struct class *cls)
    {
    if (cls)
    - kset_put(&cls->subsys);
    + kset_put(&cls->p->subsys);
    }

    static int add_class_attrs(struct class *cls)
    @@ -136,17 +135,23 @@ static void remove_class_attrs(struct class *cls)

    int class_register(struct class *cls)
    {
    + struct class_private *cp;
    int error;

    pr_debug("device class '%s': registering\n", cls->name);

    - INIT_LIST_HEAD(&cls->devices);
    - INIT_LIST_HEAD(&cls->interfaces);
    - kset_init(&cls->class_dirs);
    - init_MUTEX(&cls->sem);
    - error = kobject_set_name(&cls->subsys.kobj, "%s", cls->name);
    - if (error)
    + cp = kzalloc(sizeof(*cp), GFP_KERNEL);
    + if (!cp)
    + return -ENOMEM;
    + INIT_LIST_HEAD(&cp->devices);
    + INIT_LIST_HEAD(&cp->interfaces);
    + kset_init(&cp->class_dirs);
    + init_MUTEX(&cp->sem);
    + error = kobject_set_name(&cp->subsys.kobj, "%s", cls->name);
    + if (error) {
    + kfree(cp);
    return error;
    + }

    /* set the default /sys/dev directory for devices of this class */
    if (!cls->dev_kobj)
    @@ -155,17 +160,21 @@ int class_register(struct class *cls)
    #if defined(CONFIG_SYSFS_DEPRECATED) && defined(CONFIG_BLOCK)
    /* let the block class directory show up in the root of sysfs */
    if (cls != &block_class)
    - cls->subsys.kobj.kset = class_kset;
    + cp->subsys.kobj.kset = class_kset;
    #else
    - cls->subsys.kobj.kset = class_kset;
    + cp->subsys.kobj.kset = class_kset;
    #endif
    - cls->subsys.kobj.ktype = &class_ktype;
    + cp->subsys.kobj.ktype = &class_ktype;
    + cp->class = cls;
    + cls->p = cp;

    - error = kset_register(&cls->subsys);
    - if (!error) {
    - error = add_class_attrs(class_get(cls));
    - class_put(cls);
    + error = kset_register(&cp->subsys);
    + if (error) {
    + kfree(cp);
    + return error;
    }
    + error = add_class_attrs(class_get(cls));
    + class_put(cls);
    return error;
    }

    @@ -173,7 +182,7 @@ void class_unregister(struct class *cls)
    {
    pr_debug("device class '%s': unregistering\n", cls->name);
    remove_class_attrs(cls);
    - kset_unregister(&cls->subsys);
    + kset_unregister(&cls->p->subsys);
    }

    static void class_create_release(struct class *cls)
    @@ -280,8 +289,8 @@ int class_for_each_device(struct class *class, struct device *start,

    if (!class)
    return -EINVAL;
    - down(&class->sem);
    - list_for_each_entry(dev, &class->devices, node) {
    + down(&class->p->sem);
    + list_for_each_entry(dev, &class->p->devices, node) {
    if (start) {
    if (start == dev)
    start = NULL;
    @@ -293,7 +302,7 @@ int class_for_each_device(struct class *class, struct device *start,
    if (error)
    break;
    }
    - up(&class->sem);
    + up(&class->p->sem);

    return error;
    }
    @@ -330,8 +339,8 @@ struct device *class_find_device(struct class *class, struct device *start,
    if (!class)
    return NULL;

    - down(&class->sem);
    - list_for_each_entry(dev, &class->devices, node) {
    + down(&class->p->sem);
    + list_for_each_entry(dev, &class->p->devices, node) {
    if (start) {
    if (start == dev)
    start = NULL;
    @@ -344,7 +353,7 @@ struct device *class_find_device(struct class *class, struct device *start,
    } else
    put_device(dev);
    }
    - up(&class->sem);
    + up(&class->p->sem);

    return found ? dev : NULL;
    }
    @@ -362,13 +371,13 @@ int class_interface_register(struct class_interface *class_intf)
    if (!parent)
    return -EINVAL;

    - down(&parent->sem);
    - list_add_tail(&class_intf->node, &parent->interfaces);
    + down(&parent->p->sem);
    + list_add_tail(&class_intf->node, &parent->p->interfaces);
    if (class_intf->add_dev) {
    - list_for_each_entry(dev, &parent->devices, node)
    + list_for_each_entry(dev, &parent->p->devices, node)
    class_intf->add_dev(dev, class_intf);
    }
    - up(&parent->sem);
    + up(&parent->p->sem);

    return 0;
    }
    @@ -381,13 +390,13 @@ void class_interface_unregister(struct class_interface *class_intf)
    if (!parent)
    return;

    - down(&parent->sem);
    + down(&parent->p->sem);
    list_del_init(&class_intf->node);
    if (class_intf->remove_dev) {
    - list_for_each_entry(dev, &parent->devices, node)
    + list_for_each_entry(dev, &parent->p->devices, node)
    class_intf->remove_dev(dev, class_intf);
    }
    - up(&parent->sem);
    + up(&parent->p->sem);

    class_put(parent);
    }
    diff --git a/drivers/base/core.c b/drivers/base/core.c
    index 9f05de6..64c150b 100644
    --- a/drivers/base/core.c
    +++ b/drivers/base/core.c
    @@ -551,7 +551,7 @@ static struct kobject *get_device_parent(struct device *dev,
    {
    /* class devices without a parent live in /sys/class// */
    if (dev->class && (!parent || parent->class != dev->class))
    - return &dev->class->subsys.kobj;
    + return &dev->class->p->subsys.kobj;
    /* all other devices keep their parent */
    else if (parent)
    return &parent->kobj;
    @@ -597,13 +597,13 @@ static struct kobject *get_device_parent(struct device *dev,
    parent_kobj = &parent->kobj;

    /* find our class-directory at the parent and reference it */
    - spin_lock(&dev->class->class_dirs.list_lock);
    - list_for_each_entry(k, &dev->class->class_dirs.list, entry)
    + spin_lock(&dev->class->p->class_dirs.list_lock);
    + list_for_each_entry(k, &dev->class->p->class_dirs.list, entry)
    if (k->parent == parent_kobj) {
    kobj = kobject_get(k);
    break;
    }
    - spin_unlock(&dev->class->class_dirs.list_lock);
    + spin_unlock(&dev->class->p->class_dirs.list_lock);
    if (kobj)
    return kobj;

    @@ -611,7 +611,7 @@ static struct kobject *get_device_parent(struct device *dev,
    k = kobject_create();
    if (!k)
    return NULL;
    - k->kset = &dev->class->class_dirs;
    + k->kset = &dev->class->p->class_dirs;
    retval = kobject_add(k, parent_kobj, "%s", dev->class->name);
    if (retval < 0) {
    kobject_put(k);
    @@ -630,7 +630,7 @@ static void cleanup_glue_dir(struct device *dev, struct kobject *glue_dir)
    {
    /* see if we live in a "glue" directory */
    if (!glue_dir || !dev->class ||
    - glue_dir->kset != &dev->class->class_dirs)
    + glue_dir->kset != &dev->class->p->class_dirs)
    return;

    kobject_put(glue_dir);
    @@ -657,17 +657,17 @@ static int device_add_class_symlinks(struct device *dev)
    if (!dev->class)
    return 0;

    - error = sysfs_create_link(&dev->kobj, &dev->class->subsys.kobj,
    + error = sysfs_create_link(&dev->kobj, &dev->class->p->subsys.kobj,
    "subsystem");
    if (error)
    goto out;

    #ifdef CONFIG_SYSFS_DEPRECATED
    /* stacked class devices need a symlink in the class directory */
    - if (dev->kobj.parent != &dev->class->subsys.kobj &&
    + if (dev->kobj.parent != &dev->class->p->subsys.kobj &&
    device_is_not_partition(dev)) {
    - error = sysfs_create_link(&dev->class->subsys.kobj, &dev->kobj,
    - dev->bus_id);
    + error = sysfs_create_link(&dev->class->p->subsys.kobj,
    + &dev->kobj, dev->bus_id);
    if (error)
    goto out_subsys;
    }
    @@ -704,12 +704,12 @@ out_device:
    if (dev->parent && device_is_not_partition(dev))
    sysfs_remove_link(&dev->kobj, "device");
    out_busid:
    - if (dev->kobj.parent != &dev->class->subsys.kobj &&
    + if (dev->kobj.parent != &dev->class->p->subsys.kobj &&
    device_is_not_partition(dev))
    - sysfs_remove_link(&dev->class->subsys.kobj, dev->bus_id);
    + sysfs_remove_link(&dev->class->p->subsys.kobj, dev->bus_id);
    #else
    /* link in the class directory pointing to the device */
    - error = sysfs_create_link(&dev->class->subsys.kobj, &dev->kobj,
    + error = sysfs_create_link(&dev->class->p->subsys.kobj, &dev->kobj,
    dev->bus_id);
    if (error)
    goto out_subsys;
    @@ -723,7 +723,7 @@ out_busid:
    return 0;

    out_busid:
    - sysfs_remove_link(&dev->class->subsys.kobj, dev->bus_id);
    + sysfs_remove_link(&dev->class->p->subsys.kobj, dev->bus_id);
    #endif

    out_subsys:
    @@ -749,14 +749,14 @@ static void device_remove_class_symlinks(struct device *dev)
    sysfs_remove_link(&dev->kobj, "device");
    }

    - if (dev->kobj.parent != &dev->class->subsys.kobj &&
    + if (dev->kobj.parent != &dev->class->p->subsys.kobj &&
    device_is_not_partition(dev))
    - sysfs_remove_link(&dev->class->subsys.kobj, dev->bus_id);
    + sysfs_remove_link(&dev->class->p->subsys.kobj, dev->bus_id);
    #else
    if (dev->parent && device_is_not_partition(dev))
    sysfs_remove_link(&dev->kobj, "device");

    - sysfs_remove_link(&dev->class->subsys.kobj, dev->bus_id);
    + sysfs_remove_link(&dev->class->p->subsys.kobj, dev->bus_id);
    #endif

    sysfs_remove_link(&dev->kobj, "subsystem");
    @@ -904,15 +904,16 @@ int device_add(struct device *dev)
    klist_add_tail(&dev->knode_parent, &parent->klist_children);

    if (dev->class) {
    - down(&dev->class->sem);
    + down(&dev->class->p->sem);
    /* tie the class to the device */
    - list_add_tail(&dev->node, &dev->class->devices);
    + list_add_tail(&dev->node, &dev->class->p->devices);

    /* notify any interfaces that the device is here */
    - list_for_each_entry(class_intf, &dev->class->interfaces, node)
    + list_for_each_entry(class_intf, &dev->class->p->interfaces,
    + node)
    if (class_intf->add_dev)
    class_intf->add_dev(dev, class_intf);
    - up(&dev->class->sem);
    + up(&dev->class->p->sem);
    }
    Done:
    put_device(dev);
    @@ -1013,14 +1014,15 @@ void device_del(struct device *dev)
    if (dev->class) {
    device_remove_class_symlinks(dev);

    - down(&dev->class->sem);
    + down(&dev->class->p->sem);
    /* notify any interfaces that the device is now gone */
    - list_for_each_entry(class_intf, &dev->class->interfaces, node)
    + list_for_each_entry(class_intf, &dev->class->p->interfaces,
    + node)
    if (class_intf->remove_dev)
    class_intf->remove_dev(dev, class_intf);
    /* remove the device from the class list */
    list_del_init(&dev->node);
    - up(&dev->class->sem);
    + up(&dev->class->p->sem);
    }
    device_remove_file(dev, &uevent_attr);
    device_remove_attrs(dev);
    @@ -1348,11 +1350,12 @@ int device_rename(struct device *dev, char *new_name)
    }
    #else
    if (dev->class) {
    - error = sysfs_create_link(&dev->class->subsys.kobj, &dev->kobj,
    - dev->bus_id);
    + error = sysfs_create_link(&dev->class->p->subsys.kobj,
    + &dev->kobj, dev->bus_id);
    if (error)
    goto out;
    - sysfs_remove_link(&dev->class->subsys.kobj, old_device_name);
    + sysfs_remove_link(&dev->class->p->subsys.kobj,
    + old_device_name);
    }
    #endif

    diff --git a/include/linux/device.h b/include/linux/device.h
    index c1f7298..b055608 100644
    --- a/include/linux/device.h
    +++ b/include/linux/device.h
    @@ -35,6 +35,7 @@ struct device;
    struct device_driver;
    struct driver_private;
    struct class;
    +struct class_private;
    struct bus_type;
    struct bus_type_private;

    @@ -186,11 +187,6 @@ struct class {
    const char *name;
    struct module *owner;

    - struct kset subsys;
    - struct list_head devices;
    - struct list_head interfaces;
    - struct kset class_dirs;
    - struct semaphore sem; /* locks children, devices, interfaces */
    struct class_attribute *class_attrs;
    struct device_attribute *dev_attrs;
    struct kobject *dev_kobj;
    @@ -204,6 +200,7 @@ struct class {
    int (*resume)(struct device *dev);

    struct pm_ops *pm;
    + struct class_private *p;
    };

    extern struct kobject *sysfs_dev_block_kobj;
    --
    1.5.6.3

    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  4. [PATCH 30/79] device create: convert device_create_drvdata to device_create

    Now that device_create() has been audited, rename things back to the
    original call to be sane.

    Keep the device_create_drvdata macro around to make merges easier.

    Signed-off-by: Greg Kroah-Hartman
    ---
    drivers/base/core.c | 11 ++++-------
    include/linux/device.h | 9 ++++-----
    2 files changed, 8 insertions(+), 12 deletions(-)

    diff --git a/drivers/base/core.c b/drivers/base/core.c
    index 4dc0d27..9ae28aa 100644
    --- a/drivers/base/core.c
    +++ b/drivers/base/core.c
    @@ -1236,7 +1236,7 @@ error:
    EXPORT_SYMBOL_GPL(device_create_vargs);

    /**
    - * device_create_drvdata - creates a device and registers it with sysfs
    + * device_create - creates a device and registers it with sysfs
    * @class: pointer to the struct class that this device should be registered to
    * @parent: pointer to the parent struct device of this new device, if any
    * @devt: the dev_t for the char device to be added
    @@ -1257,11 +1257,8 @@ EXPORT_SYMBOL_GPL(device_create_vargs);
    * Note: the struct class passed to this function must have previously
    * been created with a call to class_create().
    */
    -struct device *device_create_drvdata(struct class *class,
    - struct device *parent,
    - dev_t devt,
    - void *drvdata,
    - const char *fmt, ...)
    +struct device *device_create(struct class *class, struct device *parent,
    + dev_t devt, void *drvdata, const char *fmt, ...)
    {
    va_list vargs;
    struct device *dev;
    @@ -1271,7 +1268,7 @@ struct device *device_create_drvdata(struct class *class,
    va_end(vargs);
    return dev;
    }
    -EXPORT_SYMBOL_GPL(device_create_drvdata);
    +EXPORT_SYMBOL_GPL(device_create);

    static int __match_devt(struct device *dev, void *data)
    {
    diff --git a/include/linux/device.h b/include/linux/device.h
    index a3ef5a2..de17871 100644
    --- a/include/linux/device.h
    +++ b/include/linux/device.h
    @@ -470,12 +470,11 @@ extern struct device *device_create_vargs(struct class *cls,
    void *drvdata,
    const char *fmt,
    va_list vargs);
    -extern struct device *device_create_drvdata(struct class *cls,
    - struct device *parent,
    - dev_t devt,
    - void *drvdata,
    - const char *fmt, ...)
    +extern struct device *device_create(struct class *cls, struct device *parent,
    + dev_t devt, void *drvdata,
    + const char *fmt, ...)
    __attribute__((format(printf, 5, 6)));
    +#define device_create_drvdata device_create
    extern void device_destroy(struct class *cls, dev_t devt);

    /*
    --
    1.5.6.3

    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  5. [PATCH 37/79] block: make proc files seq_start use the class_find_device()

    Use the proper class iterator function instead of mucking around in the
    internals of the class structures.

    Cc: Kay Sievers
    Signed-off-by: Greg Kroah-Hartman
    ---
    block/genhd.c | 31 +++++++++++++++++--------------
    1 files changed, 17 insertions(+), 14 deletions(-)

    diff --git a/block/genhd.c b/block/genhd.c
    index 68a5f28..f03bdad 100644
    --- a/block/genhd.c
    +++ b/block/genhd.c
    @@ -291,18 +291,25 @@ void __init printk_all_partitions(void)

    #ifdef CONFIG_PROC_FS
    /* iterator */
    +static int find_start(struct device *dev, void *data)
    +{
    + loff_t k = *(loff_t *)data;
    +
    + if (dev->type != &disk_type)
    + return 0;
    + if (!k--)
    + return 1;
    + return 0;
    +}
    +
    static void *part_start(struct seq_file *part, loff_t *pos)
    {
    - loff_t k = *pos;
    struct device *dev;

    mutex_lock(&block_class_lock);
    - list_for_each_entry(dev, &block_class.devices, node) {
    - if (dev->type != &disk_type)
    - continue;
    - if (!k--)
    - return dev_to_disk(dev);
    - }
    + dev = class_find_device(&block_class, NULL, (void *)pos, find_start);
    + if (dev)
    + return dev_to_disk(dev);
    return NULL;
    }

    @@ -555,16 +562,12 @@ static struct device_type disk_type = {

    static void *diskstats_start(struct seq_file *part, loff_t *pos)
    {
    - loff_t k = *pos;
    struct device *dev;

    mutex_lock(&block_class_lock);
    - list_for_each_entry(dev, &block_class.devices, node) {
    - if (dev->type != &disk_type)
    - continue;
    - if (!k--)
    - return dev_to_disk(dev);
    - }
    + dev = class_find_device(&block_class, NULL, (void *)pos, find_start);
    + if (dev)
    + return dev_to_disk(dev);
    return NULL;
    }

    --
    1.5.6.3

    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  6. [PATCH 49/79] class: add lockdep infrastructure

    From: Matthew Wilcox

    This adds the infrastructure to properly handle lockdep issues when the
    internal class semaphore is changed to a mutex.

    Matthew wrote the original patch, and Greg fixed it up to work properly
    with the class_create() function.


    From: Matthew Wilcox
    Cc: Kay Sievers
    Cc: Dave Young
    Cc: Andrew Morton
    Cc: James Bottomley
    Cc: Peter Zijlstra
    Cc: Ingo Molnar
    Signed-off-by: Greg Kroah-Hartman
    ---
    drivers/base/class.c | 11 ++++++-----
    include/linux/device.h | 25 +++++++++++++++++++++++--
    2 files changed, 29 insertions(+), 7 deletions(-)

    diff --git a/drivers/base/class.c b/drivers/base/class.c
    index d24d211..8900056 100644
    --- a/drivers/base/class.c
    +++ b/drivers/base/class.c
    @@ -134,7 +134,7 @@ static void remove_class_attrs(struct class *cls)
    }
    }

    -int class_register(struct class *cls)
    +int __class_register(struct class *cls, struct lock_class_key *key)
    {
    struct class_private *cp;
    int error;
    @@ -178,6 +178,7 @@ int class_register(struct class *cls)
    class_put(cls);
    return error;
    }
    +EXPORT_SYMBOL_GPL(__class_register);

    void class_unregister(struct class *cls)
    {
    @@ -203,7 +204,8 @@ static void class_create_release(struct class *cls)
    * Note, the pointer created here is to be destroyed when finished by
    * making a call to class_destroy().
    */
    -struct class *class_create(struct module *owner, const char *name)
    +struct class *__class_create(struct module *owner, const char *name,
    + struct lock_class_key *key)
    {
    struct class *cls;
    int retval;
    @@ -218,7 +220,7 @@ struct class *class_create(struct module *owner, const char *name)
    cls->owner = owner;
    cls->class_release = class_create_release;

    - retval = class_register(cls);
    + retval = __class_register(cls, key);
    if (retval)
    goto error;

    @@ -228,6 +230,7 @@ error:
    kfree(cls);
    return ERR_PTR(retval);
    }
    +EXPORT_SYMBOL_GPL(__class_create);

    /**
    * class_destroy - destroys a struct class structure
    @@ -412,9 +415,7 @@ int __init classes_init(void)

    EXPORT_SYMBOL_GPL(class_create_file);
    EXPORT_SYMBOL_GPL(class_remove_file);
    -EXPORT_SYMBOL_GPL(class_register);
    EXPORT_SYMBOL_GPL(class_unregister);
    -EXPORT_SYMBOL_GPL(class_create);
    EXPORT_SYMBOL_GPL(class_destroy);

    EXPORT_SYMBOL_GPL(class_interface_register);
    diff --git a/include/linux/device.h b/include/linux/device.h
    index b055608..0e1d24c 100644
    --- a/include/linux/device.h
    +++ b/include/linux/device.h
    @@ -16,6 +16,7 @@
    #include
    #include
    #include
    +#include
    #include
    #include
    #include
    @@ -205,8 +206,18 @@ struct class {

    extern struct kobject *sysfs_dev_block_kobj;
    extern struct kobject *sysfs_dev_char_kobj;
    -extern int __must_check class_register(struct class *class);
    +extern int __must_check __class_register(struct class *class,
    + struct lock_class_key *key);
    extern void class_unregister(struct class *class);
    +
    +/* This is a #define to keep the compiler from merging different
    + * instances of the __key variable */
    +#define class_register(class) \
    +({ \
    + static struct lock_class_key __key; \
    + __class_register(class, &__key); \
    +})
    +
    extern int class_for_each_device(struct class *class, struct device *start,
    void *data,
    int (*fn)(struct device *dev, void *data));
    @@ -239,9 +250,19 @@ struct class_interface {
    extern int __must_check class_interface_register(struct class_interface *);
    extern void class_interface_unregister(struct class_interface *);

    -extern struct class *class_create(struct module *owner, const char *name);
    +extern struct class * __must_check __class_create(struct module *owner,
    + const char *name,
    + struct lock_class_key *key);
    extern void class_destroy(struct class *cls);

    +/* This is a #define to keep the compiler from merging different
    + * instances of the __key variable */
    +#define class_create(owner, name) \
    +({ \
    + static struct lock_class_key __key; \
    + __class_create(owner, name, &__key); \
    +})
    +
    /*
    * The type of device, "struct device" is embedded in. A class
    * or bus can contain devices of different types
    --
    1.5.6.3

    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  7. [PATCH 29/79] driver core: remove device_create()

    There are no more users of this, and it is racy. Use
    device_create_drvdata() or device_create_vargs() instead.

    Signed-off-by: Greg Kroah-Hartman
    ---
    drivers/base/core.c | 34 ----------------------------------
    include/linux/device.h | 3 ---
    2 files changed, 0 insertions(+), 37 deletions(-)

    diff --git a/drivers/base/core.c b/drivers/base/core.c
    index be9aba4..4dc0d27 100644
    --- a/drivers/base/core.c
    +++ b/drivers/base/core.c
    @@ -1273,40 +1273,6 @@ struct device *device_create_drvdata(struct class *class,
    }
    EXPORT_SYMBOL_GPL(device_create_drvdata);

    -/**
    - * device_create - creates a device and registers it with sysfs
    - * @class: pointer to the struct class that this device should be registered to
    - * @parent: pointer to the parent struct device of this new device, if any
    - * @devt: the dev_t for the char device to be added
    - * @fmt: string for the device's name
    - *
    - * This function can be used by char device classes. A struct device
    - * will be created in sysfs, registered to the specified class.
    - *
    - * A "dev" file will be created, showing the dev_t for the device, if
    - * the dev_t is not 0,0.
    - * If a pointer to a parent struct device is passed in, the newly created
    - * struct device will be a child of that device in sysfs.
    - * The pointer to the struct device will be returned from the call.
    - * Any further sysfs files that might be required can be created using this
    - * pointer.
    - *
    - * Note: the struct class passed to this function must have previously
    - * been created with a call to class_create().
    - */
    -struct device *device_create(struct class *class, struct device *parent,
    - dev_t devt, const char *fmt, ...)
    -{
    - va_list vargs;
    - struct device *dev;
    -
    - va_start(vargs, fmt);
    - dev = device_create_vargs(class, parent, devt, NULL, fmt, vargs);
    - va_end(vargs);
    - return dev;
    -}
    -EXPORT_SYMBOL_GPL(device_create);
    -
    static int __match_devt(struct device *dev, void *data)
    {
    dev_t *devt = data;
    diff --git a/include/linux/device.h b/include/linux/device.h
    index e49aa74..a3ef5a2 100644
    --- a/include/linux/device.h
    +++ b/include/linux/device.h
    @@ -470,9 +470,6 @@ extern struct device *device_create_vargs(struct class *cls,
    void *drvdata,
    const char *fmt,
    va_list vargs);
    -extern struct device *device_create(struct class *cls, struct device *parent,
    - dev_t devt, const char *fmt, ...)
    - __attribute__((format(printf, 4, 5)));
    extern struct device *device_create_drvdata(struct class *cls,
    struct device *parent,
    dev_t devt,
    --
    1.5.6.3

    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  8. [PATCH 46/79] class: rename "subsys" to "class_subsys" in internal class structure

    This renames the struct class "subsys" field to be "class_subsys" to
    make things easier when struct bus_type and struct class merge in the
    future. It also makes grepping for fields easier as well.

    Based on an idea from Kay.

    Cc: Kay Sievers
    Signed-off-by: Greg Kroah-Hartman
    ---
    drivers/base/base.h | 7 ++++---
    drivers/base/class.c | 23 ++++++++++++-----------
    drivers/base/core.c | 31 +++++++++++++++++--------------
    3 files changed, 33 insertions(+), 28 deletions(-)

    diff --git a/drivers/base/base.h b/drivers/base/base.h
    index 670b95a..a77d4bd 100644
    --- a/drivers/base/base.h
    +++ b/drivers/base/base.h
    @@ -40,7 +40,7 @@ struct driver_private {
    /**
    * struct class_private - structure to hold the private to the driver core portions of the class structure.
    *
    - * @subsys - the struct kset that defines this class. This is the main kobject
    + * @class_subsys - the struct kset that defines this class. This is the main kobject
    * @children - list of class_devices associated with this class
    * @class_devices - list of devices associated with this class
    * @class_interfaces - list of class_interfaces associated with this class
    @@ -54,14 +54,15 @@ struct driver_private {
    * core should ever touch these fields.
    */
    struct class_private {
    - struct kset subsys;
    + struct kset class_subsys;
    struct list_head class_devices;
    struct list_head class_interfaces;
    struct kset class_dirs;
    struct semaphore sem;
    struct class *class;
    };
    -#define to_class(obj) container_of(obj, struct class_private, subsys.kobj)
    +#define to_class(obj) \
    + container_of(obj, struct class_private, class_subsys.kobj)

    /* initialisation functions */
    extern int devices_init(void);
    diff --git a/drivers/base/class.c b/drivers/base/class.c
    index 48b518e..86778b8 100644
    --- a/drivers/base/class.c
    +++ b/drivers/base/class.c
    @@ -70,7 +70,7 @@ static struct kobj_type class_ktype = {
    .release = class_release,
    };

    -/* Hotplug events for classes go to the class_obj subsys */
    +/* Hotplug events for classes go to the class class_subsys */
    static struct kset *class_kset;


    @@ -78,7 +78,8 @@ int class_create_file(struct class *cls, const struct class_attribute *attr)
    {
    int error;
    if (cls)
    - error = sysfs_create_file(&cls->p->subsys.kobj, &attr->attr);
    + error = sysfs_create_file(&cls->p->class_subsys.kobj,
    + &attr->attr);
    else
    error = -EINVAL;
    return error;
    @@ -87,20 +88,20 @@ int class_create_file(struct class *cls, const struct class_attribute *attr)
    void class_remove_file(struct class *cls, const struct class_attribute *attr)
    {
    if (cls)
    - sysfs_remove_file(&cls->p->subsys.kobj, &attr->attr);
    + sysfs_remove_file(&cls->p->class_subsys.kobj, &attr->attr);
    }

    static struct class *class_get(struct class *cls)
    {
    if (cls)
    - kset_get(&cls->p->subsys);
    + kset_get(&cls->p->class_subsys);
    return cls;
    }

    static void class_put(struct class *cls)
    {
    if (cls)
    - kset_put(&cls->p->subsys);
    + kset_put(&cls->p->class_subsys);
    }

    static int add_class_attrs(struct class *cls)
    @@ -147,7 +148,7 @@ int class_register(struct class *cls)
    INIT_LIST_HEAD(&cp->class_interfaces);
    kset_init(&cp->class_dirs);
    init_MUTEX(&cp->sem);
    - error = kobject_set_name(&cp->subsys.kobj, "%s", cls->name);
    + error = kobject_set_name(&cp->class_subsys.kobj, "%s", cls->name);
    if (error) {
    kfree(cp);
    return error;
    @@ -160,15 +161,15 @@ int class_register(struct class *cls)
    #if defined(CONFIG_SYSFS_DEPRECATED) && defined(CONFIG_BLOCK)
    /* let the block class directory show up in the root of sysfs */
    if (cls != &block_class)
    - cp->subsys.kobj.kset = class_kset;
    + cp->class_subsys.kobj.kset = class_kset;
    #else
    - cp->subsys.kobj.kset = class_kset;
    + cp->class_subsys.kobj.kset = class_kset;
    #endif
    - cp->subsys.kobj.ktype = &class_ktype;
    + cp->class_subsys.kobj.ktype = &class_ktype;
    cp->class = cls;
    cls->p = cp;

    - error = kset_register(&cp->subsys);
    + error = kset_register(&cp->class_subsys);
    if (error) {
    kfree(cp);
    return error;
    @@ -182,7 +183,7 @@ void class_unregister(struct class *cls)
    {
    pr_debug("device class '%s': unregistering\n", cls->name);
    remove_class_attrs(cls);
    - kset_unregister(&cls->p->subsys);
    + kset_unregister(&cls->p->class_subsys);
    }

    static void class_create_release(struct class *cls)
    diff --git a/drivers/base/core.c b/drivers/base/core.c
    index 76fdd41..6e1cff2 100644
    --- a/drivers/base/core.c
    +++ b/drivers/base/core.c
    @@ -551,7 +551,7 @@ static struct kobject *get_device_parent(struct device *dev,
    {
    /* class devices without a parent live in /sys/class// */
    if (dev->class && (!parent || parent->class != dev->class))
    - return &dev->class->p->subsys.kobj;
    + return &dev->class->p->class_subsys.kobj;
    /* all other devices keep their parent */
    else if (parent)
    return &parent->kobj;
    @@ -657,16 +657,17 @@ static int device_add_class_symlinks(struct device *dev)
    if (!dev->class)
    return 0;

    - error = sysfs_create_link(&dev->kobj, &dev->class->p->subsys.kobj,
    + error = sysfs_create_link(&dev->kobj,
    + &dev->class->p->class_subsys.kobj,
    "subsystem");
    if (error)
    goto out;

    #ifdef CONFIG_SYSFS_DEPRECATED
    /* stacked class devices need a symlink in the class directory */
    - if (dev->kobj.parent != &dev->class->p->subsys.kobj &&
    + if (dev->kobj.parent != &dev->class->p->class_subsys.kobj &&
    device_is_not_partition(dev)) {
    - error = sysfs_create_link(&dev->class->p->subsys.kobj,
    + error = sysfs_create_link(&dev->class->p->class_subsys.kobj,
    &dev->kobj, dev->bus_id);
    if (error)
    goto out_subsys;
    @@ -704,13 +705,14 @@ out_device:
    if (dev->parent && device_is_not_partition(dev))
    sysfs_remove_link(&dev->kobj, "device");
    out_busid:
    - if (dev->kobj.parent != &dev->class->p->subsys.kobj &&
    + if (dev->kobj.parent != &dev->class->p->class_subsys.kobj &&
    device_is_not_partition(dev))
    - sysfs_remove_link(&dev->class->p->subsys.kobj, dev->bus_id);
    + sysfs_remove_link(&dev->class->p->class_subsys.kobj,
    + dev->bus_id);
    #else
    /* link in the class directory pointing to the device */
    - error = sysfs_create_link(&dev->class->p->subsys.kobj, &dev->kobj,
    - dev->bus_id);
    + error = sysfs_create_link(&dev->class->p->class_subsys.kobj,
    + &dev->kobj, dev->bus_id);
    if (error)
    goto out_subsys;

    @@ -723,7 +725,7 @@ out_busid:
    return 0;

    out_busid:
    - sysfs_remove_link(&dev->class->p->subsys.kobj, dev->bus_id);
    + sysfs_remove_link(&dev->class->p->class_subsys.kobj, dev->bus_id);
    #endif

    out_subsys:
    @@ -749,14 +751,15 @@ static void device_remove_class_symlinks(struct device *dev)
    sysfs_remove_link(&dev->kobj, "device");
    }

    - if (dev->kobj.parent != &dev->class->p->subsys.kobj &&
    + if (dev->kobj.parent != &dev->class->p->class_subsys.kobj &&
    device_is_not_partition(dev))
    - sysfs_remove_link(&dev->class->p->subsys.kobj, dev->bus_id);
    + sysfs_remove_link(&dev->class->p->class_subsys.kobj,
    + dev->bus_id);
    #else
    if (dev->parent && device_is_not_partition(dev))
    sysfs_remove_link(&dev->kobj, "device");

    - sysfs_remove_link(&dev->class->p->subsys.kobj, dev->bus_id);
    + sysfs_remove_link(&dev->class->p->class_subsys.kobj, dev->bus_id);
    #endif

    sysfs_remove_link(&dev->kobj, "subsystem");
    @@ -1350,11 +1353,11 @@ int device_rename(struct device *dev, char *new_name)
    }
    #else
    if (dev->class) {
    - error = sysfs_create_link(&dev->class->p->subsys.kobj,
    + error = sysfs_create_link(&dev->class->p->class_subsys.kobj,
    &dev->kobj, dev->bus_id);
    if (error)
    goto out;
    - sysfs_remove_link(&dev->class->p->subsys.kobj,
    + sysfs_remove_link(&dev->class->p->class_subsys.kobj,
    old_device_name);
    }
    #endif
    --
    1.5.6.3

    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  9. [PATCH 26/79] device create: spi: convert device_create to device_create_drvdata

    From: David Brownell

    Switch over to use the shiny new device_create_drvdata() call
    instead of the original device_create() calls, so this continues
    to work after device_create() is removed.

    Note that this driver never had the race which motivated removing
    the original call; it locked correctly.

    Signed-off-by: David Brownell
    Signed-off-by: Greg Kroah-Hartman
    ---
    drivers/spi/spidev.c | 4 ++--
    1 files changed, 2 insertions(+), 2 deletions(-)

    diff --git a/drivers/spi/spidev.c b/drivers/spi/spidev.c
    index ddbe1a5..2833fd7 100644
    --- a/drivers/spi/spidev.c
    +++ b/drivers/spi/spidev.c
    @@ -576,7 +576,8 @@ static int spidev_probe(struct spi_device *spi)
    struct device *dev;

    spidev->devt = MKDEV(SPIDEV_MAJOR, minor);
    - dev = device_create(spidev_class, &spi->dev, spidev->devt,
    + dev = device_create_drvdata(spidev_class, &spi->dev,
    + spidev->devt, spidev,
    "spidev%d.%d",
    spi->master->bus_num, spi->chip_select);
    status = IS_ERR(dev) ? PTR_ERR(dev) : 0;
    @@ -586,7 +587,6 @@ static int spidev_probe(struct spi_device *spi)
    }
    if (status == 0) {
    set_bit(minor, minors);
    - spi_set_drvdata(spi, spidev);
    list_add(&spidev->device_entry, &device_list);
    }
    mutex_unlock(&device_list_lock);
    --
    1.5.6.3

    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  10. [PATCH 32/79] Driver Core: add ability for class_find_device to start in middle of list

    This mirrors the functionality that driver_find_device has as well.

    We add a start variable, and all callers of the function are fixed up at
    the same time.

    The block layer will be using this new functionality in a follow-on
    patch.


    Cc: Kay Sievers
    Signed-off-by: Greg Kroah-Hartman
    ---
    drivers/base/class.c | 22 +++++++++++++---------
    drivers/base/core.c | 2 +-
    drivers/ieee1394/nodemgr.c | 9 ++++++---
    drivers/rtc/interface.c | 2 +-
    drivers/scsi/hosts.c | 3 ++-
    drivers/scsi/scsi_transport_iscsi.c | 4 ++--
    drivers/spi/spi.c | 2 +-
    include/linux/device.h | 3 ++-
    8 files changed, 28 insertions(+), 19 deletions(-)

    diff --git a/drivers/base/class.c b/drivers/base/class.c
    index 2eb7048..3918d0e 100644
    --- a/drivers/base/class.c
    +++ b/drivers/base/class.c
    @@ -302,6 +302,7 @@ EXPORT_SYMBOL_GPL(class_for_each_device);
    /**
    * class_find_device - device iterator for locating a particular device
    * @class: the class we're iterating
    + * @start: Device to begin with
    * @data: data for the match function
    * @match: function to check device
    *
    @@ -319,8 +320,9 @@ EXPORT_SYMBOL_GPL(class_for_each_device);
    * re-acquired in @match, otherwise it will self-deadlocking. For
    * example, calls to add or remove class members would be verboten.
    */
    -struct device *class_find_device(struct class *class, void *data,
    - int (*match)(struct device *, void *))
    +struct device *class_find_device(struct class *class, struct device *start,
    + void *data,
    + int (*match)(struct device *, void *))
    {
    struct device *dev;
    int found = 0;
    @@ -330,15 +332,17 @@ struct device *class_find_device(struct class *class, void *data,

    down(&class->sem);
    list_for_each_entry(dev, &class->devices, node) {
    + if (start) {
    + if (start == dev)
    + start = NULL;
    + continue;
    + }
    dev = get_device(dev);
    - if (dev) {
    - if (match(dev, data)) {
    - found = 1;
    - break;
    - } else
    - put_device(dev);
    - } else
    + if (match(dev, data)) {
    + found = 1;
    break;
    + } else
    + put_device(dev);
    }
    up(&class->sem);

    diff --git a/drivers/base/core.c b/drivers/base/core.c
    index 9ae28aa..9f05de6 100644
    --- a/drivers/base/core.c
    +++ b/drivers/base/core.c
    @@ -1289,7 +1289,7 @@ void device_destroy(struct class *class, dev_t devt)
    {
    struct device *dev;

    - dev = class_find_device(class, &devt, __match_devt);
    + dev = class_find_device(class, NULL, &devt, __match_devt);
    if (dev) {
    put_device(dev);
    device_unregister(dev);
    diff --git a/drivers/ieee1394/nodemgr.c b/drivers/ieee1394/nodemgr.c
    index 47c0d85..994a21e 100644
    --- a/drivers/ieee1394/nodemgr.c
    +++ b/drivers/ieee1394/nodemgr.c
    @@ -754,7 +754,8 @@ static void nodemgr_remove_uds(struct node_entry *ne)
    */
    mutex_lock(&nodemgr_serialize_remove_uds);
    for (; {
    - dev = class_find_device(&nodemgr_ud_class, ne, __match_ne);
    + dev = class_find_device(&nodemgr_ud_class, NULL, ne,
    + __match_ne);
    if (!dev)
    break;
    ud = container_of(dev, struct unit_directory, unit_dev);
    @@ -901,7 +902,8 @@ static struct node_entry *find_entry_by_guid(u64 guid)
    struct device *dev;
    struct node_entry *ne;

    - dev = class_find_device(&nodemgr_ne_class, &guid, __match_ne_guid);
    + dev = class_find_device(&nodemgr_ne_class, NULL, &guid,
    + __match_ne_guid);
    if (!dev)
    return NULL;
    ne = container_of(dev, struct node_entry, node_dev);
    @@ -940,7 +942,8 @@ static struct node_entry *find_entry_by_nodeid(struct hpsb_host *host,
    param.host = host;
    param.nodeid = nodeid;

    - dev = class_find_device(&nodemgr_ne_class, &param, __match_ne_nodeid);
    + dev = class_find_device(&nodemgr_ne_class, NULL, &param,
    + __match_ne_nodeid);
    if (!dev)
    return NULL;
    ne = container_of(dev, struct node_entry, node_dev);
    diff --git a/drivers/rtc/interface.c b/drivers/rtc/interface.c
    index 58b7336..d397fa5 100644
    --- a/drivers/rtc/interface.c
    +++ b/drivers/rtc/interface.c
    @@ -345,7 +345,7 @@ struct rtc_device *rtc_class_open(char *name)
    struct device *dev;
    struct rtc_device *rtc = NULL;

    - dev = class_find_device(rtc_class, name, __rtc_match);
    + dev = class_find_device(rtc_class, NULL, name, __rtc_match);
    if (dev)
    rtc = to_rtc_device(dev);

    diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
    index 35cd892..78dad28 100644
    --- a/drivers/scsi/hosts.c
    +++ b/drivers/scsi/hosts.c
    @@ -466,7 +466,8 @@ struct Scsi_Host *scsi_host_lookup(unsigned short hostnum)
    struct device *cdev;
    struct Scsi_Host *shost = ERR_PTR(-ENXIO);

    - cdev = class_find_device(&shost_class, &hostnum, __scsi_host_match);
    + cdev = class_find_device(&shost_class, NULL, &hostnum,
    + __scsi_host_match);
    if (cdev) {
    shost = scsi_host_get(class_to_shost(cdev));
    put_device(cdev);
    diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
    index 3af7cbc..06748f3 100644
    --- a/drivers/scsi/scsi_transport_iscsi.c
    +++ b/drivers/scsi/scsi_transport_iscsi.c
    @@ -170,7 +170,7 @@ iscsi_create_endpoint(int dd_size)
    int err;

    for (id = 1; id < ISCSI_MAX_EPID; id++) {
    - dev = class_find_device(&iscsi_endpoint_class, &id,
    + dev = class_find_device(&iscsi_endpoint_class, NULL, &id,
    iscsi_match_epid);
    if (!dev)
    break;
    @@ -222,7 +222,7 @@ struct iscsi_endpoint *iscsi_lookup_endpoint(u64 handle)
    struct iscsi_endpoint *ep;
    struct device *dev;

    - dev = class_find_device(&iscsi_endpoint_class, &handle,
    + dev = class_find_device(&iscsi_endpoint_class, NULL, &handle,
    iscsi_match_epid);
    if (!dev)
    return NULL;
    diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
    index 1ad12af..1771b24 100644
    --- a/drivers/spi/spi.c
    +++ b/drivers/spi/spi.c
    @@ -502,7 +502,7 @@ struct spi_master *spi_busnum_to_master(u16 bus_num)
    struct device *dev;
    struct spi_master *master = NULL;

    - dev = class_find_device(&spi_master_class, &bus_num,
    + dev = class_find_device(&spi_master_class, NULL, &bus_num,
    __spi_master_match);
    if (dev)
    master = container_of(dev, struct spi_master, dev);
    diff --git a/include/linux/device.h b/include/linux/device.h
    index 6d5b351..c1f7298 100644
    --- a/include/linux/device.h
    +++ b/include/linux/device.h
    @@ -213,7 +213,8 @@ extern void class_unregister(struct class *class);
    extern int class_for_each_device(struct class *class, struct device *start,
    void *data,
    int (*fn)(struct device *dev, void *data));
    -extern struct device *class_find_device(struct class *class, void *data,
    +extern struct device *class_find_device(struct class *class,
    + struct device *start, void *data,
    int (*match)(struct device *, void *));

    struct class_attribute {
    --
    1.5.6.3

    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  11. [PATCH 41/79] infiniband: make cm_device use a struct device and not a kobject.

    This object really should be a struct device, or at least contain a
    pointer to a struct device, as it is trying to create a separate device
    tree outside of the main device tree. This patch fixes this problem.

    It is needed for the class core rework that is being done in the driver
    core.

    Cc: Kay Sievers
    Cc: Roland Dreier
    Cc: Sean Hefty
    Cc: Hal Rosenstock
    Signed-off-by: Greg Kroah-Hartman
    ---
    drivers/infiniband/core/cm.c | 29 +++++++++--------------------
    1 files changed, 9 insertions(+), 20 deletions(-)

    diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c
    index 8dc4429..922d35f 100644
    --- a/drivers/infiniband/core/cm.c
    +++ b/drivers/infiniband/core/cm.c
    @@ -44,6 +44,7 @@
    #include
    #include
    #include
    +#include

    #include
    #include
    @@ -163,7 +164,7 @@ struct cm_port {
    struct cm_device {
    struct list_head list;
    struct ib_device *ib_device;
    - struct kobject dev_obj;
    + struct device *device;
    u8 ack_delay;
    struct cm_port *port[0];
    };
    @@ -3618,18 +3619,6 @@ static struct kobj_type cm_port_obj_type = {
    .release = cm_release_port_obj
    };

    -static void cm_release_dev_obj(struct kobject *obj)
    -{
    - struct cm_device *cm_dev;
    -
    - cm_dev = container_of(obj, struct cm_device, dev_obj);
    - kfree(cm_dev);
    -}
    -
    -static struct kobj_type cm_dev_obj_type = {
    - .release = cm_release_dev_obj
    -};
    -
    struct class cm_class = {
    .name = "infiniband_cm",
    };
    @@ -3640,7 +3629,7 @@ static int cm_create_port_fs(struct cm_port *port)
    int i, ret;

    ret = kobject_init_and_add(&port->port_obj, &cm_port_obj_type,
    - &port->cm_dev->dev_obj,
    + &port->cm_dev->device->kobj,
    "%d", port->port_num);
    if (ret) {
    kfree(port);
    @@ -3702,10 +3691,10 @@ static void cm_add_one(struct ib_device *ib_device)
    cm_dev->ib_device = ib_device;
    cm_get_ack_delay(cm_dev);

    - ret = kobject_init_and_add(&cm_dev->dev_obj, &cm_dev_obj_type,
    - &cm_class.subsys.kobj, "%s",
    - ib_device->name);
    - if (ret) {
    + cm_dev->device = device_create_drvdata(&cm_class, &ib_device->dev,
    + MKDEV(0, 0), NULL,
    + "%s", ib_device->name);
    + if (!cm_dev->device) {
    kfree(cm_dev);
    return;
    }
    @@ -3758,7 +3747,7 @@ error1:
    ib_unregister_mad_agent(port->mad_agent);
    cm_remove_port_fs(port);
    }
    - kobject_put(&cm_dev->dev_obj);
    + device_unregister(cm_dev->device);
    }

    static void cm_remove_one(struct ib_device *ib_device)
    @@ -3786,7 +3775,7 @@ static void cm_remove_one(struct ib_device *ib_device)
    flush_workqueue(cm.wq);
    cm_remove_port_fs(port);
    }
    - kobject_put(&cm_dev->dev_obj);
    + device_unregister(cm_dev->device);
    }

    static int __init ib_cm_init(void)
    --
    1.5.6.3

    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  12. [PATCH 50/79] class: change internal semaphore to a mutex

    From: Dave Young

    Now that the lockdep infrastructure in the class core is in place, we
    should be able to properly change the internal class semaphore to be a
    mutex.

    David wrote the original patch, and Greg fixed it up to apply properly
    due to all of the recent changes in this area.

    From: Dave Young
    Cc: Matthew Wilcox
    Cc: Kay Sievers
    Cc: Andrew Morton
    Cc: James Bottomley
    Signed-off-by: Greg Kroah-Hartman
    ---
    drivers/base/base.h | 4 ++--
    drivers/base/class.c | 23 ++++++++++++-----------
    drivers/base/core.c | 9 +++++----
    3 files changed, 19 insertions(+), 17 deletions(-)

    diff --git a/drivers/base/base.h b/drivers/base/base.h
    index c035dc2..31dc0cd 100644
    --- a/drivers/base/base.h
    +++ b/drivers/base/base.h
    @@ -44,7 +44,7 @@ struct driver_private {
    * @class_devices - list of devices associated with this class
    * @class_interfaces - list of class_interfaces associated with this class
    * @class_dirs - "glue" directory for virtual devices associated with this class
    - * @class_sem - semaphore to protect the children, devices, and interfaces lists.
    + * @class_mutex - mutex to protect the children, devices, and interfaces lists.
    * @class - pointer back to the struct class that this structure is associated
    * with.
    *
    @@ -57,7 +57,7 @@ struct class_private {
    struct list_head class_devices;
    struct list_head class_interfaces;
    struct kset class_dirs;
    - struct semaphore class_sem;
    + struct mutex class_mutex;
    struct class *class;
    };
    #define to_class(obj) \
    diff --git a/drivers/base/class.c b/drivers/base/class.c
    index 8900056..839d27c 100644
    --- a/drivers/base/class.c
    +++ b/drivers/base/class.c
    @@ -18,6 +18,7 @@
    #include
    #include
    #include
    +#include
    #include "base.h"

    #define to_class_attr(_attr) container_of(_attr, struct class_attribute, attr)
    @@ -147,7 +148,7 @@ int __class_register(struct class *cls, struct lock_class_key *key)
    INIT_LIST_HEAD(&cp->class_devices);
    INIT_LIST_HEAD(&cp->class_interfaces);
    kset_init(&cp->class_dirs);
    - init_MUTEX(&cp->class_sem);
    + __mutex_init(&cp->class_mutex, "struct class mutex", key);
    error = kobject_set_name(&cp->class_subsys.kobj, "%s", cls->name);
    if (error) {
    kfree(cp);
    @@ -281,7 +282,7 @@ char *make_class_name(const char *name, struct kobject *kobj)
    * We check the return of @fn each time. If it returns anything
    * other than 0, we break out and return that value.
    *
    - * Note, we hold class->class_sem in this function, so it can not be
    + * Note, we hold class->class_mutex in this function, so it can not be
    * re-acquired in @fn, otherwise it will self-deadlocking. For
    * example, calls to add or remove class members would be verboten.
    */
    @@ -293,7 +294,7 @@ int class_for_each_device(struct class *class, struct device *start,

    if (!class)
    return -EINVAL;
    - down(&class->p->class_sem);
    + mutex_lock(&class->p->class_mutex);
    list_for_each_entry(dev, &class->p->class_devices, node) {
    if (start) {
    if (start == dev)
    @@ -306,7 +307,7 @@ int class_for_each_device(struct class *class, struct device *start,
    if (error)
    break;
    }
    - up(&class->p->class_sem);
    + mutex_unlock(&class->p->class_mutex);

    return error;
    }
    @@ -329,7 +330,7 @@ EXPORT_SYMBOL_GPL(class_for_each_device);
    *
    * Note, you will need to drop the reference with put_device() after use.
    *
    - * We hold class->class_sem in this function, so it can not be
    + * We hold class->class_mutex in this function, so it can not be
    * re-acquired in @match, otherwise it will self-deadlocking. For
    * example, calls to add or remove class members would be verboten.
    */
    @@ -343,7 +344,7 @@ struct device *class_find_device(struct class *class, struct device *start,
    if (!class)
    return NULL;

    - down(&class->p->class_sem);
    + mutex_lock(&class->p->class_mutex);
    list_for_each_entry(dev, &class->p->class_devices, node) {
    if (start) {
    if (start == dev)
    @@ -357,7 +358,7 @@ struct device *class_find_device(struct class *class, struct device *start,
    } else
    put_device(dev);
    }
    - up(&class->p->class_sem);
    + mutex_unlock(&class->p->class_mutex);

    return found ? dev : NULL;
    }
    @@ -375,13 +376,13 @@ int class_interface_register(struct class_interface *class_intf)
    if (!parent)
    return -EINVAL;

    - down(&parent->p->class_sem);
    + mutex_lock(&parent->p->class_mutex);
    list_add_tail(&class_intf->node, &parent->p->class_interfaces);
    if (class_intf->add_dev) {
    list_for_each_entry(dev, &parent->p->class_devices, node)
    class_intf->add_dev(dev, class_intf);
    }
    - up(&parent->p->class_sem);
    + mutex_unlock(&parent->p->class_mutex);

    return 0;
    }
    @@ -394,13 +395,13 @@ void class_interface_unregister(struct class_interface *class_intf)
    if (!parent)
    return;

    - down(&parent->p->class_sem);
    + mutex_lock(&parent->p->class_mutex);
    list_del_init(&class_intf->node);
    if (class_intf->remove_dev) {
    list_for_each_entry(dev, &parent->p->class_devices, node)
    class_intf->remove_dev(dev, class_intf);
    }
    - up(&parent->p->class_sem);
    + mutex_unlock(&parent->p->class_mutex);

    class_put(parent);
    }
    diff --git a/drivers/base/core.c b/drivers/base/core.c
    index b90ae6f..c05b115 100644
    --- a/drivers/base/core.c
    +++ b/drivers/base/core.c
    @@ -21,6 +21,7 @@
    #include
    #include
    #include
    +#include

    #include "base.h"
    #include "power/power.h"
    @@ -907,7 +908,7 @@ int device_add(struct device *dev)
    klist_add_tail(&dev->knode_parent, &parent->klist_children);

    if (dev->class) {
    - down(&dev->class->p->class_sem);
    + mutex_lock(&dev->class->p->class_mutex);
    /* tie the class to the device */
    list_add_tail(&dev->node, &dev->class->p->class_devices);

    @@ -916,7 +917,7 @@ int device_add(struct device *dev)
    &dev->class->p->class_interfaces, node)
    if (class_intf->add_dev)
    class_intf->add_dev(dev, class_intf);
    - up(&dev->class->p->class_sem);
    + mutex_unlock(&dev->class->p->class_mutex);
    }
    Done:
    put_device(dev);
    @@ -1017,7 +1018,7 @@ void device_del(struct device *dev)
    if (dev->class) {
    device_remove_class_symlinks(dev);

    - down(&dev->class->p->class_sem);
    + mutex_lock(&dev->class->p->class_mutex);
    /* notify any interfaces that the device is now gone */
    list_for_each_entry(class_intf,
    &dev->class->p->class_interfaces, node)
    @@ -1025,7 +1026,7 @@ void device_del(struct device *dev)
    class_intf->remove_dev(dev, class_intf);
    /* remove the device from the class list */
    list_del_init(&dev->node);
    - up(&dev->class->p->class_sem);
    + mutex_unlock(&dev->class->p->class_mutex);
    }
    device_remove_file(dev, &uevent_attr);
    device_remove_attrs(dev);
    --
    1.5.6.3

    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  13. [PATCH 40/79] infiniband: rename "device" to "ib_device" in cm_device

    This pointer really is a struct ib_device, not a struct device, so name
    it properly to help prevent confusion.

    This makes the followon patch in this series much smaller and easier to
    understand as well.

    Cc: Kay Sievers
    Cc: Roland Dreier
    Cc: Hal Rosenstock
    Acked-by: Sean Hefty
    Signed-off-by: Greg Kroah-Hartman
    ---
    drivers/infiniband/core/cm.c | 47 +++++++++++++++++++++--------------------
    1 files changed, 24 insertions(+), 23 deletions(-)

    diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c
    index 55738ee..8dc4429 100644
    --- a/drivers/infiniband/core/cm.c
    +++ b/drivers/infiniband/core/cm.c
    @@ -162,7 +162,7 @@ struct cm_port {

    struct cm_device {
    struct list_head list;
    - struct ib_device *device;
    + struct ib_device *ib_device;
    struct kobject dev_obj;
    u8 ack_delay;
    struct cm_port *port[0];
    @@ -339,7 +339,7 @@ static void cm_init_av_for_response(struct cm_port *port, struct ib_wc *wc,
    {
    av->port = port;
    av->pkey_index = wc->pkey_index;
    - ib_init_ah_from_wc(port->cm_dev->device, port->port_num, wc,
    + ib_init_ah_from_wc(port->cm_dev->ib_device, port->port_num, wc,
    grh, &av->ah_attr);
    }

    @@ -353,7 +353,7 @@ static int cm_init_av_by_path(struct ib_sa_path_rec *path, struct cm_av *av)

    read_lock_irqsave(&cm.device_lock, flags);
    list_for_each_entry(cm_dev, &cm.device_list, list) {
    - if (!ib_find_cached_gid(cm_dev->device, &path->sgid,
    + if (!ib_find_cached_gid(cm_dev->ib_device, &path->sgid,
    &p, NULL)) {
    port = cm_dev->port[p-1];
    break;
    @@ -364,13 +364,13 @@ static int cm_init_av_by_path(struct ib_sa_path_rec *path, struct cm_av *av)
    if (!port)
    return -EINVAL;

    - ret = ib_find_cached_pkey(cm_dev->device, port->port_num,
    + ret = ib_find_cached_pkey(cm_dev->ib_device, port->port_num,
    be16_to_cpu(path->pkey), &av->pkey_index);
    if (ret)
    return ret;

    av->port = port;
    - ib_init_ah_from_path(cm_dev->device, port->port_num, path,
    + ib_init_ah_from_path(cm_dev->ib_device, port->port_num, path,
    &av->ah_attr);
    av->timeout = path->packet_life_time + 1;
    return 0;
    @@ -1515,7 +1515,7 @@ static int cm_req_handler(struct cm_work *work)

    req_msg = (struct cm_req_msg *)work->mad_recv_wc->recv_buf.mad;

    - cm_id = ib_create_cm_id(work->port->cm_dev->device, NULL, NULL);
    + cm_id = ib_create_cm_id(work->port->cm_dev->ib_device, NULL, NULL);
    if (IS_ERR(cm_id))
    return PTR_ERR(cm_id);

    @@ -1550,7 +1550,7 @@ static int cm_req_handler(struct cm_work *work)
    cm_format_paths_from_req(req_msg, &work->path[0], &work->path[1]);
    ret = cm_init_av_by_path(&work->path[0], &cm_id_priv->av);
    if (ret) {
    - ib_get_cached_gid(work->port->cm_dev->device,
    + ib_get_cached_gid(work->port->cm_dev->ib_device,
    work->port->port_num, 0, &work->path[0].sgid);
    ib_send_cm_rej(cm_id, IB_CM_REJ_INVALID_GID,
    &work->path[0].sgid, sizeof work->path[0].sgid,
    @@ -2950,7 +2950,7 @@ static int cm_sidr_req_handler(struct cm_work *work)
    struct cm_sidr_req_msg *sidr_req_msg;
    struct ib_wc *wc;

    - cm_id = ib_create_cm_id(work->port->cm_dev->device, NULL, NULL);
    + cm_id = ib_create_cm_id(work->port->cm_dev->ib_device, NULL, NULL);
    if (IS_ERR(cm_id))
    return PTR_ERR(cm_id);
    cm_id_priv = container_of(cm_id, struct cm_id_private, id);
    @@ -3578,7 +3578,7 @@ static void cm_get_ack_delay(struct cm_device *cm_dev)
    {
    struct ib_device_attr attr;

    - if (ib_query_device(cm_dev->device, &attr))
    + if (ib_query_device(cm_dev->ib_device, &attr))
    cm_dev->ack_delay = 0; /* acks will rely on packet life time */
    else
    cm_dev->ack_delay = attr.local_ca_ack_delay;
    @@ -3676,7 +3676,7 @@ static void cm_remove_port_fs(struct cm_port *port)
    kobject_put(&port->port_obj);
    }

    -static void cm_add_one(struct ib_device *device)
    +static void cm_add_one(struct ib_device *ib_device)
    {
    struct cm_device *cm_dev;
    struct cm_port *port;
    @@ -3691,26 +3691,27 @@ static void cm_add_one(struct ib_device *device)
    int ret;
    u8 i;

    - if (rdma_node_get_transport(device->node_type) != RDMA_TRANSPORT_IB)
    + if (rdma_node_get_transport(ib_device->node_type) != RDMA_TRANSPORT_IB)
    return;

    cm_dev = kzalloc(sizeof(*cm_dev) + sizeof(*port) *
    - device->phys_port_cnt, GFP_KERNEL);
    + ib_device->phys_port_cnt, GFP_KERNEL);
    if (!cm_dev)
    return;

    - cm_dev->device = device;
    + cm_dev->ib_device = ib_device;
    cm_get_ack_delay(cm_dev);

    ret = kobject_init_and_add(&cm_dev->dev_obj, &cm_dev_obj_type,
    - &cm_class.subsys.kobj, "%s", device->name);
    + &cm_class.subsys.kobj, "%s",
    + ib_device->name);
    if (ret) {
    kfree(cm_dev);
    return;
    }

    set_bit(IB_MGMT_METHOD_SEND, reg_req.method_mask);
    - for (i = 1; i <= device->phys_port_cnt; i++) {
    + for (i = 1; i <= ib_device->phys_port_cnt; i++) {
    port = kzalloc(sizeof *port, GFP_KERNEL);
    if (!port)
    goto error1;
    @@ -3723,7 +3724,7 @@ static void cm_add_one(struct ib_device *device)
    if (ret)
    goto error1;

    - port->mad_agent = ib_register_mad_agent(device, i,
    + port->mad_agent = ib_register_mad_agent(ib_device, i,
    IB_QPT_GSI,
    &reg_req,
    0,
    @@ -3733,11 +3734,11 @@ static void cm_add_one(struct ib_device *device)
    if (IS_ERR(port->mad_agent))
    goto error2;

    - ret = ib_modify_port(device, i, 0, &port_modify);
    + ret = ib_modify_port(ib_device, i, 0, &port_modify);
    if (ret)
    goto error3;
    }
    - ib_set_client_data(device, &cm_client, cm_dev);
    + ib_set_client_data(ib_device, &cm_client, cm_dev);

    write_lock_irqsave(&cm.device_lock, flags);
    list_add_tail(&cm_dev->list, &cm.device_list);
    @@ -3753,14 +3754,14 @@ error1:
    port_modify.clr_port_cap_mask = IB_PORT_CM_SUP;
    while (--i) {
    port = cm_dev->port[i-1];
    - ib_modify_port(device, port->port_num, 0, &port_modify);
    + ib_modify_port(ib_device, port->port_num, 0, &port_modify);
    ib_unregister_mad_agent(port->mad_agent);
    cm_remove_port_fs(port);
    }
    kobject_put(&cm_dev->dev_obj);
    }

    -static void cm_remove_one(struct ib_device *device)
    +static void cm_remove_one(struct ib_device *ib_device)
    {
    struct cm_device *cm_dev;
    struct cm_port *port;
    @@ -3770,7 +3771,7 @@ static void cm_remove_one(struct ib_device *device)
    unsigned long flags;
    int i;

    - cm_dev = ib_get_client_data(device, &cm_client);
    + cm_dev = ib_get_client_data(ib_device, &cm_client);
    if (!cm_dev)
    return;

    @@ -3778,9 +3779,9 @@ static void cm_remove_one(struct ib_device *device)
    list_del(&cm_dev->list);
    write_unlock_irqrestore(&cm.device_lock, flags);

    - for (i = 1; i <= device->phys_port_cnt; i++) {
    + for (i = 1; i <= ib_device->phys_port_cnt; i++) {
    port = cm_dev->port[i-1];
    - ib_modify_port(device, port->port_num, 0, &port_modify);
    + ib_modify_port(ib_device, port->port_num, 0, &port_modify);
    ib_unregister_mad_agent(port->mad_agent);
    flush_workqueue(cm.wq);
    cm_remove_port_fs(port);
    --
    1.5.6.3

    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  14. [PATCH 25/79] device create: sound: convert device_create to device_create_drvdata

    device_create() is race-prone, so use the race-free
    device_create_drvdata() instead as device_create() is going away.

    Cc: Jaroslav Kysela
    Signed-off-by: Greg Kroah-Hartman
    ---
    sound/core/init.c | 5 +++--
    sound/oss/soundcard.c | 14 ++++++++------
    sound/sound_core.c | 5 +++--
    3 files changed, 14 insertions(+), 10 deletions(-)

    diff --git a/sound/core/init.c b/sound/core/init.c
    index 5c254d4..df46bbc 100644
    --- a/sound/core/init.c
    +++ b/sound/core/init.c
    @@ -548,8 +548,9 @@ int snd_card_register(struct snd_card *card)
    snd_assert(card != NULL, return -EINVAL);
    #ifndef CONFIG_SYSFS_DEPRECATED
    if (!card->card_dev) {
    - card->card_dev = device_create(sound_class, card->dev, 0,
    - "card%i", card->number);
    + card->card_dev = device_create_drvdata(sound_class, card->dev,
    + MKDEV(0, 0), NULL,
    + "card%i", card->number);
    if (IS_ERR(card->card_dev))
    card->card_dev = NULL;
    }
    diff --git a/sound/oss/soundcard.c b/sound/oss/soundcard.c
    index a9c23b2..7d89c08 100644
    --- a/sound/oss/soundcard.c
    +++ b/sound/oss/soundcard.c
    @@ -560,17 +560,19 @@ static int __init oss_init(void)
    sound_dmap_flag = (dmabuf > 0 ? 1 : 0);

    for (i = 0; i < ARRAY_SIZE(dev_list); i++) {
    - device_create(sound_class, NULL,
    - MKDEV(SOUND_MAJOR, dev_list[i].minor),
    - "%s", dev_list[i].name);
    + device_create_drvdata(sound_class, NULL,
    + MKDEV(SOUND_MAJOR, dev_list[i].minor),
    + NULL, "%s", dev_list[i].name);

    if (!dev_list[i].num)
    continue;

    for (j = 1; j < *dev_list[i].num; j++)
    - device_create(sound_class, NULL,
    - MKDEV(SOUND_MAJOR, dev_list[i].minor + (j*0x10)),
    - "%s%d", dev_list[i].name, j);
    + device_create_drvdata(sound_class, NULL,
    + MKDEV(SOUND_MAJOR,
    + dev_list[i].minor + (j*0x10)),
    + NULL,
    + "%s%d", dev_list[i].name, j);
    }

    if (sound_nblocks >= 1024)
    diff --git a/sound/sound_core.c b/sound/sound_core.c
    index dcfc1d5..1b04259 100644
    --- a/sound/sound_core.c
    +++ b/sound/sound_core.c
    @@ -171,8 +171,9 @@ static int sound_insert_unit(struct sound_unit **list, const struct file_operati
    else
    sprintf(s->name, "sound/%s%d", name, r / SOUND_STEP);

    - device_create(sound_class, dev, MKDEV(SOUND_MAJOR, s->unit_minor),
    - s->name+6);
    + device_create_drvdata(sound_class, dev,
    + MKDEV(SOUND_MAJOR, s->unit_minor),
    + NULL, s->name+6);
    return r;

    fail:
    --
    1.5.6.3

    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  15. [PATCH 42/79] bluetooth: remove improper bluetooth class symlinks.

    Don't create symlinks in a class to a device that is not owned by the
    class. If the bluetooth subsystem really wants to point to all of the
    devices it controls, it needs to create real devices, not fake symlinks.

    Cc: Maxim Krasnyansky
    Cc: Kay Sievers
    Acked-by: Marcel Holtmann
    Signed-off-by: Greg Kroah-Hartman
    ---
    net/bluetooth/hci_sysfs.c | 7 -------
    1 files changed, 0 insertions(+), 7 deletions(-)

    diff --git a/net/bluetooth/hci_sysfs.c b/net/bluetooth/hci_sysfs.c
    index 844ca5f..c85bf8f 100644
    --- a/net/bluetooth/hci_sysfs.c
    +++ b/net/bluetooth/hci_sysfs.c
    @@ -398,10 +398,6 @@ int hci_register_sysfs(struct hci_dev *hdev)
    if (device_create_file(dev, bt_attrs[i]) < 0)
    BT_ERR("Failed to create device attribute");

    - if (sysfs_create_link(&bt_class->subsys.kobj,
    - &dev->kobj, kobject_name(&dev->kobj)) < 0)
    - BT_ERR("Failed to create class symlink");
    -
    return 0;
    }

    @@ -409,9 +405,6 @@ void hci_unregister_sysfs(struct hci_dev *hdev)
    {
    BT_DBG("%p name %s type %d", hdev, hdev->name, hdev->type);

    - sysfs_remove_link(&bt_class->subsys.kobj,
    - kobject_name(&hdev->dev.kobj));
    -
    device_del(&hdev->dev);
    }

    --
    1.5.6.3

    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  16. [PATCH 36/79] block: make /proc/diskstats only build if CONFIG_PROC_FS is enabled

    From: Randy Dunlap

    These functions are only needed if CONFIG_PROC_FS is enabled, so save
    the space when it is not.

    This also makes it easier for a patch later in this series to work
    properly if CONFIG_PROC_FS is not enabled.

    Signed-off-by: Randy Dunlap
    Signed-off-by: Greg Kroah-Hartman
    ---
    block/genhd.c | 2 ++
    1 files changed, 2 insertions(+), 0 deletions(-)

    diff --git a/block/genhd.c b/block/genhd.c
    index e8c42bf..68a5f28 100644
    --- a/block/genhd.c
    +++ b/block/genhd.c
    @@ -544,6 +544,7 @@ static struct device_type disk_type = {
    .release = disk_release,
    };

    +#ifdef CONFIG_PROC_FS
    /*
    * aggregate disk stat collector. Uses the same stats that the sysfs
    * entries do, above, but makes them available through one seq_file.
    @@ -653,6 +654,7 @@ const struct seq_operations diskstats_op = {
    .stop = diskstats_stop,
    .show = diskstats_show
    };
    +#endif /* CONFIG_PROC_FS */

    static void media_change_notify_thread(struct work_struct *work)
    {
    --
    1.5.6.3

    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  17. [PATCH 47/79] class: rename "sem" to "class_sem" in internal class structure

    This renames the struct class "sem" field to be "class_sem" to make
    things easier when struct bus_type and struct class merge in the future.
    It also makes grepping for fields easier as well.

    Based on an idea from Kay.

    Cc: Kay Sievers
    Signed-off-by: Greg Kroah-Hartman
    ---
    drivers/base/base.h | 4 ++--
    drivers/base/class.c | 22 +++++++++++-----------
    drivers/base/core.c | 8 ++++----
    3 files changed, 17 insertions(+), 17 deletions(-)

    diff --git a/drivers/base/base.h b/drivers/base/base.h
    index a77d4bd..4435732 100644
    --- a/drivers/base/base.h
    +++ b/drivers/base/base.h
    @@ -45,7 +45,7 @@ struct driver_private {
    * @class_devices - list of devices associated with this class
    * @class_interfaces - list of class_interfaces associated with this class
    * @class_dirs -
    - * @sem - semaphore to protect the children, devices, and interfaces lists.
    + * @class_sem - semaphore to protect the children, devices, and interfaces lists.
    * @class - pointer back to the struct class that this structure is associated
    * with.
    *
    @@ -58,7 +58,7 @@ struct class_private {
    struct list_head class_devices;
    struct list_head class_interfaces;
    struct kset class_dirs;
    - struct semaphore sem;
    + struct semaphore class_sem;
    struct class *class;
    };
    #define to_class(obj) \
    diff --git a/drivers/base/class.c b/drivers/base/class.c
    index 86778b8..d24d211 100644
    --- a/drivers/base/class.c
    +++ b/drivers/base/class.c
    @@ -147,7 +147,7 @@ int class_register(struct class *cls)
    INIT_LIST_HEAD(&cp->class_devices);
    INIT_LIST_HEAD(&cp->class_interfaces);
    kset_init(&cp->class_dirs);
    - init_MUTEX(&cp->sem);
    + init_MUTEX(&cp->class_sem);
    error = kobject_set_name(&cp->class_subsys.kobj, "%s", cls->name);
    if (error) {
    kfree(cp);
    @@ -278,7 +278,7 @@ char *make_class_name(const char *name, struct kobject *kobj)
    * We check the return of @fn each time. If it returns anything
    * other than 0, we break out and return that value.
    *
    - * Note, we hold class->sem in this function, so it can not be
    + * Note, we hold class->class_sem in this function, so it can not be
    * re-acquired in @fn, otherwise it will self-deadlocking. For
    * example, calls to add or remove class members would be verboten.
    */
    @@ -290,7 +290,7 @@ int class_for_each_device(struct class *class, struct device *start,

    if (!class)
    return -EINVAL;
    - down(&class->p->sem);
    + down(&class->p->class_sem);
    list_for_each_entry(dev, &class->p->class_devices, node) {
    if (start) {
    if (start == dev)
    @@ -303,7 +303,7 @@ int class_for_each_device(struct class *class, struct device *start,
    if (error)
    break;
    }
    - up(&class->p->sem);
    + up(&class->p->class_sem);

    return error;
    }
    @@ -326,7 +326,7 @@ EXPORT_SYMBOL_GPL(class_for_each_device);
    *
    * Note, you will need to drop the reference with put_device() after use.
    *
    - * We hold class->sem in this function, so it can not be
    + * We hold class->class_sem in this function, so it can not be
    * re-acquired in @match, otherwise it will self-deadlocking. For
    * example, calls to add or remove class members would be verboten.
    */
    @@ -340,7 +340,7 @@ struct device *class_find_device(struct class *class, struct device *start,
    if (!class)
    return NULL;

    - down(&class->p->sem);
    + down(&class->p->class_sem);
    list_for_each_entry(dev, &class->p->class_devices, node) {
    if (start) {
    if (start == dev)
    @@ -354,7 +354,7 @@ struct device *class_find_device(struct class *class, struct device *start,
    } else
    put_device(dev);
    }
    - up(&class->p->sem);
    + up(&class->p->class_sem);

    return found ? dev : NULL;
    }
    @@ -372,13 +372,13 @@ int class_interface_register(struct class_interface *class_intf)
    if (!parent)
    return -EINVAL;

    - down(&parent->p->sem);
    + down(&parent->p->class_sem);
    list_add_tail(&class_intf->node, &parent->p->class_interfaces);
    if (class_intf->add_dev) {
    list_for_each_entry(dev, &parent->p->class_devices, node)
    class_intf->add_dev(dev, class_intf);
    }
    - up(&parent->p->sem);
    + up(&parent->p->class_sem);

    return 0;
    }
    @@ -391,13 +391,13 @@ void class_interface_unregister(struct class_interface *class_intf)
    if (!parent)
    return;

    - down(&parent->p->sem);
    + down(&parent->p->class_sem);
    list_del_init(&class_intf->node);
    if (class_intf->remove_dev) {
    list_for_each_entry(dev, &parent->p->class_devices, node)
    class_intf->remove_dev(dev, class_intf);
    }
    - up(&parent->p->sem);
    + up(&parent->p->class_sem);

    class_put(parent);
    }
    diff --git a/drivers/base/core.c b/drivers/base/core.c
    index 6e1cff2..b90ae6f 100644
    --- a/drivers/base/core.c
    +++ b/drivers/base/core.c
    @@ -907,7 +907,7 @@ int device_add(struct device *dev)
    klist_add_tail(&dev->knode_parent, &parent->klist_children);

    if (dev->class) {
    - down(&dev->class->p->sem);
    + down(&dev->class->p->class_sem);
    /* tie the class to the device */
    list_add_tail(&dev->node, &dev->class->p->class_devices);

    @@ -916,7 +916,7 @@ int device_add(struct device *dev)
    &dev->class->p->class_interfaces, node)
    if (class_intf->add_dev)
    class_intf->add_dev(dev, class_intf);
    - up(&dev->class->p->sem);
    + up(&dev->class->p->class_sem);
    }
    Done:
    put_device(dev);
    @@ -1017,7 +1017,7 @@ void device_del(struct device *dev)
    if (dev->class) {
    device_remove_class_symlinks(dev);

    - down(&dev->class->p->sem);
    + down(&dev->class->p->class_sem);
    /* notify any interfaces that the device is now gone */
    list_for_each_entry(class_intf,
    &dev->class->p->class_interfaces, node)
    @@ -1025,7 +1025,7 @@ void device_del(struct device *dev)
    class_intf->remove_dev(dev, class_intf);
    /* remove the device from the class list */
    list_del_init(&dev->node);
    - up(&dev->class->p->sem);
    + up(&dev->class->p->class_sem);
    }
    device_remove_file(dev, &uevent_attr);
    device_remove_attrs(dev);
    --
    1.5.6.3

    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  18. [PATCH 33/79] block: fix compiler warning in genhd.c

    Warn if something really bad happens if we can't create this link.

    Cc: Kay Sievers
    Signed-off-by: Greg Kroah-Hartman
    ---
    block/genhd.c | 4 +++-
    1 files changed, 3 insertions(+), 1 deletions(-)

    diff --git a/block/genhd.c b/block/genhd.c
    index 24e3fc9..3ccf5c0 100644
    --- a/block/genhd.c
    +++ b/block/genhd.c
    @@ -183,6 +183,7 @@ static int exact_lock(dev_t devt, void *data)
    void add_disk(struct gendisk *disk)
    {
    struct backing_dev_info *bdi;
    + int retval;

    disk->flags |= GENHD_FL_UP;
    blk_register_region(MKDEV(disk->major, disk->first_minor),
    @@ -193,7 +194,8 @@ void add_disk(struct gendisk *disk)

    bdi = &disk->queue->backing_dev_info;
    bdi_register_dev(bdi, MKDEV(disk->major, disk->first_minor));
    - sysfs_create_link(&disk->dev.kobj, &bdi->dev->kobj, "bdi");
    + retval = sysfs_create_link(&disk->dev.kobj, &bdi->dev->kobj, "bdi");
    + WARN_ON(retval);
    }

    EXPORT_SYMBOL(add_disk);
    --
    1.5.6.3

    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  19. [PATCH 68/79] debugfs: Implement debugfs_remove_recursive()

    From: Haavard Skinnemoen

    debugfs_remove_recursive() will remove a dentry and all its children.
    Drivers can use this to zap their whole debugfs tree so that they don't
    need to keep track of every single debugfs dentry they created.

    It may fail to remove the whole tree in certain cases:

    sh-3.2# rmmod atmel-mci < /sys/kernel/debug/mmc0/ios/clock
    mmc0: card b368 removed
    atmel_mci atmel_mci.0: Lost dma0chan1, falling back to PIO
    sh-3.2# ls /sys/kernel/debug/mmc0/
    ios

    But I'm not sure if that case can be handled in any sane manner.

    Signed-off-by: Haavard Skinnemoen
    Cc: Pierre Ossman
    Signed-off-by: Greg Kroah-Hartman
    ---
    fs/debugfs/inode.c | 114 +++++++++++++++++++++++++++++++++++++++-------
    include/linux/debugfs.h | 4 ++
    2 files changed, 100 insertions(+), 18 deletions(-)

    diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c
    index e9602d8..08e28c9 100644
    --- a/fs/debugfs/inode.c
    +++ b/fs/debugfs/inode.c
    @@ -309,6 +309,31 @@ struct dentry *debugfs_create_symlink(const char *name, struct dentry *parent,
    }
    EXPORT_SYMBOL_GPL(debugfs_create_symlink);

    +static void __debugfs_remove(struct dentry *dentry, struct dentry *parent)
    +{
    + int ret = 0;
    +
    + if (debugfs_positive(dentry)) {
    + if (dentry->d_inode) {
    + dget(dentry);
    + switch (dentry->d_inode->i_mode & S_IFMT) {
    + case S_IFDIR:
    + ret = simple_rmdir(parent->d_inode, dentry);
    + break;
    + case S_IFLNK:
    + kfree(dentry->d_inode->i_private);
    + /* fall through */
    + default:
    + simple_unlink(parent->d_inode, dentry);
    + break;
    + }
    + if (!ret)
    + d_delete(dentry);
    + dput(dentry);
    + }
    + }
    +}
    +
    /**
    * debugfs_remove - removes a file or directory from the debugfs filesystem
    * @dentry: a pointer to a the dentry of the file or directory to be
    @@ -325,7 +350,6 @@ EXPORT_SYMBOL_GPL(debugfs_create_symlink);
    void debugfs_remove(struct dentry *dentry)
    {
    struct dentry *parent;
    - int ret = 0;

    if (!dentry)
    return;
    @@ -335,29 +359,83 @@ void debugfs_remove(struct dentry *dentry)
    return;

    mutex_lock(&parent->d_inode->i_mutex);
    - if (debugfs_positive(dentry)) {
    - if (dentry->d_inode) {
    - dget(dentry);
    - switch (dentry->d_inode->i_mode & S_IFMT) {
    - case S_IFDIR:
    - ret = simple_rmdir(parent->d_inode, dentry);
    - break;
    - case S_IFLNK:
    - kfree(dentry->d_inode->i_private);
    - /* fall through */
    - default:
    - simple_unlink(parent->d_inode, dentry);
    + __debugfs_remove(dentry, parent);
    + mutex_unlock(&parent->d_inode->i_mutex);
    + simple_release_fs(&debugfs_mount, &debugfs_mount_count);
    +}
    +EXPORT_SYMBOL_GPL(debugfs_remove);
    +
    +/**
    + * debugfs_remove_recursive - recursively removes a directory
    + * @dentry: a pointer to a the dentry of the directory to be removed.
    + *
    + * This function recursively removes a directory tree in debugfs that
    + * was previously created with a call to another debugfs function
    + * (like debugfs_create_file() or variants thereof.)
    + *
    + * This function is required to be called in order for the file to be
    + * removed, no automatic cleanup of files will happen when a module is
    + * removed, you are responsible here.
    + */
    +void debugfs_remove_recursive(struct dentry *dentry)
    +{
    + struct dentry *child;
    + struct dentry *parent;
    +
    + if (!dentry)
    + return;
    +
    + parent = dentry->d_parent;
    + if (!parent || !parent->d_inode)
    + return;
    +
    + parent = dentry;
    + mutex_lock(&parent->d_inode->i_mutex);
    +
    + while (1) {
    + /*
    + * When all dentries under "parent" has been removed,
    + * walk up the tree until we reach our starting point.
    + */
    + if (list_empty(&parent->d_subdirs)) {
    + mutex_unlock(&parent->d_inode->i_mutex);
    + if (parent == dentry)
    break;
    - }
    - if (!ret)
    - d_delete(dentry);
    - dput(dentry);
    + parent = parent->d_parent;
    + mutex_lock(&parent->d_inode->i_mutex);
    + }
    + child = list_entry(parent->d_subdirs.next, struct dentry,
    + d_u.d_child);
    +
    + /*
    + * If "child" isn't empty, walk down the tree and
    + * remove all its descendants first.
    + */
    + if (!list_empty(&child->d_subdirs)) {
    + mutex_unlock(&parent->d_inode->i_mutex);
    + parent = child;
    + mutex_lock(&parent->d_inode->i_mutex);
    + continue;
    }
    + __debugfs_remove(child, parent);
    + if (parent->d_subdirs.next == &child->d_u.d_child) {
    + /*
    + * Avoid infinite loop if we fail to remove
    + * one dentry.
    + */
    + mutex_unlock(&parent->d_inode->i_mutex);
    + break;
    + }
    + simple_release_fs(&debugfs_mount, &debugfs_mount_count);
    }
    +
    + parent = dentry->d_parent;
    + mutex_lock(&parent->d_inode->i_mutex);
    + __debugfs_remove(dentry, parent);
    mutex_unlock(&parent->d_inode->i_mutex);
    simple_release_fs(&debugfs_mount, &debugfs_mount_count);
    }
    -EXPORT_SYMBOL_GPL(debugfs_remove);
    +EXPORT_SYMBOL_GPL(debugfs_remove_recursive);

    /**
    * debugfs_rename - rename a file/directory in the debugfs filesystem
    diff --git a/include/linux/debugfs.h b/include/linux/debugfs.h
    index 32755cd..e1a6c04 100644
    --- a/include/linux/debugfs.h
    +++ b/include/linux/debugfs.h
    @@ -44,6 +44,7 @@ struct dentry *debugfs_create_symlink(const char *name, struct dentry *parent,
    const char *dest);

    void debugfs_remove(struct dentry *dentry);
    +void debugfs_remove_recursive(struct dentry *dentry);

    struct dentry *debugfs_rename(struct dentry *old_dir, struct dentry *old_dentry,
    struct dentry *new_dir, const char *new_name);
    @@ -101,6 +102,9 @@ static inline struct dentry *debugfs_create_symlink(const char *name,
    static inline void debugfs_remove(struct dentry *dentry)
    { }

    +static inline void debugfs_remove_recursive(struct dentry *dentry)
    +{ }
    +
    static inline struct dentry *debugfs_rename(struct dentry *old_dir, struct dentry *old_dentry,
    struct dentry *new_dir, char *new_name)
    {
    --
    1.5.6.3

    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  20. [PATCH 61/79] kobject: should use kobject_put() in kset-example

    From: Li Zefan

    We should call kobject_put() instead of kfree() if kobject_init_and_add()
    returns an error, shouldn't we? Don't set up a bad example

    Signed-off-by: Li Zefan
    Signed-off-by: Greg Kroah-Hartman
    ---
    samples/kobject/kset-example.c | 2 +-
    1 files changed, 1 insertions(+), 1 deletions(-)

    diff --git a/samples/kobject/kset-example.c b/samples/kobject/kset-example.c
    index b0a1b4f..7395c0b 100644
    --- a/samples/kobject/kset-example.c
    +++ b/samples/kobject/kset-example.c
    @@ -211,7 +211,7 @@ static struct foo_obj *create_foo_obj(const char *name)
    */
    retval = kobject_init_and_add(&foo->kobj, &foo_ktype, NULL, "%s", name);
    if (retval) {
    - kfree(foo);
    + kobject_put(&foo->kobj);
    return NULL;
    }

    --
    1.5.6.3

    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

+ Reply to Thread
Page 2 of 4 FirstFirst 1 2 3 4 LastLast