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][ 03/13] [Suspend2] Ask userspace to enable/disable access to our storage.
Date: Tue, 27 Jun 2006 14:40:35 +1000	[thread overview]
Message-ID: <20060627044034.14778.54026.stgit@nigel.suspend2.net> (raw)
In-Reply-To: <20060627044025.14778.17719.stgit@nigel.suspend2.net>

Ask userspace to do whatever it needs to do to provide us with access to
the image storage, or to tear down the access.

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

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

diff --git a/kernel/power/storage.c b/kernel/power/storage.c
index b66efe2..71b8c02 100644
--- a/kernel/power/storage.c
+++ b/kernel/power/storage.c
@@ -72,3 +72,61 @@ static int usm_user_rcv_msg(struct sk_bu
 	return 1;
 }
 
+int suspend_activate_storage(int force)
+{
+	int tries = 1;
+
+	if (usm_helper_data.pid == -1 || usm_ops.disabled)
+		return 0;
+
+	message_received = 0;
+	activations++;
+
+	if (activations > 1 && !force)
+		return 0;
+
+	while ((!message_received || message_received == USM_MSG_FAILED) && tries < 2) {
+		suspend_prepare_status(DONT_CLEAR_BAR, "Activate storage attempt %d.\n", tries);
+
+		init_completion(&usm_helper_data.wait_for_process);
+
+		suspend_send_netlink_message(&usm_helper_data,
+			USM_MSG_CONNECT,
+			NULL, 0);
+
+		/* Wait 2 seconds for the userspace process to make contact */
+		wait_for_completion_timeout(&usm_helper_data.wait_for_process, 2*HZ);
+
+		tries++;
+	}
+
+	return 0;
+}
+
+int suspend_deactivate_storage(int force)
+{
+	if (usm_helper_data.pid == -1 || usm_ops.disabled)
+		return 0;
+	
+	message_received = 0;
+	activations--;
+
+	if (activations && !force)
+		return 0;
+
+	init_completion(&usm_helper_data.wait_for_process);
+
+	suspend_send_netlink_message(&usm_helper_data,
+			USM_MSG_DISCONNECT,
+			NULL, 0);
+
+	wait_for_completion_timeout(&usm_helper_data.wait_for_process, 2*HZ);
+
+	if (!message_received || message_received == USM_MSG_FAILED) {
+		printk("Returning failure disconnecting storage.\n");
+		return 1;
+	}
+
+	return 0;
+}
+

--
Nigel Cunningham		nigel at suspend2 dot net

  parent reply	other threads:[~2006-06-27  4:54 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-06-27  4:40 [Suspend2][ 00/13] Storage manager Nigel Cunningham
2006-06-27  4:40 ` [Suspend2][ 01/13] [Suspend2] Storage.c header Nigel Cunningham
2006-06-27  4:40 ` [Suspend2][ 02/13] [Suspend2] Receive storage manager message Nigel Cunningham
2006-06-27  4:40 ` Nigel Cunningham [this message]
2006-06-27  4:40 ` [Suspend2][ 04/13] [Suspend2] Utility function for testing storage managers Nigel Cunningham
2006-06-27  4:40 ` [Suspend2][ 05/13] [Suspend2] Get storage manager space needed in image header Nigel Cunningham
2006-06-27  4:40 ` [Suspend2][ 06/13] [Suspend2] Serialise storage manager config in an " Nigel Cunningham
2006-06-27  4:40 ` [Suspend2][ 07/13] [Suspend2] Get the amount of memory needed by the storage manager Nigel Cunningham
2006-06-27  4:40 ` [Suspend2][ 08/13] [Suspend2] Prepare and cleanup " Nigel Cunningham
2006-06-27  4:40 ` [Suspend2][ 09/13] [Suspend2] Manually activate/deactivate " Nigel Cunningham
2006-06-27  4:41 ` [Suspend2][ 10/13] [Suspend2] Storage manager proc entries Nigel Cunningham
2006-06-27  4:41 ` [Suspend2][ 11/13] [Suspend2] Storage manager module ops Nigel Cunningham
2006-06-27  4:41 ` [Suspend2][ 12/13] [Suspend2] Initialisation of the storage manager on load Nigel Cunningham
2006-06-27  4:41 ` [Suspend2][ 13/13] [Suspend2] Storage manager header file Nigel Cunningham

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=20060627044034.14778.54026.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®