aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pci/pci-driver.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2008-01-25 11:34:42 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2008-01-25 11:35:13 -0500
commitdf8dc74e8a383eaf2d9b44b80a71ec6f0e52b42e (patch)
treebc3799a43e8b94fa84b32e37b1c124d5e4868f50 /drivers/pci/pci-driver.c
parent556a169dab38b5100df6f4a45b655dddd3db94c1 (diff)
parent4a3ad20ccd8f4d2a0535cf98fa83f7b561ba59a9 (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-2.6
This can be broken down into these major areas: - Documentation updates (language translations and fixes, as well as kobject and kset documenatation updates.) - major kset/kobject/ktype rework and fixes. This cleans up the kset and kobject and ktype relationship and architecture, making sense of things now, and good documenation and samples are provided for others to use. Also the attributes for kobjects are much easier to handle now. This cleaned up a LOT of code all through the kernel, making kobjects easier to use if you want to. - struct bus_type has been reworked to now handle the lifetime rules properly, as the kobject is properly dynamic. - struct driver has also been reworked, and now the lifetime issues are resolved. - the block subsystem has been converted to use struct device now, and not "raw" kobjects. This patch has been in the -mm tree for over a year now, and finally all the issues are worked out with it. Older distros now properly work with new kernels, and no userspace updates are needed at all. - nozomi driver is added. This has also been in -mm for a long time, and many people have asked for it to go in. It is now in good enough shape to do so. - lots of class_device conversions to use struct device instead. The tree is almost all cleaned up now, only SCSI and IB is the remaining code to fix up... * git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-2.6: (196 commits) Driver core: coding style fixes Kobject: fix coding style issues in kobject c files Kobject: fix coding style issues in kobject.h Driver core: fix coding style issues in device.h spi: use class iteration api scsi: use class iteration api rtc: use class iteration api power supply : use class iteration api ieee1394: use class iteration api Driver Core: add class iteration api Driver core: Cleanup get_device_parent() in device_add() and device_move() UIO: constify function pointer tables Driver Core: constify the name passed to platform_device_register_simple driver core: fix build with SYSFS=n sysfs: make SYSFS_DEPRECATED depend on SYSFS Driver core: use LIST_HEAD instead of call to INIT_LIST_HEAD in __init kobject: add sample code for how to use ksets/ktypes/kobjects kobject: add sample code for how to use kobjects in a simple manner. kobject: update the kobject/kset documentation kobject: remove old, outdated documentation. ...
Diffstat (limited to 'drivers/pci/pci-driver.c')
-rw-r--r--drivers/pci/pci-driver.c59
1 files changed, 12 insertions, 47 deletions
diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c
index 6d1a21611818..c4fa35d1dd77 100644
--- a/drivers/pci/pci-driver.c
+++ b/drivers/pci/pci-driver.c
@@ -1,6 +1,11 @@
1/* 1/*
2 * drivers/pci/pci-driver.c 2 * drivers/pci/pci-driver.c
3 * 3 *
4 * (C) Copyright 2002-2004, 2007 Greg Kroah-Hartman <greg@kroah.com>
5 * (C) Copyright 2007 Novell Inc.
6 *
7 * Released under the GPL v2 only.
8 *
4 */ 9 */
5 10
6#include <linux/pci.h> 11#include <linux/pci.h>
@@ -96,17 +101,21 @@ pci_create_newid_file(struct pci_driver *drv)
96{ 101{
97 int error = 0; 102 int error = 0;
98 if (drv->probe != NULL) 103 if (drv->probe != NULL)
99 error = sysfs_create_file(&drv->driver.kobj, 104 error = driver_create_file(&drv->driver, &driver_attr_new_id);
100 &driver_attr_new_id.attr);
101 return error; 105 return error;
102} 106}
103 107
108static void pci_remove_newid_file(struct pci_driver *drv)
109{
110 driver_remove_file(&drv->driver, &driver_attr_new_id);
111}
104#else /* !CONFIG_HOTPLUG */ 112#else /* !CONFIG_HOTPLUG */
105static inline void pci_free_dynids(struct pci_driver *drv) {} 113static inline void pci_free_dynids(struct pci_driver *drv) {}
106static inline int pci_create_newid_file(struct pci_driver *drv) 114static inline int pci_create_newid_file(struct pci_driver *drv)
107{ 115{
108 return 0; 116 return 0;
109} 117}
118static inline void pci_remove_newid_file(struct pci_driver *drv) {}
110#endif 119#endif
111 120
112/** 121/**
@@ -352,50 +361,6 @@ static void pci_device_shutdown(struct device *dev)
352 drv->shutdown(pci_dev); 361 drv->shutdown(pci_dev);
353} 362}
354 363
355#define kobj_to_pci_driver(obj) container_of(obj, struct device_driver, kobj)
356#define attr_to_driver_attribute(obj) container_of(obj, struct driver_attribute, attr)
357
358static ssize_t
359pci_driver_attr_show(struct kobject * kobj, struct attribute *attr, char *buf)
360{
361 struct device_driver *driver = kobj_to_pci_driver(kobj);
362 struct driver_attribute *dattr = attr_to_driver_attribute(attr);
363 ssize_t ret;
364
365 if (!get_driver(driver))
366 return -ENODEV;
367
368 ret = dattr->show ? dattr->show(driver, buf) : -EIO;
369
370 put_driver(driver);
371 return ret;
372}
373
374static ssize_t
375pci_driver_attr_store(struct kobject * kobj, struct attribute *attr,
376 const char *buf, size_t count)
377{
378 struct device_driver *driver = kobj_to_pci_driver(kobj);
379 struct driver_attribute *dattr = attr_to_driver_attribute(attr);
380 ssize_t ret;
381
382 if (!get_driver(driver))
383 return -ENODEV;
384
385 ret = dattr->store ? dattr->store(driver, buf, count) : -EIO;
386
387 put_driver(driver);
388 return ret;
389}
390
391static struct sysfs_ops pci_driver_sysfs_ops = {
392 .show = pci_driver_attr_show,
393 .store = pci_driver_attr_store,
394};
395static struct kobj_type pci_driver_kobj_type = {
396 .sysfs_ops = &pci_driver_sysfs_ops,
397};
398
399/** 364/**
400 * __pci_register_driver - register a new pci driver 365 * __pci_register_driver - register a new pci driver
401 * @drv: the driver structure to register 366 * @drv: the driver structure to register
@@ -417,7 +382,6 @@ int __pci_register_driver(struct pci_driver *drv, struct module *owner,
417 drv->driver.bus = &pci_bus_type; 382 drv->driver.bus = &pci_bus_type;
418 drv->driver.owner = owner; 383 drv->driver.owner = owner;
419 drv->driver.mod_name = mod_name; 384 drv->driver.mod_name = mod_name;
420 drv->driver.kobj.ktype = &pci_driver_kobj_type;
421 385
422 spin_lock_init(&drv->dynids.lock); 386 spin_lock_init(&drv->dynids.lock);
423 INIT_LIST_HEAD(&drv->dynids.list); 387 INIT_LIST_HEAD(&drv->dynids.list);
@@ -447,6 +411,7 @@ int __pci_register_driver(struct pci_driver *drv, struct module *owner,
447void 411void
448pci_unregister_driver(struct pci_driver *drv) 412pci_unregister_driver(struct pci_driver *drv)
449{ 413{
414 pci_remove_newid_file(drv);
450 driver_unregister(&drv->driver); 415 driver_unregister(&drv->driver);
451 pci_free_dynids(drv); 416 pci_free_dynids(drv);
452} 417}