public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Dmitry Torokhov <dtor_core@ameritech.net>
To: linux-kernel@vger.kernel.org
Cc: Greg KH <greg@kroah.com>
Subject: [PATCH 3/3] Add platform_device_simple_release
Date: Wed, 9 Jun 2004 02:25:33 -0500	[thread overview]
Message-ID: <200406090225.35891.dtor_core@ameritech.net> (raw)
In-Reply-To: <200406090224.04876.dtor_core@ameritech.net>


===================================================================


ChangeSet@1.1837, 2004-06-09 01:36:36-05:00, dtor_core@ameritech.net
  sysfs: add platform_device_simple_release that just frees memory
         occupied by platform device. The function can be used by
         simple platform devices, when all resources except for memory
         can be deallocated beforehand. By having final release function
         in the driver core module can be unloaded without waiting for
         the last reference to the device to be dropped.
  
  Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


 drivers/base/platform.c |   21 +++++++++++++++++++++
 include/linux/device.h  |    1 +
 2 files changed, 22 insertions(+)


===================================================================



diff -Nru a/drivers/base/platform.c b/drivers/base/platform.c
--- a/drivers/base/platform.c	2004-06-09 01:40:26 -05:00
+++ b/drivers/base/platform.c	2004-06-09 01:40:26 -05:00
@@ -43,12 +43,32 @@
 	return device_register(&pdev->dev);
 }
 
+/**
+ *	platform_device_unregister - remove a platform-level device
+ *	@dev:	platform device we're removing
+ *
+ */
 void platform_device_unregister(struct platform_device * pdev)
 {
 	if (pdev)
 		device_unregister(&pdev->dev);
 }
 
+/**
+ *	platform_device_simple_release - free a platform-level device
+ *	@dev:	platform device we're freeing
+ *
+ *	This canned release function can be used for simple platform
+ *	devices. By having the function outside of driver module it
+ *	can be unloaded without waiting for the device to be released
+ *	(provided that the device has been dynamically allocated).
+ */
+void platform_device_simple_release(struct device *dev)
+{
+	struct platform_device *pdev = to_platform_device(dev);
+
+	kfree(pdev);
+}
 
 /**
  *	platform_match - bind platform device to platform driver.
@@ -117,3 +137,4 @@
 EXPORT_SYMBOL(platform_bus_type);
 EXPORT_SYMBOL(platform_device_register);
 EXPORT_SYMBOL(platform_device_unregister);
+EXPORT_SYMBOL(platform_device_simple_release);
diff -Nru a/include/linux/device.h b/include/linux/device.h
--- a/include/linux/device.h	2004-06-09 01:40:26 -05:00
+++ b/include/linux/device.h	2004-06-09 01:40:26 -05:00
@@ -386,6 +386,7 @@
 
 extern int platform_device_register(struct platform_device *);
 extern void platform_device_unregister(struct platform_device *);
+extern void platform_device_simple_release(struct device *);
 
 extern struct bus_type platform_bus_type;
 extern struct device platform_bus;

  reply	other threads:[~2004-06-09  7:32 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-06-09  7:21 [PATCH 0/3] Couple of sysfs patches Dmitry Torokhov
2004-06-09  7:22 ` [PATCH 1/3] whitespace fixes in drivers/base Dmitry Torokhov
2004-06-09  7:24   ` [PATCH 2/3] Suppress platform device suffixes Dmitry Torokhov
2004-06-09  7:25     ` Dmitry Torokhov [this message]
2004-06-09 22:13 ` [PATCH 0/3] Couple of sysfs patches Greg KH
     [not found]   ` <200406091732.28684.dtor_core@ameritech.net>
2004-06-09 22:45     ` Greg KH
     [not found]       ` <200406091754.23303.dtor_core@ameritech.net>
2004-06-09 23:19         ` Greg KH
2004-06-10  6:40           ` Dmitry Torokhov
2004-06-10  6:42             ` [PATCH 1/3] Suppress platform device suffixes - take 2 Dmitry Torokhov
2004-06-10  6:43               ` [PATCH 2/3] Add platform_device_register_simple Dmitry Torokhov
2004-06-10  6:44                 ` [PATCH 3/3] Whitespace fixes Dmitry Torokhov
2004-06-10  6:46                   ` [PATCH 4/3] Allow registering device without taking bus lock Dmitry Torokhov
2004-06-10 10:14                     ` Russell King
2004-06-10 16:02                     ` Greg KH
2004-06-10 16:26                   ` [PATCH 3/3] Whitespace fixes Greg KH
2004-06-10 10:16                 ` [PATCH 2/3] Add platform_device_register_simple Russell King
     [not found]                   ` <200406100755.59943.dtor_core@ameritech.net>
2004-06-10 13:56                     ` Russell King
2004-06-10 16:04                 ` Greg KH
2004-06-10 16:19               ` [PATCH 1/3] Suppress platform device suffixes - take 2 Greg KH

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200406090225.35891.dtor_core@ameritech.net \
    --to=dtor_core@ameritech.net \
    --cc=greg@kroah.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox