mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Nigel Cunningham <nigel@suspend2.net>
To: linux-kernel@vger.kernel.org
Subject: [Suspend2][ 6/7] [Suspend2] Register and remove proc file functions.
Date: Tue, 27 Jun 2006 02:47:50 +1000	[thread overview]
Message-ID: <20060626164749.10724.12205.stgit@nigel.suspend2.net> (raw)
In-Reply-To: <20060626164729.10724.37131.stgit@nigel.suspend2.net>

Functions to add and remove a Suspend2 proc file entry.

Signed-off-by: Nigel Cunningham <nigel@suspend2.net>

 kernel/power/proc.c |   44 ++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 44 insertions(+), 0 deletions(-)

diff --git a/kernel/power/proc.c b/kernel/power/proc.c
index dad818f..9722377 100644
--- a/kernel/power/proc.c
+++ b/kernel/power/proc.c
@@ -281,3 +281,47 @@ static void suspend_initialise_proc(void
 		suspend_register_procfile(&proc_params[i]);
 }
 
+/* suspend_register_procfile
+ *
+ * Helper for registering a new /proc/suspend2 entry.
+ */
+
+struct proc_dir_entry *suspend_register_procfile(
+		struct suspend_proc_data *suspend_proc_data)
+{
+	struct proc_dir_entry *new_entry;
+	
+	if (!suspend_proc_initialised)
+		suspend_initialise_proc();
+
+	new_entry = create_proc_entry(
+			suspend_proc_data->filename,
+			suspend_proc_data->permissions, 
+			suspend_dir);
+	if (new_entry) {
+		list_add_tail(&suspend_proc_data->proc_data_list, &suspend_proc_entries);
+		new_entry->read_proc = suspend_read_proc;
+		new_entry->write_proc = suspend_write_proc;
+		new_entry->data = suspend_proc_data;
+	} else {
+		printk("Error! create_proc_entry returned NULL.\n");
+		INIT_LIST_HEAD(&suspend_proc_data->proc_data_list);
+	}
+	return new_entry;
+}
+
+/* suspend_unregister_procfile
+ *
+ * Helper for removing unwanted /proc/suspend2 entries.
+ *
+ */
+void suspend_unregister_procfile(struct suspend_proc_data *suspend_proc_data)
+{
+	if (list_empty(&suspend_proc_data->proc_data_list))
+		return;
+
+	remove_proc_entry(
+		suspend_proc_data->filename,
+		suspend_dir);
+	list_del(&suspend_proc_data->proc_data_list);
+}

--
Nigel Cunningham		nigel at suspend2 dot net

  parent reply	other threads:[~2006-06-26 16:48 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-06-26 16:47 [Suspend2][ 0/7] Proc file support Nigel Cunningham
2006-06-26 16:47 ` [Suspend2][ 1/7] [Suspend2] Proc.c header Nigel Cunningham
2006-06-26 16:47 ` [Suspend2][ 2/7] [Suspend2] Read a proc file entry Nigel Cunningham
2006-06-26 16:47 ` [Suspend2][ 3/7] [Suspend2] Proc write routine Nigel Cunningham
2006-06-26 16:47 ` [Suspend2][ 4/7] [Suspend2] Basic (do_suspend/do_resume) entries Nigel Cunningham
2006-06-26 16:47 ` [Suspend2][ 5/7] [Suspend2] Initialise the proc directories & basic entries Nigel Cunningham
2006-06-26 16:47 ` Nigel Cunningham [this message]
2006-06-26 16:47 ` [Suspend2][ 7/7] [Suspend2] Suspend2 proc.h Nigel Cunningham
2006-06-26 20:07 ` [Suspend2][ 0/7] Proc file support Rafael J. Wysocki
2006-06-26 22:50   ` Nigel Cunningham
2006-06-27 21:00     ` Rafael J. Wysocki

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=20060626164749.10724.12205.stgit@nigel.suspend2.net \
    --to=nigel@suspend2.net \
    --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

all inboxes | Powered by JetHome®