Commit 6de3d58d authored by Linus Torvalds's avatar Linus Torvalds

Merge git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-2.6

* git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-2.6:
  klist: fix coding style errors in klist.h and klist.c
  driver core: remove no longer used "struct class_device"
  pcmcia: remove pccard_sysfs_interface warnings
  devres: support addresses greater than an unsigned long via dev_ioremap
  kobject: do not copy vargs, just pass them around
  sysfs: sysfs_update_group stub for CONFIG_SYSFS=n
  DEBUGFS: Correct location of debugfs API documentation.
  driver core: warn about duplicate driver names on the same bus
  klist: implement klist_add_{after|before}()
  klist: implement KLIST_INIT() and DEFINE_KLIST()
  sysfs: Disallow truncation of files in sysfs
parents e0066c4e c3bb7fad
......@@ -64,17 +64,6 @@ extern void sysdev_shutdown(void);
extern int sysdev_suspend(pm_message_t state);
extern int sysdev_resume(void);
static inline struct class_device *to_class_dev(struct kobject *obj)
{
return container_of(obj, struct class_device, kobj);
}
static inline
struct class_device_attribute *to_class_dev_attr(struct attribute *_attr)
{
return container_of(_attr, struct class_device_attribute, attr);
}
extern char *make_class_name(const char *name, struct kobject *kobj);
extern int devres_release_all(struct device *dev);
......
This diff is collapsed.
......@@ -217,12 +217,22 @@ static void driver_remove_groups(struct device_driver *drv,
int driver_register(struct device_driver *drv)
{
int ret;
struct device_driver *other;
if ((drv->bus->probe && drv->probe) ||
(drv->bus->remove && drv->remove) ||
(drv->bus->shutdown && drv->shutdown))
printk(KERN_WARNING "Driver '%s' needs updating - please use "
"bus_type methods\n", drv->name);
other = driver_find(drv->name, drv->bus);
if (other) {
put_driver(other);
printk(KERN_ERR "Error: Driver '%s' is already registered, "
"aborting...\n", drv->name);
return -EEXIST;
}
ret = bus_add_driver(drv);
if (ret)
return ret;
......
......@@ -652,6 +652,9 @@ static int pccardd(void *__skt)
complete(&skt->thread_done);
return 0;
}
ret = pccard_sysfs_add_socket(&skt->dev);
if (ret)
dev_warn(&skt->dev, "err %d adding socket attributes\n", ret);
add_wait_queue(&skt->thread_wait, &wait);
complete(&skt->thread_done);
......@@ -694,6 +697,7 @@ static int pccardd(void *__skt)
remove_wait_queue(&skt->thread_wait, &wait);
/* remove from the device core */
pccard_sysfs_remove_socket(&skt->dev);
device_unregister(&skt->dev);
return 0;
......@@ -940,20 +944,13 @@ EXPORT_SYMBOL(pcmcia_socket_class);
static int __init init_pcmcia_cs(void)
{
int ret;
init_completion(&pcmcia_unload);
ret = class_register(&pcmcia_socket_class);
if (ret)
return (ret);
return class_interface_register(&pccard_sysfs_interface);
return class_register(&pcmcia_socket_class);
}
static void __exit exit_pcmcia_cs(void)
{
class_interface_unregister(&pccard_sysfs_interface);
class_unregister(&pcmcia_socket_class);
wait_for_completion(&pcmcia_unload);
}
......
......@@ -121,7 +121,8 @@ struct resource *pcmcia_find_mem_region(u_long base, u_long num, u_long align,
void release_resource_db(struct pcmcia_socket *s);
/* In socket_sysfs.c */
extern struct class_interface pccard_sysfs_interface;
extern int pccard_sysfs_add_socket(struct device *dev);
extern void pccard_sysfs_remove_socket(struct device *dev);
/* In cs.c */
extern struct rw_semaphore pcmcia_socket_list_rwsem;
......
......@@ -356,19 +356,23 @@ static ssize_t pccard_store_cis(struct kobject *kobj,
}
static struct device_attribute *pccard_socket_attributes[] = {
&dev_attr_card_type,
&dev_attr_card_voltage,
&dev_attr_card_vpp,
&dev_attr_card_vcc,
&dev_attr_card_insert,
&dev_attr_card_pm_state,
&dev_attr_card_eject,
&dev_attr_card_irq_mask,
&dev_attr_available_resources_setup_done,
static struct attribute *pccard_socket_attributes[] = {
&dev_attr_card_type.attr,
&dev_attr_card_voltage.attr,
&dev_attr_card_vpp.attr,
&dev_attr_card_vcc.attr,
&dev_attr_card_insert.attr,
&dev_attr_card_pm_state.attr,
&dev_attr_card_eject.attr,
&dev_attr_card_irq_mask.attr,
&dev_attr_available_resources_setup_done.attr,
NULL,
};
static const struct attribute_group socket_attrs = {
.attrs = pccard_socket_attributes,
};
static struct bin_attribute pccard_cis_attr = {
.attr = { .name = "cis", .mode = S_IRUGO | S_IWUSR },
.size = 0x200,
......@@ -376,35 +380,21 @@ static struct bin_attribute pccard_cis_attr = {
.write = pccard_store_cis,
};
static int __devinit pccard_sysfs_add_socket(struct device *dev,
struct class_interface *class_intf)
int pccard_sysfs_add_socket(struct device *dev)
{
struct device_attribute **attr;
int ret = 0;
for (attr = pccard_socket_attributes; *attr; attr++) {
ret = device_create_file(dev, *attr);
ret = sysfs_create_group(&dev->kobj, &socket_attrs);
if (!ret) {
ret = sysfs_create_bin_file(&dev->kobj, &pccard_cis_attr);
if (ret)
break;
sysfs_remove_group(&dev->kobj, &socket_attrs);
}
if (!ret)
ret = sysfs_create_bin_file(&dev->kobj, &pccard_cis_attr);
return ret;
}
static void __devexit pccard_sysfs_remove_socket(struct device *dev,
struct class_interface *class_intf)
void pccard_sysfs_remove_socket(struct device *dev)
{
struct device_attribute **attr;
sysfs_remove_bin_file(&dev->kobj, &pccard_cis_attr);
for (attr = pccard_socket_attributes; *attr; attr++)
device_remove_file(dev, *attr);
sysfs_remove_group(&dev->kobj, &socket_attrs);
}
struct class_interface pccard_sysfs_interface = {
.class = &pcmcia_socket_class,
.add_dev = &pccard_sysfs_add_socket,
.remove_dev = __devexit_p(&pccard_sysfs_remove_socket),
};
......@@ -9,7 +9,7 @@
* 2 as published by the Free Software Foundation.
*
* debugfs is for people to use instead of /proc or /sys.
* See Documentation/DocBook/kernel-api for more details.
* See Documentation/DocBook/filesystems for more details.
*
*/
......
......@@ -59,6 +59,8 @@ int sysfs_setattr(struct dentry * dentry, struct iattr * iattr)
if (error)
return error;
iattr->ia_valid &= ~ATTR_SIZE; /* ignore size changes */
error = inode_setattr(inode, iattr);
if (error)
return error;
......
......@@ -35,7 +35,6 @@ struct device;
struct device_driver;
struct driver_private;
struct class;
struct class_device;
struct bus_type;
struct bus_type_private;
......@@ -190,13 +189,10 @@ struct class {
struct kset class_dirs;
struct semaphore sem; /* locks children, devices, interfaces */
struct class_attribute *class_attrs;
struct class_device_attribute *class_dev_attrs;
struct device_attribute *dev_attrs;
int (*uevent)(struct class_device *dev, struct kobj_uevent_env *env);
int (*dev_uevent)(struct device *dev, struct kobj_uevent_env *env);
void (*release)(struct class_device *dev);
void (*class_release)(struct class *class);
void (*dev_release)(struct device *dev);
......@@ -210,9 +206,6 @@ extern int class_for_each_device(struct class *class, void *data,
int (*fn)(struct device *dev, void *data));
extern struct device *class_find_device(struct class *class, void *data,
int (*match)(struct device *, void *));
extern struct class_device *class_find_child(struct class *class, void *data,
int (*match)(struct class_device *, void *));
struct class_attribute {
struct attribute attr;
......@@ -228,92 +221,10 @@ extern int __must_check class_create_file(struct class *class,
extern void class_remove_file(struct class *class,
const struct class_attribute *attr);
struct class_device_attribute {
struct attribute attr;
ssize_t (*show)(struct class_device *, char *buf);
ssize_t (*store)(struct class_device *, const char *buf, size_t count);
};
#define CLASS_DEVICE_ATTR(_name, _mode, _show, _store) \
struct class_device_attribute class_device_attr_##_name = \
__ATTR(_name, _mode, _show, _store)
extern int __must_check class_device_create_file(struct class_device *,
const struct class_device_attribute *);
/**
* struct class_device - class devices
* @class: pointer to the parent class for this class device. This is required.
* @devt: for internal use by the driver core only.
* @node: for internal use by the driver core only.
* @kobj: for internal use by the driver core only.
* @groups: optional additional groups to be created
* @dev: if set, a symlink to the struct device is created in the sysfs
* directory for this struct class device.
* @class_data: pointer to whatever you want to store here for this struct
* class_device. Use class_get_devdata() and class_set_devdata() to get and
* set this pointer.
* @parent: pointer to a struct class_device that is the parent of this struct
* class_device. If NULL, this class_device will show up at the root of the
* struct class in sysfs (which is probably what you want to have happen.)
* @release: pointer to a release function for this struct class_device. If
* set, this will be called instead of the class specific release function.
* Only use this if you want to override the default release function, like
* when you are nesting class_device structures.
* @uevent: pointer to a uevent function for this struct class_device. If
* set, this will be called instead of the class specific uevent function.
* Only use this if you want to override the default uevent function, like
* when you are nesting class_device structures.
*/
struct class_device {
struct list_head node;
struct kobject kobj;
struct class *class;
dev_t devt;
struct device *dev;
void *class_data;
struct class_device *parent;
struct attribute_group **groups;
void (*release)(struct class_device *dev);
int (*uevent)(struct class_device *dev, struct kobj_uevent_env *env);
char class_id[BUS_ID_SIZE];
};
static inline void *class_get_devdata(struct class_device *dev)
{
return dev->class_data;
}
static inline void class_set_devdata(struct class_device *dev, void *data)
{
dev->class_data = data;
}
extern int __must_check class_device_register(struct class_device *);
extern void class_device_unregister(struct class_device *);
extern void class_device_initialize(struct class_device *);
extern int __must_check class_device_add(struct class_device *);
extern void class_device_del(struct class_device *);
extern struct class_device *class_device_get(struct class_device *);
extern void class_device_put(struct class_device *);
extern void class_device_remove_file(struct class_device *,
const struct class_device_attribute *);
extern int __must_check class_device_create_bin_file(struct class_device *,
struct bin_attribute *);
extern void class_device_remove_bin_file(struct class_device *,
struct bin_attribute *);
struct class_interface {
struct list_head node;
struct class *class;
int (*add) (struct class_device *, struct class_interface *);
void (*remove) (struct class_device *, struct class_interface *);
int (*add_dev) (struct device *, struct class_interface *);
void (*remove_dev) (struct device *, struct class_interface *);
};
......@@ -323,13 +234,6 @@ extern void class_interface_unregister(struct class_interface *);
extern struct class *class_create(struct module *owner, const char *name);
extern void class_destroy(struct class *cls);
extern struct class_device *class_device_create(struct class *cls,
struct class_device *parent,
dev_t devt,
struct device *device,
const char *fmt, ...)
__attribute__((format(printf, 5, 6)));
extern void class_device_destroy(struct class *cls, dev_t devt);
/*
* The type of device, "struct device" is embedded in. A class
......@@ -465,7 +369,6 @@ struct device {
spinlock_t devres_lock;
struct list_head devres_head;
/* class_device migration path */
struct list_head node;
struct class *class;
dev_t devt; /* dev_t, creates the sysfs "dev" */
......
......@@ -58,9 +58,9 @@ static inline void devm_ioport_unmap(struct device *dev, void __iomem *addr)
}
#endif
void __iomem * devm_ioremap(struct device *dev, unsigned long offset,
void __iomem *devm_ioremap(struct device *dev, resource_size_t offset,
unsigned long size);
void __iomem * devm_ioremap_nocache(struct device *dev, unsigned long offset,
void __iomem *devm_ioremap_nocache(struct device *dev, resource_size_t offset,
unsigned long size);
void devm_iounmap(struct device *dev, void __iomem *addr);
int check_signature(const volatile void __iomem *io_addr,
......
......@@ -25,37 +25,47 @@ struct klist {
void (*put)(struct klist_node *);
};
#define KLIST_INIT(_name, _get, _put) \
{ .k_lock = __SPIN_LOCK_UNLOCKED(_name.k_lock), \
.k_list = LIST_HEAD_INIT(_name.k_list), \
.get = _get, \
.put = _put, }
extern void klist_init(struct klist * k, void (*get)(struct klist_node *),
#define DEFINE_KLIST(_name, _get, _put) \
struct klist _name = KLIST_INIT(_name, _get, _put)
extern void klist_init(struct klist *k, void (*get)(struct klist_node *),
void (*put)(struct klist_node *));
struct klist_node {
struct klist * n_klist;
struct klist *n_klist;
struct list_head n_node;
struct kref n_ref;
struct completion n_removed;
};
extern void klist_add_tail(struct klist_node * n, struct klist * k);
extern void klist_add_head(struct klist_node * n, struct klist * k);
extern void klist_add_tail(struct klist_node *n, struct klist *k);
extern void klist_add_head(struct klist_node *n, struct klist *k);
extern void klist_add_after(struct klist_node *n, struct klist_node *pos);
extern void klist_add_before(struct klist_node *n, struct klist_node *pos);
extern void klist_del(struct klist_node * n);
extern void klist_remove(struct klist_node * n);
extern void klist_del(struct klist_node *n);
extern void klist_remove(struct klist_node *n);
extern int klist_node_attached(struct klist_node * n);
extern int klist_node_attached(struct klist_node *n);
struct klist_iter {
struct klist * i_klist;
struct list_head * i_head;
struct klist_node * i_cur;
struct klist *i_klist;
struct list_head *i_head;
struct klist_node *i_cur;
};
extern void klist_iter_init(struct klist * k, struct klist_iter * i);
extern void klist_iter_init_node(struct klist * k, struct klist_iter * i,
struct klist_node * n);
extern void klist_iter_exit(struct klist_iter * i);
extern struct klist_node * klist_next(struct klist_iter * i);
extern void klist_iter_init(struct klist *k, struct klist_iter *i);
extern void klist_iter_init_node(struct klist *k, struct klist_iter *i,
struct klist_node *n);
extern void klist_iter_exit(struct klist_iter *i);
extern struct klist_node *klist_next(struct klist_iter *i);
#endif
......@@ -190,6 +190,12 @@ static inline int sysfs_create_group(struct kobject *kobj,
return 0;
}
static inline int sysfs_update_group(struct kobject *kobj,
const struct attribute_group *grp)
{
return 0;
}
static inline void sysfs_remove_group(struct kobject *kobj,
const struct attribute_group *grp)
{
......
......@@ -20,7 +20,7 @@ static int devm_ioremap_match(struct device *dev, void *res, void *match_data)
*
* Managed ioremap(). Map is automatically unmapped on driver detach.
*/
void __iomem *devm_ioremap(struct device *dev, unsigned long offset,
void __iomem *devm_ioremap(struct device *dev, resource_size_t offset,
unsigned long size)
{
void __iomem **ptr, *addr;
......@@ -49,7 +49,7 @@ EXPORT_SYMBOL(devm_ioremap);
* Managed ioremap_nocache(). Map is automatically unmapped on driver
* detach.
*/
void __iomem *devm_ioremap_nocache(struct device *dev, unsigned long offset,
void __iomem *devm_ioremap_nocache(struct device *dev, resource_size_t offset,
unsigned long size)
{
void __iomem **ptr, *addr;
......
This diff is collapsed.
......@@ -216,21 +216,12 @@ static int kobject_add_internal(struct kobject *kobj)
static int kobject_set_name_vargs(struct kobject *kobj, const char *fmt,
va_list vargs)
{
va_list aq;
char *name;
va_copy(aq, vargs);
name = kvasprintf(GFP_KERNEL, fmt, vargs);
va_end(aq);
if (!name)
return -ENOMEM;
/* Free the old name, if necessary. */
kfree(kobj->name);
/* Now, set the new name */
kobj->name = name;
kobj->name = kvasprintf(GFP_KERNEL, fmt, vargs);
if (!kobj->name)
return -ENOMEM;
return 0;
}
......@@ -246,12 +237,12 @@ static int kobject_set_name_vargs(struct kobject *kobj, const char *fmt,
*/
int kobject_set_name(struct kobject *kobj, const char *fmt, ...)
{
va_list args;
va_list vargs;
int retval;
va_start(args, fmt);
retval = kobject_set_name_vargs(kobj, fmt, args);
va_end(args);
va_start(vargs, fmt);
retval = kobject_set_name_vargs(kobj, fmt, vargs);
va_end(vargs);
return retval;
}
......@@ -301,12 +292,9 @@ EXPORT_SYMBOL(kobject_init);
static int kobject_add_varg(struct kobject *kobj, struct kobject *parent,
const char *fmt, va_list vargs)
{
va_list aq;
int retval;
va_copy(aq, vargs);
retval = kobject_set_name_vargs(kobj, fmt, aq);
va_end(aq);
retval = kobject_set_name_vargs(kobj, fmt, vargs);
if (retval) {
printk(KERN_ERR "kobject: can not set name properly!\n");
return retval;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment