diff options
-rw-r--r-- | drivers/ipack/carriers/tpci200.c | 14 | ||||
-rw-r--r-- | drivers/ipack/ipack.c | 24 | ||||
-rw-r--r-- | include/linux/ipack.h | 39 |
3 files changed, 56 insertions, 21 deletions
diff --git a/drivers/ipack/carriers/tpci200.c b/drivers/ipack/carriers/tpci200.c index 0246b1fddffe..c276fde318e5 100644 --- a/drivers/ipack/carriers/tpci200.c +++ b/drivers/ipack/carriers/tpci200.c | |||
@@ -480,6 +480,7 @@ static void tpci200_release_device(struct ipack_device *dev) | |||
480 | 480 | ||
481 | static int tpci200_create_device(struct tpci200_board *tpci200, int i) | 481 | static int tpci200_create_device(struct tpci200_board *tpci200, int i) |
482 | { | 482 | { |
483 | int ret; | ||
483 | enum ipack_space space; | 484 | enum ipack_space space; |
484 | struct ipack_device *dev = | 485 | struct ipack_device *dev = |
485 | kzalloc(sizeof(struct ipack_device), GFP_KERNEL); | 486 | kzalloc(sizeof(struct ipack_device), GFP_KERNEL); |
@@ -495,7 +496,18 @@ static int tpci200_create_device(struct tpci200_board *tpci200, int i) | |||
495 | + tpci200_space_interval[space] * i; | 496 | + tpci200_space_interval[space] * i; |
496 | dev->region[space].size = tpci200_space_size[space]; | 497 | dev->region[space].size = tpci200_space_size[space]; |
497 | } | 498 | } |
498 | return ipack_device_register(dev); | 499 | |
500 | ret = ipack_device_init(dev); | ||
501 | if (ret < 0) { | ||
502 | ipack_put_device(dev); | ||
503 | return ret; | ||
504 | } | ||
505 | |||
506 | ret = ipack_device_add(dev); | ||
507 | if (ret < 0) | ||
508 | ipack_put_device(dev); | ||
509 | |||
510 | return ret; | ||
499 | } | 511 | } |
500 | 512 | ||
501 | static int tpci200_pci_probe(struct pci_dev *pdev, | 513 | static int tpci200_pci_probe(struct pci_dev *pdev, |
diff --git a/drivers/ipack/ipack.c b/drivers/ipack/ipack.c index 4f913aa88971..6e066c53acce 100644 --- a/drivers/ipack/ipack.c +++ b/drivers/ipack/ipack.c | |||
@@ -227,7 +227,7 @@ static int ipack_unregister_bus_member(struct device *dev, void *data) | |||
227 | struct ipack_bus_device *bus = data; | 227 | struct ipack_bus_device *bus = data; |
228 | 228 | ||
229 | if (idev->bus == bus) | 229 | if (idev->bus == bus) |
230 | ipack_device_unregister(idev); | 230 | ipack_device_del(idev); |
231 | 231 | ||
232 | return 1; | 232 | return 1; |
233 | } | 233 | } |
@@ -419,7 +419,7 @@ out: | |||
419 | return ret; | 419 | return ret; |
420 | } | 420 | } |
421 | 421 | ||
422 | int ipack_device_register(struct ipack_device *dev) | 422 | int ipack_device_init(struct ipack_device *dev) |
423 | { | 423 | { |
424 | int ret; | 424 | int ret; |
425 | 425 | ||
@@ -428,6 +428,7 @@ int ipack_device_register(struct ipack_device *dev) | |||
428 | dev->dev.parent = dev->bus->parent; | 428 | dev->dev.parent = dev->bus->parent; |
429 | dev_set_name(&dev->dev, | 429 | dev_set_name(&dev->dev, |
430 | "ipack-dev.%u.%u", dev->bus->bus_nr, dev->slot); | 430 | "ipack-dev.%u.%u", dev->bus->bus_nr, dev->slot); |
431 | device_initialize(&dev->dev); | ||
431 | 432 | ||
432 | if (dev->bus->ops->set_clockrate(dev, 8)) | 433 | if (dev->bus->ops->set_clockrate(dev, 8)) |
433 | dev_warn(&dev->dev, "failed to switch to 8 MHz operation for reading of device ID.\n"); | 434 | dev_warn(&dev->dev, "failed to switch to 8 MHz operation for reading of device ID.\n"); |
@@ -447,19 +448,22 @@ int ipack_device_register(struct ipack_device *dev) | |||
447 | dev_err(&dev->dev, "failed to switch to 32 MHz operation.\n"); | 448 | dev_err(&dev->dev, "failed to switch to 32 MHz operation.\n"); |
448 | } | 449 | } |
449 | 450 | ||
450 | ret = device_register(&dev->dev); | 451 | return 0; |
451 | if (ret < 0) | 452 | } |
452 | kfree(dev->id); | 453 | EXPORT_SYMBOL_GPL(ipack_device_init); |
453 | 454 | ||
454 | return ret; | 455 | int ipack_device_add(struct ipack_device *dev) |
456 | { | ||
457 | return device_add(&dev->dev); | ||
455 | } | 458 | } |
456 | EXPORT_SYMBOL_GPL(ipack_device_register); | 459 | EXPORT_SYMBOL_GPL(ipack_device_add); |
457 | 460 | ||
458 | void ipack_device_unregister(struct ipack_device *dev) | 461 | void ipack_device_del(struct ipack_device *dev) |
459 | { | 462 | { |
460 | device_unregister(&dev->dev); | 463 | device_del(&dev->dev); |
464 | ipack_put_device(dev); | ||
461 | } | 465 | } |
462 | EXPORT_SYMBOL_GPL(ipack_device_unregister); | 466 | EXPORT_SYMBOL_GPL(ipack_device_del); |
463 | 467 | ||
464 | void ipack_get_device(struct ipack_device *dev) | 468 | void ipack_get_device(struct ipack_device *dev) |
465 | { | 469 | { |
diff --git a/include/linux/ipack.h b/include/linux/ipack.h index def91fd996f4..1888e06ddf64 100644 --- a/include/linux/ipack.h +++ b/include/linux/ipack.h | |||
@@ -207,19 +207,38 @@ int ipack_driver_register(struct ipack_driver *edrv, struct module *owner, | |||
207 | void ipack_driver_unregister(struct ipack_driver *edrv); | 207 | void ipack_driver_unregister(struct ipack_driver *edrv); |
208 | 208 | ||
209 | /** | 209 | /** |
210 | * ipack_device_register -- register an IPack device with the kernel | 210 | * ipack_device_init -- initialize an IPack device |
211 | * @dev: the new device to register. | 211 | * @dev: the new device to initialize. |
212 | * | 212 | * |
213 | * Register a new IPack device ("module" in IndustryPack jargon). The call | 213 | * Initialize a new IPack device ("module" in IndustryPack jargon). The call |
214 | * is done by the carrier driver. The carrier should populate the fields | 214 | * is done by the carrier driver. The carrier should populate the fields |
215 | * bus and slot as well as the region array of @dev prior to calling this | 215 | * bus and slot as well as the region array of @dev prior to calling this |
216 | * function. The rest of the fields will be allocated and populated | 216 | * function. The rest of the fields will be allocated and populated |
217 | * during registration. | 217 | * during initalization. |
218 | * | 218 | * |
219 | * Return zero on success or error code on failure. | 219 | * Return zero on success or error code on failure. |
220 | * | ||
221 | * NOTE: _Never_ directly free @dev after calling this function, even | ||
222 | * if it returned an error! Always use ipack_put_device() to give up the | ||
223 | * reference initialized in this function instead. | ||
224 | */ | ||
225 | int ipack_device_init(struct ipack_device *dev); | ||
226 | |||
227 | /** | ||
228 | * ipack_device_add -- Add an IPack device | ||
229 | * @dev: the new device to add. | ||
230 | * | ||
231 | * Add a new IPack device. The call is done by the carrier driver | ||
232 | * after calling ipack_device_init(). | ||
233 | * | ||
234 | * Return zero on success or error code on failure. | ||
235 | * | ||
236 | * NOTE: _Never_ directly free @dev after calling this function, even | ||
237 | * if it returned an error! Always use ipack_put_device() to give up the | ||
238 | * reference initialized in this function instead. | ||
220 | */ | 239 | */ |
221 | int ipack_device_register(struct ipack_device *dev); | 240 | int ipack_device_add(struct ipack_device *dev); |
222 | void ipack_device_unregister(struct ipack_device *dev); | 241 | void ipack_device_del(struct ipack_device *dev); |
223 | 242 | ||
224 | void ipack_get_device(struct ipack_device *dev); | 243 | void ipack_get_device(struct ipack_device *dev); |
225 | void ipack_put_device(struct ipack_device *dev); | 244 | void ipack_put_device(struct ipack_device *dev); |