|
@@ -344,108 +344,56 @@ void platform_device_unregister(struct platform_device *pdev)
|
|
|
EXPORT_SYMBOL_GPL(platform_device_unregister);
|
|
|
|
|
|
/**
|
|
|
- * platform_device_register_simple - add a platform-level device and its resources
|
|
|
- * @name: base name of the device we're adding
|
|
|
- * @id: instance id
|
|
|
- * @res: set of resources that needs to be allocated for the device
|
|
|
- * @num: number of resources
|
|
|
- *
|
|
|
- * This function creates a simple platform device that requires minimal
|
|
|
- * resource and memory management. Canned release function freeing memory
|
|
|
- * allocated for the device allows drivers using such devices to be
|
|
|
- * unloaded without waiting for the last reference to the device to be
|
|
|
- * dropped.
|
|
|
+ * platform_device_register_resndata - add a platform-level device with
|
|
|
+ * resources and platform-specific data
|
|
|
*
|
|
|
- * This interface is primarily intended for use with legacy drivers which
|
|
|
- * probe hardware directly. Because such drivers create sysfs device nodes
|
|
|
- * themselves, rather than letting system infrastructure handle such device
|
|
|
- * enumeration tasks, they don't fully conform to the Linux driver model.
|
|
|
- * In particular, when such drivers are built as modules, they can't be
|
|
|
- * "hotplugged".
|
|
|
- *
|
|
|
- * Returns &struct platform_device pointer on success, or ERR_PTR() on error.
|
|
|
- */
|
|
|
-struct platform_device *platform_device_register_simple(const char *name,
|
|
|
- int id,
|
|
|
- const struct resource *res,
|
|
|
- unsigned int num)
|
|
|
-{
|
|
|
- struct platform_device *pdev;
|
|
|
- int retval;
|
|
|
-
|
|
|
- pdev = platform_device_alloc(name, id);
|
|
|
- if (!pdev) {
|
|
|
- retval = -ENOMEM;
|
|
|
- goto error;
|
|
|
- }
|
|
|
-
|
|
|
- if (num) {
|
|
|
- retval = platform_device_add_resources(pdev, res, num);
|
|
|
- if (retval)
|
|
|
- goto error;
|
|
|
- }
|
|
|
-
|
|
|
- retval = platform_device_add(pdev);
|
|
|
- if (retval)
|
|
|
- goto error;
|
|
|
-
|
|
|
- return pdev;
|
|
|
-
|
|
|
-error:
|
|
|
- platform_device_put(pdev);
|
|
|
- return ERR_PTR(retval);
|
|
|
-}
|
|
|
-EXPORT_SYMBOL_GPL(platform_device_register_simple);
|
|
|
-
|
|
|
-/**
|
|
|
- * platform_device_register_data - add a platform-level device with platform-specific data
|
|
|
* @parent: parent device for the device we're adding
|
|
|
* @name: base name of the device we're adding
|
|
|
* @id: instance id
|
|
|
+ * @res: set of resources that needs to be allocated for the device
|
|
|
+ * @num: number of resources
|
|
|
* @data: platform specific data for this platform device
|
|
|
* @size: size of platform specific data
|
|
|
*
|
|
|
- * This function creates a simple platform device that requires minimal
|
|
|
- * resource and memory management. Canned release function freeing memory
|
|
|
- * allocated for the device allows drivers using such devices to be
|
|
|
- * unloaded without waiting for the last reference to the device to be
|
|
|
- * dropped.
|
|
|
- *
|
|
|
* Returns &struct platform_device pointer on success, or ERR_PTR() on error.
|
|
|
*/
|
|
|
-struct platform_device *platform_device_register_data(
|
|
|
+struct platform_device *platform_device_register_resndata(
|
|
|
struct device *parent,
|
|
|
const char *name, int id,
|
|
|
+ const struct resource *res, unsigned int num,
|
|
|
const void *data, size_t size)
|
|
|
{
|
|
|
+ int ret = -ENOMEM;
|
|
|
struct platform_device *pdev;
|
|
|
- int retval;
|
|
|
|
|
|
pdev = platform_device_alloc(name, id);
|
|
|
- if (!pdev) {
|
|
|
- retval = -ENOMEM;
|
|
|
- goto error;
|
|
|
- }
|
|
|
+ if (!pdev)
|
|
|
+ goto err;
|
|
|
|
|
|
pdev->dev.parent = parent;
|
|
|
|
|
|
- if (size) {
|
|
|
- retval = platform_device_add_data(pdev, data, size);
|
|
|
- if (retval)
|
|
|
- goto error;
|
|
|
+ if (res) {
|
|
|
+ ret = platform_device_add_resources(pdev, res, num);
|
|
|
+ if (ret)
|
|
|
+ goto err;
|
|
|
}
|
|
|
|
|
|
- retval = platform_device_add(pdev);
|
|
|
- if (retval)
|
|
|
- goto error;
|
|
|
+ if (data) {
|
|
|
+ ret = platform_device_add_data(pdev, data, size);
|
|
|
+ if (ret)
|
|
|
+ goto err;
|
|
|
+ }
|
|
|
|
|
|
- return pdev;
|
|
|
+ ret = platform_device_add(pdev);
|
|
|
+ if (ret) {
|
|
|
+err:
|
|
|
+ platform_device_put(pdev);
|
|
|
+ return ERR_PTR(ret);
|
|
|
+ }
|
|
|
|
|
|
-error:
|
|
|
- platform_device_put(pdev);
|
|
|
- return ERR_PTR(retval);
|
|
|
+ return pdev;
|
|
|
}
|
|
|
-EXPORT_SYMBOL_GPL(platform_device_register_data);
|
|
|
+EXPORT_SYMBOL_GPL(platform_device_register_resndata);
|
|
|
|
|
|
static int platform_drv_probe(struct device *_dev)
|
|
|
{
|