hal: Branch 'master'
Danny Kukawka
dkukawka at kemper.freedesktop.org
Wed Mar 21 02:28:49 PDT 2007
doc/spec/hal-spec-properties.xml | 24 ++++++++++++++++++------
hald/linux/device.c | 2 ++
hald/util.c | 19 +++++++++++++++++++
hald/util.h | 2 ++
tools/lshal.c | 3 ++-
5 files changed, 43 insertions(+), 7 deletions(-)
New commits:
diff-tree bef598c725c48223174e9dfc172f927fb0c274cb (from ce6d8df0c1be9518df9187660915890415287e4a)
Author: Danny Kukawka <danny.kukawka at web.de>
Date: Wed Mar 21 10:28:12 2007 +0100
change usb*.version_bcd/usb*.speed_bcd to new double keys
This adds two new keys which store the version and the speed of a USB
device as double values and not in BCD. This looks better in lshal and
should also be easier to handle by applications which consume this
information.
Set the old usb*.*_bcd properties in the spec to deprecated.
diff --git a/doc/spec/hal-spec-properties.xml b/doc/spec/hal-spec-properties.xml
index cd206d6..e7f4ae5 100644
--- a/doc/spec/hal-spec-properties.xml
+++ b/doc/spec/hal-spec-properties.xml
@@ -592,19 +592,19 @@
</row>
<row>
<entry>
- <literal>usb_device.speed_bcd</literal> (int)
+ <literal>usb_device.speed</literal> (double)
</entry>
- <entry>examples: 0x00150, 0x01200, 0x48000</entry>
+ <entry>examples: 1.5, 12.0, 480.0</entry>
<entry>Yes</entry>
- <entry>Speed of device, in Mbit/s, in BCD with two decimals</entry>
+ <entry>Speed of device, in Mbit/s</entry>
</row>
<row>
<entry>
- <literal>usb_device.version_bcd</literal> (int)
+ <literal>usb_device.version</literal> (double)
</entry>
- <entry>examples: 0x0100, 0x0110, 0x0200</entry>
+ <entry>examples: 1.0, 1.1, 2.0</entry>
<entry>Yes</entry>
- <entry>USB version of device in BCD with two decimals</entry>
+ <entry>USB version of device</entry>
</row>
<row>
<entry>
@@ -6447,6 +6447,18 @@
<entry>2008-02-28</entry>
<entry>Duplicate of system.hardware.vendor.</entry>
</row>
+ <row>
+ <entry><literal>usb_device.speed_bcd</literal> (int)</entry>
+ <entry><literal>usb_device.speed</literal> (double)</entry>
+ <entry>2008-03-21</entry>
+ <entry>changed from 'BCD with two decimals' to double</entry>
+ </row>
+ <row>
+ <entry><literal>usb_device.version_bcd</literal> (int)</entry>
+ <entry><literal>usb_device.version</literal> (double)</entry>
+ <entry>2008-03-21</entry>
+ <entry>changed from 'BCD with two decimals' to double</entry>
+ </row>
</tbody>
</tgroup>
</informaltable>
diff --git a/hald/linux/device.c b/hald/linux/device.c
index e696b1d..3936229 100644
--- a/hald/linux/device.c
+++ b/hald/linux/device.c
@@ -1557,7 +1557,9 @@ usb_add (const gchar *sysfs_path, const
hal_util_set_string_from_file (d, "usb_device.serial", sysfs_path, "serial");
hal_util_set_bcd2_from_file (d, "usb_device.speed_bcd", sysfs_path, "speed");
+ hal_util_set_double_from_file (d, "usb_device.speed", sysfs_path, "speed");
hal_util_set_bcd2_from_file (d, "usb_device.version_bcd", sysfs_path, "version");
+ hal_util_set_double_from_file (d, "usb_device.version", sysfs_path, "version");
hal_util_get_int_from_file (sysfs_path, "bmAttributes", &bmAttributes, 16);
hal_device_property_set_bool (d, "usb_device.is_self_powered", (bmAttributes & 0x40) != 0);
diff --git a/hald/util.c b/hald/util.c
index 3179277..4288c29 100644
--- a/hald/util.c
+++ b/hald/util.c
@@ -423,6 +423,25 @@ hal_util_set_string_from_file (HalDevice
return ret;
}
+gboolean
+hal_util_set_double_from_file (HalDevice *d, const gchar *key, const gchar *directory, const gchar *file)
+{
+ double value;
+ gchar *buf, *end;
+ gboolean ret;
+
+ ret = FALSE;
+
+ if ((buf = hal_util_get_string_from_file (directory, file)) != NULL) {
+ value = strtod(buf, &end);
+ if (errno != ERANGE) {
+ ret = hal_device_property_set_double (d, key, value);
+ }
+ }
+
+ return ret;
+}
+
void
hal_util_compute_udi (HalDeviceStore *store, gchar *dst, gsize dstsize, const gchar *format, ...)
{
diff --git a/hald/util.h b/hald/util.h
index 27ad0d5..4542b1b 100644
--- a/hald/util.h
+++ b/hald/util.h
@@ -65,6 +65,8 @@ gboolean hal_util_get_bcd2_from_file (co
gboolean hal_util_set_bcd2_from_file (HalDevice *d, const gchar *key, const gchar *directory, const gchar *file);
+gboolean hal_util_set_double_from_file (HalDevice *d, const gchar *key, const gchar *directory, const gchar *file);
+
void hal_util_compute_udi (HalDeviceStore *store, gchar *dst, gsize dstsize, const gchar *format, ...);
gboolean hal_util_path_ascend (gchar *path);
diff --git a/tools/lshal.c b/tools/lshal.c
index ca417d8..372c2f5 100644
--- a/tools/lshal.c
+++ b/tools/lshal.c
@@ -150,8 +150,9 @@ print_props (const char *udi)
break;
case LIBHAL_PROPERTY_TYPE_DOUBLE:
- printf (" %s = %g (double)\n",
+ printf (" %s = %.1f (%g) (double)\n",
libhal_psi_get_key (&it),
+ libhal_psi_get_double (&it),
libhal_psi_get_double (&it));
break;
More information about the hal-commit
mailing list