aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pci/pci-driver.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/pci/pci-driver.c')
-rw-r--r--drivers/pci/pci-driver.c50
1 files changed, 5 insertions, 45 deletions
diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c
index 73e362992694..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>
@@ -356,50 +361,6 @@ static void pci_device_shutdown(struct device *dev)
356 drv->shutdown(pci_dev); 361 drv->shutdown(pci_dev);
357} 362}
358 363
359#define kobj_to_pci_driver(obj) container_of(obj, struct device_driver, kobj)
360#define attr_to_driver_attribute(obj) container_of(obj, struct driver_attribute, attr)
361
362static ssize_t
363pci_driver_attr_show(struct kobject * kobj, struct attribute *attr, char *buf)
364{
365 struct device_driver *driver = kobj_to_pci_driver(kobj);
366 struct driver_attribute *dattr = attr_to_driver_attribute(attr);
367 ssize_t ret;
368
369 if (!get_driver(driver))
370 return -ENODEV;
371
372 ret = dattr->show ? dattr->show(driver, buf) : -EIO;
373
374 put_driver(driver);
375 return ret;
376}
377
378static ssize_t
379pci_driver_attr_store(struct kobject * kobj, struct attribute *attr,
380 const char *buf, size_t count)
381{
382 struct device_driver *driver = kobj_to_pci_driver(kobj);
383 struct driver_attribute *dattr = attr_to_driver_attribute(attr);
384 ssize_t ret;
385
386 if (!get_driver(driver))
387 return -ENODEV;
388
389 ret = dattr->store ? dattr->store(driver, buf, count) : -EIO;
390
391 put_driver(driver);
392 return ret;
393}
394
395static struct sysfs_ops pci_driver_sysfs_ops = {
396 .show = pci_driver_attr_show,
397 .store = pci_driver_attr_store,
398};
399static struct kobj_type pci_driver_kobj_type = {
400 .sysfs_ops = &pci_driver_sysfs_ops,
401};
402
403/** 364/**
404 * __pci_register_driver - register a new pci driver 365 * __pci_register_driver - register a new pci driver
405 * @drv: the driver structure to register 366 * @drv: the driver structure to register
@@ -421,7 +382,6 @@ int __pci_register_driver(struct pci_driver *drv, struct module *owner,
421 drv->driver.bus = &pci_bus_type; 382 drv->driver.bus = &pci_bus_type;
422 drv->driver.owner = owner; 383 drv->driver.owner = owner;
423 drv->driver.mod_name = mod_name; 384 drv->driver.mod_name = mod_name;
424 drv->driver.kobj.ktype = &pci_driver_kobj_type;
425 385
426 spin_lock_init(&drv->dynids.lock); 386 spin_lock_init(&drv->dynids.lock);
427 INIT_LIST_HEAD(&drv->dynids.list); 387 INIT_LIST_HEAD(&drv->dynids.list);