From: John Stultz <john.stultz@linaro.org>
To: LKML <linux-kernel@vger.kernel.org>
Cc: Akihiro MAEDA <sola.1980.a@gmail.com>,
Anton Vorontsov <cbouatmailru@gmail.com>,
John Stultz <john.stultz@linaro.org>
Subject: [PATCH 2/3][RFC] power: virtual battery driver tweaks
Date: Mon, 25 Apr 2011 13:20:28 -0700 [thread overview]
Message-ID: <1303762829-18000-3-git-send-email-john.stultz@linaro.org> (raw)
In-Reply-To: <1303762829-18000-1-git-send-email-john.stultz@linaro.org>
From: Akihiro MAEDA <sola.1980.a@gmail.com>
This patch tweaks the virtual battery driver, setting
arguments as const and adding new kernel_param_ops.
CC: Anton Vorontsov <cbouatmailru@gmail.com>
Signed-off-by: Akihiro MAEDA <sola.1980.a@gmail.com>
[john.stultz: Reworded commit log]
Signed-off-by: John Stultz <john.stultz@linaro.org>
---
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 <yokota@pylone.jp>
+ * Modified by: Akihiro MAEDA <sola.1980.a@gmail.com>
*
* 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);
--
1.7.3.2.146.gca209
next prev parent reply other threads:[~2011-04-25 20:21 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-25 20:20 [PATCH 0/3][RFC] Virtual Battery Driver John Stultz
2011-04-25 20:20 ` [PATCH 1/3][RFC] power: Add virtual battery driver John Stultz
2011-04-25 20:20 ` John Stultz [this message]
2011-04-25 20:20 ` [PATCH 3/3][RFC] power: Fixup stack usage in vritual " John Stultz
2011-04-25 21:11 ` [PATCH 0/3][RFC] Virtual Battery Driver Anton Vorontsov
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=1303762829-18000-3-git-send-email-john.stultz@linaro.org \
--to=john.stultz@linaro.org \
--cc=cbouatmailru@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=sola.1980.a@gmail.com \
/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