From patchwork Mon Apr 25 20:20:28 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 1175 Return-Path: Delivered-To: unknown Received: from imap.gmail.com (74.125.159.109) by localhost6.localdomain6 with IMAP4-SSL; 08 Jun 2011 14:49:53 -0000 Delivered-To: patches@linaro.org Received: by 10.224.2.73 with SMTP id 9cs48747qai; Mon, 25 Apr 2011 13:21:04 -0700 (PDT) Received: by 10.150.169.8 with SMTP id r8mr3431318ybe.447.1303762863820; Mon, 25 Apr 2011 13:21:03 -0700 (PDT) Received: from e38.co.us.ibm.com (e38.co.us.ibm.com [32.97.110.159]) by mx.google.com with ESMTPS id q17si15653538ybk.23.2011.04.25.13.21.02 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 25 Apr 2011 13:21:02 -0700 (PDT) Received-SPF: pass (google.com: domain of jstultz@us.ibm.com designates 32.97.110.159 as permitted sender) client-ip=32.97.110.159; Authentication-Results: mx.google.com; spf=pass (google.com: domain of jstultz@us.ibm.com designates 32.97.110.159 as permitted sender) smtp.mail=jstultz@us.ibm.com Received: from d03relay01.boulder.ibm.com (d03relay01.boulder.ibm.com [9.17.195.226]) by e38.co.us.ibm.com (8.14.4/8.13.1) with ESMTP id p3PCZFIP005997; Mon, 25 Apr 2011 06:35:15 -0600 Received: from d03av03.boulder.ibm.com (d03av03.boulder.ibm.com [9.17.195.169]) by d03relay01.boulder.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id p3PKKg9r035484; Mon, 25 Apr 2011 14:20:42 -0600 Received: from d03av03.boulder.ibm.com (loopback [127.0.0.1]) by d03av03.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id p3PKKg2P014192; Mon, 25 Apr 2011 14:20:42 -0600 Received: from kernel.beaverton.ibm.com (kernel.beaverton.ibm.com [9.47.67.96]) by d03av03.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id p3PKKgb7014163; Mon, 25 Apr 2011 14:20:42 -0600 Received: by kernel.beaverton.ibm.com (Postfix, from userid 1056) id 882A81E7510; Mon, 25 Apr 2011 13:20:41 -0700 (PDT) From: John Stultz To: LKML Cc: Akihiro MAEDA , Anton Vorontsov , John Stultz Subject: [PATCH 2/3][RFC] power: virtual battery driver tweaks Date: Mon, 25 Apr 2011 13:20:28 -0700 Message-Id: <1303762829-18000-3-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 1.7.3.2.146.gca209 In-Reply-To: <1303762829-18000-1-git-send-email-john.stultz@linaro.org> References: <1303762829-18000-1-git-send-email-john.stultz@linaro.org> From: Akihiro MAEDA This patch tweaks the virtual battery driver, setting arguments as const and adding new kernel_param_ops. CC: Anton Vorontsov Signed-off-by: Akihiro MAEDA [john.stultz: Reworded commit log] Signed-off-by: John Stultz --- drivers/power/virtual_battery.c | 53 ++++++++++++++++++++++++++++++-------- 1 files changed, 42 insertions(+), 11 deletions(-) diff --git a/drivers/power/virtual_battery.c b/drivers/power/virtual_battery.c index 4ae79d4..ed686ef 100644 --- a/drivers/power/virtual_battery.c +++ b/drivers/power/virtual_battery.c @@ -5,6 +5,7 @@ * * Copyright (C) 2008 Pylone, Inc. * Author: Masashi YOKOTA + * Modified by: Akihiro MAEDA * * This software is licensed under the terms of the GNU General Public * License version 2, as published by the Free Software Foundation, and @@ -190,7 +191,7 @@ static const char * map_get_key(struct battery_property_map * map, int value, co return def_key; } -static int param_set_ac_status(const char *key, struct kernel_param *kp) +static int param_set_ac_status(const char *key, const struct kernel_param *kp) { dev_dbg(&bat_pdev->dev, "%s: name=%s, key=%s\n", __func__, kp->name, key); ac_status = map_get_value( map_ac_online, key, ac_status); @@ -198,14 +199,14 @@ static int param_set_ac_status(const char *key, struct kernel_param *kp) return 0; } -static int param_get_ac_status(char *buffer, struct kernel_param *kp) +static int param_get_ac_status(char *buffer, const struct kernel_param *kp) { dev_dbg(&bat_pdev->dev, "%s: name=%s\n", __func__, kp->name); strcpy(buffer, map_get_key( map_ac_online, ac_status, "unknown")); return strlen(buffer); } -static int param_set_battery_status(const char *key, struct kernel_param *kp) +static int param_set_battery_status(const char *key, const struct kernel_param *kp) { dev_dbg(&bat_pdev->dev, "%s: name=%s, key=%s.\n", __func__, kp->name, key); battery_status = map_get_value( map_status, key, battery_status); @@ -213,14 +214,14 @@ static int param_set_battery_status(const char *key, struct kernel_param *kp) return 0; } -static int param_get_battery_status(char *buffer, struct kernel_param *kp) +static int param_get_battery_status(char *buffer, const struct kernel_param *kp) { dev_dbg(&bat_pdev->dev, "%s: name=%s\n", __func__, kp->name); strcpy(buffer, map_get_key( map_status, battery_status, "unknown")); return strlen(buffer); } -static int param_set_battery_health(const char *key, struct kernel_param *kp) +static int param_set_battery_health(const char *key, const struct kernel_param *kp) { dev_dbg(&bat_pdev->dev, "%s: name=%s, key=%s\n", __func__, kp->name, key); battery_health = map_get_value( map_health, key, battery_health); @@ -228,14 +229,14 @@ static int param_set_battery_health(const char *key, struct kernel_param *kp) return 0; } -static int param_get_battery_health(char *buffer, struct kernel_param *kp) +static int param_get_battery_health(char *buffer, const struct kernel_param *kp) { dev_dbg(&bat_pdev->dev, "%s: name=%s\n", __func__, kp->name); strcpy(buffer, map_get_key( map_health, battery_health, "unknown")); return strlen(buffer); } -static int param_set_battery_present(const char *key, struct kernel_param *kp) +static int param_set_battery_present(const char *key, const struct kernel_param *kp) { dev_dbg(&bat_pdev->dev, "%s: name=%s, key=%s\n", __func__, kp->name, key); battery_present = map_get_value( map_present, key, battery_present); @@ -243,14 +244,14 @@ static int param_set_battery_present(const char *key, struct kernel_param *kp) return 0; } -static int param_get_battery_present(char *buffer, struct kernel_param *kp) +static int param_get_battery_present(char *buffer, const struct kernel_param *kp) { dev_dbg(&bat_pdev->dev, "%s: name=%s\n", __func__, kp->name); strcpy(buffer, map_get_key( map_present, battery_present, "unknown")); return strlen(buffer); } -static int param_set_battery_technology(const char *key, struct kernel_param *kp) +static int param_set_battery_technology(const char *key, const struct kernel_param *kp) { dev_dbg(&bat_pdev->dev, "%s: name=%s, key=%s\n", __func__, kp->name, key); battery_technology = map_get_value( map_technology, key, battery_technology); @@ -258,14 +259,14 @@ static int param_set_battery_technology(const char *key, struct kernel_param *kp return 0; } -static int param_get_battery_technology(char *buffer, struct kernel_param *kp) +static int param_get_battery_technology(char *buffer, const struct kernel_param *kp) { dev_dbg(&bat_pdev->dev, "%s: name=%s\n", __func__, kp->name); strcpy(buffer, map_get_key( map_technology, battery_technology, "unknown")); return strlen(buffer); } -static int param_set_battery_capacity(const char *key, struct kernel_param *kp) +static int param_set_battery_capacity(const char *key, const struct kernel_param *kp) { int tmp; @@ -314,6 +315,36 @@ static void __exit virtual_battery_exit(void) printk(KERN_INFO KBUILD_BASENAME": unregistered \n"); } +static struct kernel_param_ops param_ops_ac_status = { + .set = param_set_ac_status, + .get = param_get_ac_status, +}; + +static struct kernel_param_ops param_ops_battery_status = { + .set = param_set_battery_status, + .get = param_get_battery_status, +}; + +static struct kernel_param_ops param_ops_battery_present = { + .set = param_set_battery_present, + .get = param_get_battery_present, +}; + +static struct kernel_param_ops param_ops_battery_technology = { + .set = param_set_battery_technology, + .get = param_get_battery_technology, +}; + +static struct kernel_param_ops param_ops_battery_health = { + .set = param_set_battery_health, + .get = param_get_battery_health, +}; + +static struct kernel_param_ops param_ops_battery_capacity = { + .set = param_set_battery_capacity, + .get = param_get_battery_capacity, +}; + module_init(virtual_battery_init); module_exit(virtual_battery_exit);