lkml.org 
[lkml]   [2006]   [Jun]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[Suspend2][ 03/13] [Suspend2] Ask userspace to enable/disable access to our storage.
    Date
    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
    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

    \
     
     \ /
      Last update: 2006-06-27 07:01    [W:0.023 / U:1.420 seconds]
    ©2003-2017 Jasper Spaans. hosted at Digital OceanAdvertise on this site