diff options
author | Tony Jones <tonyj@suse.de> | 2008-02-21 18:13:36 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2008-04-19 22:10:30 -0400 |
commit | f4e91eb4a81559da87a3843758a641b5cc590b65 (patch) | |
tree | 534335821d076764cbc072586b19c4b061710e3d /drivers/infiniband/hw/ipath | |
parent | c4c66cf1787d408066fbfc69209185701f5df15f (diff) |
IB: convert struct class_device to struct device
This converts the main ib_device to use struct device instead of struct
class_device as class_device is going away.
Signed-off-by: Tony Jones <tonyj@suse.de>
Signed-off-by: Kay Sievers <kay.sievers@vrfy.org>
Cc: Roland Dreier <rolandd@cisco.com>
Cc: Sean Hefty <sean.hefty@intel.com>
Cc: Hal Rosenstock <hal.rosenstock@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/infiniband/hw/ipath')
-rw-r--r-- | drivers/infiniband/hw/ipath/ipath_diag.c | 10 | ||||
-rw-r--r-- | drivers/infiniband/hw/ipath/ipath_file_ops.c | 44 | ||||
-rw-r--r-- | drivers/infiniband/hw/ipath/ipath_kernel.h | 8 | ||||
-rw-r--r-- | drivers/infiniband/hw/ipath/ipath_verbs.c | 37 |
4 files changed, 51 insertions, 48 deletions
diff --git a/drivers/infiniband/hw/ipath/ipath_diag.c b/drivers/infiniband/hw/ipath/ipath_diag.c index 6d49d2f18a88..d4ce8b63e19e 100644 --- a/drivers/infiniband/hw/ipath/ipath_diag.c +++ b/drivers/infiniband/hw/ipath/ipath_diag.c | |||
@@ -79,7 +79,7 @@ static const struct file_operations diagpkt_file_ops = { | |||
79 | 79 | ||
80 | static atomic_t diagpkt_count = ATOMIC_INIT(0); | 80 | static atomic_t diagpkt_count = ATOMIC_INIT(0); |
81 | static struct cdev *diagpkt_cdev; | 81 | static struct cdev *diagpkt_cdev; |
82 | static struct class_device *diagpkt_class_dev; | 82 | static struct device *diagpkt_dev; |
83 | 83 | ||
84 | int ipath_diag_add(struct ipath_devdata *dd) | 84 | int ipath_diag_add(struct ipath_devdata *dd) |
85 | { | 85 | { |
@@ -89,7 +89,7 @@ int ipath_diag_add(struct ipath_devdata *dd) | |||
89 | if (atomic_inc_return(&diagpkt_count) == 1) { | 89 | if (atomic_inc_return(&diagpkt_count) == 1) { |
90 | ret = ipath_cdev_init(IPATH_DIAGPKT_MINOR, | 90 | ret = ipath_cdev_init(IPATH_DIAGPKT_MINOR, |
91 | "ipath_diagpkt", &diagpkt_file_ops, | 91 | "ipath_diagpkt", &diagpkt_file_ops, |
92 | &diagpkt_cdev, &diagpkt_class_dev); | 92 | &diagpkt_cdev, &diagpkt_dev); |
93 | 93 | ||
94 | if (ret) { | 94 | if (ret) { |
95 | ipath_dev_err(dd, "Couldn't create ipath_diagpkt " | 95 | ipath_dev_err(dd, "Couldn't create ipath_diagpkt " |
@@ -102,7 +102,7 @@ int ipath_diag_add(struct ipath_devdata *dd) | |||
102 | 102 | ||
103 | ret = ipath_cdev_init(IPATH_DIAG_MINOR_BASE + dd->ipath_unit, name, | 103 | ret = ipath_cdev_init(IPATH_DIAG_MINOR_BASE + dd->ipath_unit, name, |
104 | &diag_file_ops, &dd->diag_cdev, | 104 | &diag_file_ops, &dd->diag_cdev, |
105 | &dd->diag_class_dev); | 105 | &dd->diag_dev); |
106 | if (ret) | 106 | if (ret) |
107 | ipath_dev_err(dd, "Couldn't create %s device: %d", | 107 | ipath_dev_err(dd, "Couldn't create %s device: %d", |
108 | name, ret); | 108 | name, ret); |
@@ -114,9 +114,9 @@ done: | |||
114 | void ipath_diag_remove(struct ipath_devdata *dd) | 114 | void ipath_diag_remove(struct ipath_devdata *dd) |
115 | { | 115 | { |
116 | if (atomic_dec_and_test(&diagpkt_count)) | 116 | if (atomic_dec_and_test(&diagpkt_count)) |
117 | ipath_cdev_cleanup(&diagpkt_cdev, &diagpkt_class_dev); | 117 | ipath_cdev_cleanup(&diagpkt_cdev, &diagpkt_dev); |
118 | 118 | ||
119 | ipath_cdev_cleanup(&dd->diag_cdev, &dd->diag_class_dev); | 119 | ipath_cdev_cleanup(&dd->diag_cdev, &dd->diag_dev); |
120 | } | 120 | } |
121 | 121 | ||
122 | /** | 122 | /** |
diff --git a/drivers/infiniband/hw/ipath/ipath_file_ops.c b/drivers/infiniband/hw/ipath/ipath_file_ops.c index 1e627aab18bf..8b1752202e78 100644 --- a/drivers/infiniband/hw/ipath/ipath_file_ops.c +++ b/drivers/infiniband/hw/ipath/ipath_file_ops.c | |||
@@ -2434,11 +2434,11 @@ static ssize_t ipath_writev(struct kiocb *iocb, const struct iovec *iov, | |||
2434 | static struct class *ipath_class; | 2434 | static struct class *ipath_class; |
2435 | 2435 | ||
2436 | static int init_cdev(int minor, char *name, const struct file_operations *fops, | 2436 | static int init_cdev(int minor, char *name, const struct file_operations *fops, |
2437 | struct cdev **cdevp, struct class_device **class_devp) | 2437 | struct cdev **cdevp, struct device **devp) |
2438 | { | 2438 | { |
2439 | const dev_t dev = MKDEV(IPATH_MAJOR, minor); | 2439 | const dev_t dev = MKDEV(IPATH_MAJOR, minor); |
2440 | struct cdev *cdev = NULL; | 2440 | struct cdev *cdev = NULL; |
2441 | struct class_device *class_dev = NULL; | 2441 | struct device *device = NULL; |
2442 | int ret; | 2442 | int ret; |
2443 | 2443 | ||
2444 | cdev = cdev_alloc(); | 2444 | cdev = cdev_alloc(); |
@@ -2462,12 +2462,12 @@ static int init_cdev(int minor, char *name, const struct file_operations *fops, | |||
2462 | goto err_cdev; | 2462 | goto err_cdev; |
2463 | } | 2463 | } |
2464 | 2464 | ||
2465 | class_dev = class_device_create(ipath_class, NULL, dev, NULL, name); | 2465 | device = device_create(ipath_class, NULL, dev, name); |
2466 | 2466 | ||
2467 | if (IS_ERR(class_dev)) { | 2467 | if (IS_ERR(device)) { |
2468 | ret = PTR_ERR(class_dev); | 2468 | ret = PTR_ERR(device); |
2469 | printk(KERN_ERR IPATH_DRV_NAME ": Could not create " | 2469 | printk(KERN_ERR IPATH_DRV_NAME ": Could not create " |
2470 | "class_dev for minor %d, %s (err %d)\n", | 2470 | "device for minor %d, %s (err %d)\n", |
2471 | minor, name, -ret); | 2471 | minor, name, -ret); |
2472 | goto err_cdev; | 2472 | goto err_cdev; |
2473 | } | 2473 | } |
@@ -2481,29 +2481,29 @@ err_cdev: | |||
2481 | done: | 2481 | done: |
2482 | if (ret >= 0) { | 2482 | if (ret >= 0) { |
2483 | *cdevp = cdev; | 2483 | *cdevp = cdev; |
2484 | *class_devp = class_dev; | 2484 | *devp = device; |
2485 | } else { | 2485 | } else { |
2486 | *cdevp = NULL; | 2486 | *cdevp = NULL; |
2487 | *class_devp = NULL; | 2487 | *devp = NULL; |
2488 | } | 2488 | } |
2489 | 2489 | ||
2490 | return ret; | 2490 | return ret; |
2491 | } | 2491 | } |
2492 | 2492 | ||
2493 | int ipath_cdev_init(int minor, char *name, const struct file_operations *fops, | 2493 | int ipath_cdev_init(int minor, char *name, const struct file_operations *fops, |
2494 | struct cdev **cdevp, struct class_device **class_devp) | 2494 | struct cdev **cdevp, struct device **devp) |
2495 | { | 2495 | { |
2496 | return init_cdev(minor, name, fops, cdevp, class_devp); | 2496 | return init_cdev(minor, name, fops, cdevp, devp); |
2497 | } | 2497 | } |
2498 | 2498 | ||
2499 | static void cleanup_cdev(struct cdev **cdevp, | 2499 | static void cleanup_cdev(struct cdev **cdevp, |
2500 | struct class_device **class_devp) | 2500 | struct device **devp) |
2501 | { | 2501 | { |
2502 | struct class_device *class_dev = *class_devp; | 2502 | struct device *dev = *devp; |
2503 | 2503 | ||
2504 | if (class_dev) { | 2504 | if (dev) { |
2505 | class_device_unregister(class_dev); | 2505 | device_unregister(dev); |
2506 | *class_devp = NULL; | 2506 | *devp = NULL; |
2507 | } | 2507 | } |
2508 | 2508 | ||
2509 | if (*cdevp) { | 2509 | if (*cdevp) { |
@@ -2513,13 +2513,13 @@ static void cleanup_cdev(struct cdev **cdevp, | |||
2513 | } | 2513 | } |
2514 | 2514 | ||
2515 | void ipath_cdev_cleanup(struct cdev **cdevp, | 2515 | void ipath_cdev_cleanup(struct cdev **cdevp, |
2516 | struct class_device **class_devp) | 2516 | struct device **devp) |
2517 | { | 2517 | { |
2518 | cleanup_cdev(cdevp, class_devp); | 2518 | cleanup_cdev(cdevp, devp); |
2519 | } | 2519 | } |
2520 | 2520 | ||
2521 | static struct cdev *wildcard_cdev; | 2521 | static struct cdev *wildcard_cdev; |
2522 | static struct class_device *wildcard_class_dev; | 2522 | static struct device *wildcard_dev; |
2523 | 2523 | ||
2524 | static const dev_t dev = MKDEV(IPATH_MAJOR, 0); | 2524 | static const dev_t dev = MKDEV(IPATH_MAJOR, 0); |
2525 | 2525 | ||
@@ -2576,7 +2576,7 @@ int ipath_user_add(struct ipath_devdata *dd) | |||
2576 | goto bail; | 2576 | goto bail; |
2577 | } | 2577 | } |
2578 | ret = init_cdev(0, "ipath", &ipath_file_ops, &wildcard_cdev, | 2578 | ret = init_cdev(0, "ipath", &ipath_file_ops, &wildcard_cdev, |
2579 | &wildcard_class_dev); | 2579 | &wildcard_dev); |
2580 | if (ret < 0) { | 2580 | if (ret < 0) { |
2581 | ipath_dev_err(dd, "Could not create wildcard " | 2581 | ipath_dev_err(dd, "Could not create wildcard " |
2582 | "minor: error %d\n", -ret); | 2582 | "minor: error %d\n", -ret); |
@@ -2589,7 +2589,7 @@ int ipath_user_add(struct ipath_devdata *dd) | |||
2589 | snprintf(name, sizeof(name), "ipath%d", dd->ipath_unit); | 2589 | snprintf(name, sizeof(name), "ipath%d", dd->ipath_unit); |
2590 | 2590 | ||
2591 | ret = init_cdev(dd->ipath_unit + 1, name, &ipath_file_ops, | 2591 | ret = init_cdev(dd->ipath_unit + 1, name, &ipath_file_ops, |
2592 | &dd->user_cdev, &dd->user_class_dev); | 2592 | &dd->user_cdev, &dd->user_dev); |
2593 | if (ret < 0) | 2593 | if (ret < 0) |
2594 | ipath_dev_err(dd, "Could not create user minor %d, %s\n", | 2594 | ipath_dev_err(dd, "Could not create user minor %d, %s\n", |
2595 | dd->ipath_unit + 1, name); | 2595 | dd->ipath_unit + 1, name); |
@@ -2604,13 +2604,13 @@ bail: | |||
2604 | 2604 | ||
2605 | void ipath_user_remove(struct ipath_devdata *dd) | 2605 | void ipath_user_remove(struct ipath_devdata *dd) |
2606 | { | 2606 | { |
2607 | cleanup_cdev(&dd->user_cdev, &dd->user_class_dev); | 2607 | cleanup_cdev(&dd->user_cdev, &dd->user_dev); |
2608 | 2608 | ||
2609 | if (atomic_dec_return(&user_count) == 0) { | 2609 | if (atomic_dec_return(&user_count) == 0) { |
2610 | if (atomic_read(&user_setup) == 0) | 2610 | if (atomic_read(&user_setup) == 0) |
2611 | goto bail; | 2611 | goto bail; |
2612 | 2612 | ||
2613 | cleanup_cdev(&wildcard_cdev, &wildcard_class_dev); | 2613 | cleanup_cdev(&wildcard_cdev, &wildcard_dev); |
2614 | user_cleanup(); | 2614 | user_cleanup(); |
2615 | 2615 | ||
2616 | atomic_set(&user_setup, 0); | 2616 | atomic_set(&user_setup, 0); |
diff --git a/drivers/infiniband/hw/ipath/ipath_kernel.h b/drivers/infiniband/hw/ipath/ipath_kernel.h index 5863cbe99303..202337ae90dc 100644 --- a/drivers/infiniband/hw/ipath/ipath_kernel.h +++ b/drivers/infiniband/hw/ipath/ipath_kernel.h | |||
@@ -466,8 +466,8 @@ struct ipath_devdata { | |||
466 | struct pci_dev *pcidev; | 466 | struct pci_dev *pcidev; |
467 | struct cdev *user_cdev; | 467 | struct cdev *user_cdev; |
468 | struct cdev *diag_cdev; | 468 | struct cdev *diag_cdev; |
469 | struct class_device *user_class_dev; | 469 | struct device *user_dev; |
470 | struct class_device *diag_class_dev; | 470 | struct device *diag_dev; |
471 | /* timer used to prevent stats overflow, error throttling, etc. */ | 471 | /* timer used to prevent stats overflow, error throttling, etc. */ |
472 | struct timer_list ipath_stats_timer; | 472 | struct timer_list ipath_stats_timer; |
473 | /* timer to verify interrupts work, and fallback if possible */ | 473 | /* timer to verify interrupts work, and fallback if possible */ |
@@ -854,9 +854,9 @@ void ipath_clear_freeze(struct ipath_devdata *); | |||
854 | 854 | ||
855 | struct file_operations; | 855 | struct file_operations; |
856 | int ipath_cdev_init(int minor, char *name, const struct file_operations *fops, | 856 | int ipath_cdev_init(int minor, char *name, const struct file_operations *fops, |
857 | struct cdev **cdevp, struct class_device **class_devp); | 857 | struct cdev **cdevp, struct device **devp); |
858 | void ipath_cdev_cleanup(struct cdev **cdevp, | 858 | void ipath_cdev_cleanup(struct cdev **cdevp, |
859 | struct class_device **class_devp); | 859 | struct device **devp); |
860 | 860 | ||
861 | int ipath_diag_add(struct ipath_devdata *); | 861 | int ipath_diag_add(struct ipath_devdata *); |
862 | void ipath_diag_remove(struct ipath_devdata *); | 862 | void ipath_diag_remove(struct ipath_devdata *); |
diff --git a/drivers/infiniband/hw/ipath/ipath_verbs.c b/drivers/infiniband/hw/ipath/ipath_verbs.c index 320a6d018de7..c38f9aa8be8d 100644 --- a/drivers/infiniband/hw/ipath/ipath_verbs.c +++ b/drivers/infiniband/hw/ipath/ipath_verbs.c | |||
@@ -2172,18 +2172,20 @@ void ipath_unregister_ib_device(struct ipath_ibdev *dev) | |||
2172 | ib_dealloc_device(ibdev); | 2172 | ib_dealloc_device(ibdev); |
2173 | } | 2173 | } |
2174 | 2174 | ||
2175 | static ssize_t show_rev(struct class_device *cdev, char *buf) | 2175 | static ssize_t show_rev(struct device *device, struct device_attribute *attr, |
2176 | char *buf) | ||
2176 | { | 2177 | { |
2177 | struct ipath_ibdev *dev = | 2178 | struct ipath_ibdev *dev = |
2178 | container_of(cdev, struct ipath_ibdev, ibdev.class_dev); | 2179 | container_of(device, struct ipath_ibdev, ibdev.dev); |
2179 | 2180 | ||
2180 | return sprintf(buf, "%x\n", dev->dd->ipath_pcirev); | 2181 | return sprintf(buf, "%x\n", dev->dd->ipath_pcirev); |
2181 | } | 2182 | } |
2182 | 2183 | ||
2183 | static ssize_t show_hca(struct class_device *cdev, char *buf) | 2184 | static ssize_t show_hca(struct device *device, struct device_attribute *attr, |
2185 | char *buf) | ||
2184 | { | 2186 | { |
2185 | struct ipath_ibdev *dev = | 2187 | struct ipath_ibdev *dev = |
2186 | container_of(cdev, struct ipath_ibdev, ibdev.class_dev); | 2188 | container_of(device, struct ipath_ibdev, ibdev.dev); |
2187 | int ret; | 2189 | int ret; |
2188 | 2190 | ||
2189 | ret = dev->dd->ipath_f_get_boardname(dev->dd, buf, 128); | 2191 | ret = dev->dd->ipath_f_get_boardname(dev->dd, buf, 128); |
@@ -2196,10 +2198,11 @@ bail: | |||
2196 | return ret; | 2198 | return ret; |
2197 | } | 2199 | } |
2198 | 2200 | ||
2199 | static ssize_t show_stats(struct class_device *cdev, char *buf) | 2201 | static ssize_t show_stats(struct device *device, struct device_attribute *attr, |
2202 | char *buf) | ||
2200 | { | 2203 | { |
2201 | struct ipath_ibdev *dev = | 2204 | struct ipath_ibdev *dev = |
2202 | container_of(cdev, struct ipath_ibdev, ibdev.class_dev); | 2205 | container_of(device, struct ipath_ibdev, ibdev.dev); |
2203 | int i; | 2206 | int i; |
2204 | int len; | 2207 | int len; |
2205 | 2208 | ||
@@ -2237,16 +2240,16 @@ static ssize_t show_stats(struct class_device *cdev, char *buf) | |||
2237 | return len; | 2240 | return len; |
2238 | } | 2241 | } |
2239 | 2242 | ||
2240 | static CLASS_DEVICE_ATTR(hw_rev, S_IRUGO, show_rev, NULL); | 2243 | static DEVICE_ATTR(hw_rev, S_IRUGO, show_rev, NULL); |
2241 | static CLASS_DEVICE_ATTR(hca_type, S_IRUGO, show_hca, NULL); | 2244 | static DEVICE_ATTR(hca_type, S_IRUGO, show_hca, NULL); |
2242 | static CLASS_DEVICE_ATTR(board_id, S_IRUGO, show_hca, NULL); | 2245 | static DEVICE_ATTR(board_id, S_IRUGO, show_hca, NULL); |
2243 | static CLASS_DEVICE_ATTR(stats, S_IRUGO, show_stats, NULL); | 2246 | static DEVICE_ATTR(stats, S_IRUGO, show_stats, NULL); |
2244 | 2247 | ||
2245 | static struct class_device_attribute *ipath_class_attributes[] = { | 2248 | static struct device_attribute *ipath_class_attributes[] = { |
2246 | &class_device_attr_hw_rev, | 2249 | &dev_attr_hw_rev, |
2247 | &class_device_attr_hca_type, | 2250 | &dev_attr_hca_type, |
2248 | &class_device_attr_board_id, | 2251 | &dev_attr_board_id, |
2249 | &class_device_attr_stats | 2252 | &dev_attr_stats |
2250 | }; | 2253 | }; |
2251 | 2254 | ||
2252 | static int ipath_verbs_register_sysfs(struct ib_device *dev) | 2255 | static int ipath_verbs_register_sysfs(struct ib_device *dev) |
@@ -2255,8 +2258,8 @@ static int ipath_verbs_register_sysfs(struct ib_device *dev) | |||
2255 | int ret; | 2258 | int ret; |
2256 | 2259 | ||
2257 | for (i = 0; i < ARRAY_SIZE(ipath_class_attributes); ++i) | 2260 | for (i = 0; i < ARRAY_SIZE(ipath_class_attributes); ++i) |
2258 | if (class_device_create_file(&dev->class_dev, | 2261 | if (device_create_file(&dev->dev, |
2259 | ipath_class_attributes[i])) { | 2262 | ipath_class_attributes[i])) { |
2260 | ret = 1; | 2263 | ret = 1; |
2261 | goto bail; | 2264 | goto bail; |
2262 | } | 2265 | } |