summaryrefslogtreecommitdiff
path: root/compat
diff options
context:
space:
mode:
authorLuis R. Rodriguez <mcgrof@do-not-panic.com>2012-12-12 11:45:05 -0800
committerLuis R. Rodriguez <mcgrof@do-not-panic.com>2012-12-12 20:39:24 -0800
commit1337db88b14e369de099e11d50a3038b64c5dfad (patch)
tree2861c387412c9f79932cb18dc967cf14585fef95 /compat
parent54783c5b8bd5798320ca948ce00fa88b3b3c8211 (diff)
compat: backport platform_device_register_data()
Add the helper. mcgrof@frijol ~/linux-next (git::master)$ git describe --contains d8bf254 v2.6.28-rc1~284^2~9 commit d8bf254089a6c31d7d01a4d1d2f1861662900855 Author: Dmitry Baryshkov <dbaryshkov@gmail.com> Date: Mon Sep 22 14:41:40 2008 -0700 platform: add new device registration helper Add a helper that registers simple platform_device w/o resources but with parent and device data. This is usefull to cleanup platform code from code that registers such simple devices as leds-gpio, generic-bl, etc. Signed-off-by: Dmitry Baryshkov <dbaryshkov@gmail.com> Cc: David Brownell <dbrownell@users.sourceforge.net> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> mcgrof@drvbp1 ~/compat (git::master)$ time ckmake Trying kernel 3.6.5-030605-generic [OK] Trying kernel 3.5.7-030507-generic [OK] Trying kernel 3.4.17-030417-generic [OK] Trying kernel 3.3.8-030308-generic [OK] Trying kernel 3.2.33-030233-generic [OK] Trying kernel 3.1.10-030110-generic [OK] Trying kernel 3.0.50-030050-generic [OK] Trying kernel 2.6.39-02063904-generic [OK] Trying kernel 2.6.38-02063808-generic [OK] Trying kernel 2.6.37-02063706-generic [OK] Trying kernel 2.6.36-02063604-generic [OK] Trying kernel 2.6.35-02063513-generic [OK] Trying kernel 2.6.34-02063413-generic [OK] Trying kernel 2.6.33-02063320-generic [OK] Trying kernel 2.6.32-02063260-generic [OK] Trying kernel 2.6.31-02063113-generic [OK] Trying kernel 2.6.30-02063010-generic [OK] Trying kernel 2.6.29-02062906-generic [OK] Trying kernel 2.6.28-02062810-generic [OK] Trying kernel 2.6.27-020627-generic [OK] Trying kernel 2.6.26-020626-generic [OK] Trying kernel 2.6.25-020625-generic [OK] Trying kernel 2.6.24-020624-generic [OK] real 1m58.798s user 3m59.967s sys 1m25.585s Signed-off-by: Luis R. Rodriguez <mcgrof@do-not-panic.com>
Diffstat (limited to 'compat')
-rw-r--r--compat/compat-2.6.28.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/compat/compat-2.6.28.c b/compat/compat-2.6.28.c
index 0ae8f465..6be54427 100644
--- a/compat/compat-2.6.28.c
+++ b/compat/compat-2.6.28.c
@@ -11,10 +11,58 @@
#include <linux/compat.h>
#include <linux/usb.h>
#include <linux/tty.h>
+#include <linux/platform_device.h>
#include <asm/poll.h>
/* 2.6.28 compat code goes here */
+/**
+ * platform_device_register_data
+ * @parent: parent device for the device we're adding
+ * @name: base name of the device we're adding
+ * @id: instance id
+ * @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.
+ */
+struct platform_device *platform_device_register_data(
+ struct device *parent,
+ const char *name, int id,
+ const void *data, size_t size)
+{
+ struct platform_device *pdev;
+ int retval;
+
+ pdev = platform_device_alloc(name, id);
+ if (!pdev) {
+ retval = -ENOMEM;
+ goto error;
+ }
+
+ pdev->dev.parent = parent;
+
+ if (size) {
+ retval = platform_device_add_data(pdev, data, size);
+ if (retval)
+ goto error;
+ }
+
+ retval = platform_device_add(pdev);
+ if (retval)
+ goto error;
+
+ return pdev;
+
+error:
+ platform_device_put(pdev);
+ return ERR_PTR(retval);
+}
+
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,23))
#if defined(CONFIG_USB) || defined(CONFIG_USB_MODULE)
/*