|
From: <far...@us...> - 2006-11-03 20:09:49
|
Revision: 660
http://svn.sourceforge.net/hackndev/?rev=660&view=rev
Author: farcaller
Date: 2006-11-03 12:09:33 -0800 (Fri, 03 Nov 2006)
Log Message:
-----------
l4p: initial commit of battery/charger classes
Added Paths:
-----------
linux4palm/linux/trunk/drivers/misc/battchargemon.c
linux4palm/linux/trunk/include/linux/battchargemon.h
Added: linux4palm/linux/trunk/drivers/misc/battchargemon.c
===================================================================
--- linux4palm/linux/trunk/drivers/misc/battchargemon.c (rev 0)
+++ linux4palm/linux/trunk/drivers/misc/battchargemon.c 2006-11-03 20:09:33 UTC (rev 660)
@@ -0,0 +1,63 @@
+/*
+ * battchargemon.c
+ *
+ * Battery and charger monitor class, mostly inspired by battery.c
+ *
+ * (c) 2006 Vladimir "Farcaller" Pouzanov <far...@gm...>
+ *
+ * You may use this code as per GPL version 2
+ *
+ * All volatges, currents, charges, and temperatures in mV, mA, mJ and
+ * tenths of a degree unless otherwise stated.
+ *
+ */
+
+#include <linux/config.h>
+#include <linux/module.h>
+#include <linux/types.h>
+#include <linux/init.h>
+#include <linux/device.h>
+#include <linux/battchargemon.h>
+
+
+
+
+static struct class battery_class = {
+ .name = "battery",
+// .hotplug = battery_class_hotplug,
+// .release = battery_class_release,
+};
+
+static struct class charger_class = {
+ .name = "charger",
+};
+
+static int __init battcharge_class_init(void)
+{
+ int ret = class_register(&battery_class);
+ if(likely(ret)) {
+ if(likely((ret = class_register(&charger_class)) == 0)) {
+ return 0;
+ } else {
+ class_unregister(&battery_class);
+ }
+ }
+ return ret;
+}
+
+static void __exit battcharge_class_exit(void)
+{
+ class_unregister(&charger_class);
+ class_unregister(&battery_class);
+}
+
+#ifdef MODULE
+module_init(battcharge_class_init);
+#else /* start early */
+subsys_initcall(battcharge_class_init);
+#endif
+module_exit(battcharge_class_exit);
+
+MODULE_DESCRIPTION("Battery and charger driver");
+MODULE_AUTHOR("Vladimir Pouzanov");
+MODULE_LICENSE("GPL");
Added: linux4palm/linux/trunk/include/linux/battchargemon.h
===================================================================
--- linux4palm/linux/trunk/include/linux/battchargemon.h (rev 0)
+++ linux4palm/linux/trunk/include/linux/battchargemon.h 2006-11-03 20:09:33 UTC (rev 660)
@@ -0,0 +1,51 @@
+/*
+ * battchargemon.h
+ *
+ * Battery and charger monitor class
+ *
+ * (c) 2006 Vladimir "Farcaller" Pouzanov <far...@gm...>
+ *
+ * You may use this code as per GPL version 2
+ *
+ */
+
+#ifndef _LINUX_BATTCHARGEMON_H
+#define _LINUX_BATTCHARGEMON_H
+
+#include <linux/device.h>
+
+struct battery {
+ struct class_device class_dev;
+ const char *name;
+ char *id;
+ int (*get_min_voltage)(struct battery *);
+ int (*get_max_voltage)(struct battery *);
+ int (*get_voltage)(struct battery *);
+
+ int (*get_current)(struct battery *);
+
+ int (*get_temp)(struct battery *);
+
+ int (*get_charge)(struct battery *);
+};
+
+struct charger {
+ struct class_device class_dev;
+ const char *name;
+
+#define CHARGER_DISCONNECTED 0
+#define CHARGER_CONNECTED 1
+ int (*get_status)(struct charger *);
+};
+
+#define BATTERY_STATUS_UNKNOWN 0
+#define BATTERY_STATUS_CHARGING 1
+#define BATTERY_STATUS_DISCHARGING 2
+#define BATTERY_STATUS_NOT_CHARGING 3
+
+extern int battery_class_register(struct battery *);
+extern void battery_class_unregister(struct battery *);
+
+
+#endif
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|