From: Arkadiusz Miśkiewicz Date: Tue, 26 Mar 2013 18:22:16 +0000 (+0100) Subject: - rel 5; one more fix for hid++v2 devices; don't do classic stop on preun X-Git-Tag: auto/th/upower-0.9.20-5 X-Git-Url: http://git.pld-linux.org/gitweb.cgi?a=commitdiff_plain;h=f310ec0800ec360cbae8cf62771454b763fb6df7;p=packages%2Fupower.git - rel 5; one more fix for hid++v2 devices; don't do classic stop on preun --- diff --git a/upower-fixes.patch b/upower-fixes.patch index 34d4aaf..a58a3e3 100644 --- a/upower-fixes.patch +++ b/upower-fixes.patch @@ -497,3 +497,147 @@ index f6636e6..ea8b0b3 100644 &error); if (!ret) { g_warning ("failed to coldplug unifying device: %s", +diff --git a/src/linux/hidpp-device.c b/src/linux/hidpp-device.c +index 5398a38..1ce48b7 100644 +--- a/src/linux/hidpp-device.c ++++ b/src/linux/hidpp-device.c +@@ -46,7 +46,6 @@ + /* HID++ 1.0 */ + #define HIDPP_READ_SHORT_REGISTER 0x81 + #define HIDPP_READ_SHORT_REGISTER_BATTERY 0x0d +-#define HIDPP_READ_SHORT_REGISTER_CONNECTION_STATE 0x02 + + #define HIDPP_READ_LONG_REGISTER 0x83 + #define HIDPP_READ_LONG_REGISTER_DEVICE_TYPE 11 +@@ -315,11 +314,10 @@ hidpp_device_cmd (HidppDevice *device, + buf[2] == HIDPP_ERR_INVALID_SUBID && + buf[3] == 0x00 && + buf[4] == HIDPP_FEATURE_ROOT_FN_PING) { +- if (buf[5] == HIDPP_ERROR_CODE_UNSUPPORTED) { +- /* device offline / unreachable */ +- g_set_error_literal (error, 1, 0, +- "device is unreachable"); +- ret = FALSE; ++ /* HID++ 1.0 ping reply, so fake success with version 1 */ ++ if (priv->version < 2 && (buf[5] == HIDPP_ERROR_CODE_UNKNOWN ++ || buf[5] == HIDPP_ERROR_CODE_UNSUPPORTED)) { ++ response_data[0] = 1; + goto out; + } + } +@@ -504,32 +502,12 @@ hidpp_device_refresh (HidppDevice *device, + ret = FALSE; + goto out; + } +- +- /* add features we are going to use */ +-// hidpp_device_map_add (device, +-// HIDPP_FEATURE_I_FEATURE_SET, +-// "IFeatureSet"); +-// hidpp_device_map_add (device, +-// HIDPP_FEATURE_I_FIRMWARE_INFO, +-// "IFirmwareInfo"); +- hidpp_device_map_add (device, +- HIDPP_FEATURE_GET_DEVICE_NAME_TYPE, +- "GetDeviceNameType"); +- hidpp_device_map_add (device, +- HIDPP_FEATURE_BATTERY_LEVEL_STATUS, +- "BatteryLevelStatus"); +-// hidpp_device_map_add (device, +-// HIDPP_FEATURE_WIRELESS_DEVICE_STATUS, +-// "WirelessDeviceStatus"); +- hidpp_device_map_add (device, +- HIDPP_FEATURE_SOLAR_DASHBOARD, +- "SolarDashboard"); +- hidpp_device_map_print (device); + } + + /* get version */ + if ((refresh_flags & HIDPP_REFRESH_FLAGS_VERSION) > 0) { +- /* first try v2 packet */ ++ guint version_old = priv->version; ++ + buf[0] = 0x00; + buf[1] = 0x00; + buf[2] = HIDPP_PING_DATA; +@@ -540,34 +518,43 @@ hidpp_device_refresh (HidppDevice *device, + buf, 3, + buf, 4, + error); +- if (ret) +- priv->version = buf[0]; +- /* then try v1 packet */ +- else { +- /* discard potential v1 error */ +- g_clear_error (error); +- +- /* checking hid++ v1 packet */ +- buf[0] = 0x00; +- buf[1] = 0x00; +- buf[2] = 0x00; ++ if (!ret) ++ goto out; + +- ret = hidpp_device_cmd (device, +- HIDPP_RECEIVER_ADDRESS, +- HIDPP_READ_SHORT_REGISTER, +- HIDPP_READ_SHORT_REGISTER_CONNECTION_STATE, +- buf, 3, +- buf, 2, +- error); ++ priv->version = buf[0]; + +- if (!ret) +- goto out; ++ if (version_old != priv->version) ++ g_debug("protocol for hid++ device changed from v%d to v%d", ++ version_old, priv->version); + +- priv->version = 1; +- } ++ if (version_old < 2 && priv->version >= 2) ++ refresh_flags |= HIDPP_REFRESH_FLAGS_FEATURES; + + } + ++ if ((refresh_flags & HIDPP_REFRESH_FLAGS_FEATURES) > 0) { ++ /* add features we are going to use */ ++// hidpp_device_map_add (device, ++// HIDPP_FEATURE_I_FEATURE_SET, ++// "IFeatureSet"); ++// hidpp_device_map_add (device, ++// HIDPP_FEATURE_I_FIRMWARE_INFO, ++// "IFirmwareInfo"); ++ hidpp_device_map_add (device, ++ HIDPP_FEATURE_GET_DEVICE_NAME_TYPE, ++ "GetDeviceNameType"); ++ hidpp_device_map_add (device, ++ HIDPP_FEATURE_BATTERY_LEVEL_STATUS, ++ "BatteryLevelStatus"); ++// hidpp_device_map_add (device, ++// HIDPP_FEATURE_WIRELESS_DEVICE_STATUS, ++// "WirelessDeviceStatus"); ++ hidpp_device_map_add (device, ++ HIDPP_FEATURE_SOLAR_DASHBOARD, ++ "SolarDashboard"); ++ hidpp_device_map_print (device); ++ } ++ + /* get device kind */ + if ((refresh_flags & HIDPP_REFRESH_FLAGS_KIND) > 0) { + +diff --git a/src/linux/hidpp-device.h b/src/linux/hidpp-device.h +index 935cd07..3f249a8 100644 +--- a/src/linux/hidpp-device.h ++++ b/src/linux/hidpp-device.h +@@ -68,7 +68,8 @@ typedef enum { + HIDPP_REFRESH_FLAGS_VERSION = 1, + HIDPP_REFRESH_FLAGS_KIND = 2, + HIDPP_REFRESH_FLAGS_BATTERY = 4, +- HIDPP_REFRESH_FLAGS_MODEL = 8 ++ HIDPP_REFRESH_FLAGS_MODEL = 8, ++ HIDPP_REFRESH_FLAGS_FEATURES = 16 + } HidppRefreshFlags; + + GType hidpp_device_get_type (void); + diff --git a/upower.spec b/upower.spec index d2f2a9f..c0670c9 100644 --- a/upower.spec +++ b/upower.spec @@ -2,7 +2,7 @@ Summary: Power management service Summary(pl.UTF-8): Usługa zarządzania energią Name: upower Version: 0.9.20 -Release: 4 +Release: 5 License: GPL v2+ Group: Libraries Source0: http://upower.freedesktop.org/releases/%{name}-%{version}.tar.xz @@ -142,9 +142,6 @@ rm -rf $RPM_BUILD_ROOT %systemd_post upower.service %preun -if [ "$1" = "0" ]; then - %service upower stop -fi %systemd_preun upower.service %postun