diff options
author | Samuel Iglesias Gonsalvez <siglesias@igalia.com> | 2013-03-08 09:21:47 +0100 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-03-15 12:23:09 -0700 |
commit | e926301b39a07f587ff8c66354a2e2ee4c29162c (patch) | |
tree | 407121dd6ef41bfa48681e2ed4f7f48bf85b5f40 /include/linux/ipack.h | |
parent | fa882867ae5f8543eb304a1667563f1c99514475 (diff) | |
download | linux-stable-e926301b39a07f587ff8c66354a2e2ee4c29162c.tar.gz linux-stable-e926301b39a07f587ff8c66354a2e2ee4c29162c.tar.bz2 linux-stable-e926301b39a07f587ff8c66354a2e2ee4c29162c.zip |
ipack: split ipack_device_register() in several functions
One function is ipack_device_init(). If it fails, the caller should execute
ipack_put_device().
The second function is ipack_device_add that only adds the device. If
it fails, the caller should execute ipack_put_device().
Then the device is removed with refcount = 0, as device_register() kernel
documentation says.
ipack_device_del() is added to remove the device.
Signed-off-by: Samuel Iglesias Gonsalvez <siglesias@igalia.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'include/linux/ipack.h')
-rw-r--r-- | include/linux/ipack.h | 39 |
1 files changed, 29 insertions, 10 deletions
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, void ipack_driver_unregister(struct ipack_driver *edrv); /** - * ipack_device_register -- register an IPack device with the kernel - * @dev: the new device to register. + * ipack_device_init -- initialize an IPack device + * @dev: the new device to initialize. * - * Register a new IPack device ("module" in IndustryPack jargon). The call - * is done by the carrier driver. The carrier should populate the fields - * bus and slot as well as the region array of @dev prior to calling this - * function. The rest of the fields will be allocated and populated - * during registration. + * Initialize a new IPack device ("module" in IndustryPack jargon). The call + * is done by the carrier driver. The carrier should populate the fields + * bus and slot as well as the region array of @dev prior to calling this + * function. The rest of the fields will be allocated and populated + * during initalization. * - * Return zero on success or error code on failure. + * Return zero on success or error code on failure. + * + * NOTE: _Never_ directly free @dev after calling this function, even + * if it returned an error! Always use ipack_put_device() to give up the + * reference initialized in this function instead. + */ +int ipack_device_init(struct ipack_device *dev); + +/** + * ipack_device_add -- Add an IPack device + * @dev: the new device to add. + * + * Add a new IPack device. The call is done by the carrier driver + * after calling ipack_device_init(). + * + * Return zero on success or error code on failure. + * + * NOTE: _Never_ directly free @dev after calling this function, even + * if it returned an error! Always use ipack_put_device() to give up the + * reference initialized in this function instead. */ -int ipack_device_register(struct ipack_device *dev); -void ipack_device_unregister(struct ipack_device *dev); +int ipack_device_add(struct ipack_device *dev); +void ipack_device_del(struct ipack_device *dev); void ipack_get_device(struct ipack_device *dev); void ipack_put_device(struct ipack_device *dev); |