add page for HID power devices

add page for HID power devices

error: pathspec 'inc/hid_usage_power.h' did not match any file(s) known to git

--- inc/hid_usage_power.h
+++ inc/hid_usage_power.h
@@ -0,0 +1,355 @@
+/* This file is the part of the Lightweight USB device Stack for STM32 microcontrollers
+ *
+ * Copyright ©2019 Dmitry Filimonchuk <dmitrystu[at]gmail[dot]com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _USB_HID_POWER_DEVICES_H_
+#define _USB_HID_POWER_DEVICES_H_
+
+/**\ingroup USB_HID
+ * \addtogroup USB_HID_POWER HID Usage Tables for Power Devices.
+ * \brief Contains USB HID Usage tables definitions for HID Power Devices.
+ * \details This module based on
+ * + [Universal Serial Bus Usage Tables for HID Power Devices. Release 1.0](https://usb.org/sites/default/files/documents/pdcv10.pdf)
+ * @{ */
+
+/**
+ * Name             | Physical Unit | HID unit | HID unit code | HID unit exponent | HID size
+ * -----------------|---------------|----------|---------------|-------------------|---------
+ * AC voltage       | Volt          | Volt     | 0x00F0D121    | 7                 | 8
+ * AC current       | centiAmp      | Amp      | 0x00100001    | -2                | 16
+ * Frequency        | Hertz         | Hertz    | 0xF001        | 0                 | 8
+ * DC voltage       | centiVolt     | Volt     | 0x00F0D121    | 5                 | 16
+ * Time             | second        | s        | 0x1001        | 0                 | 16
+ * DC current       | centiAmp      | Amp      | 0x00100001    | -2                | 16
+ * Power            | VA or W       | VA or W  | 0xD121        | 7                 | 16
+ * Temperature      | K degree      | K degree | 0x00010001    | 0                 | 16
+ * Battery capacity | AmpSec        | AmpSec   | 0x00101001    | 0                 | 24
+ *
+ */
+
+/**\name Measures and Physical Units ant it's exponents in Reports  according to this table.*/
+//@{
+/**AC voltage unit code. Volt.*/
+#define HID_POWER_UNIT_AC_VOLTAGE           0x67, 0x21, 0xD1, 0xF0, 0x00, 0x55, 0x07
+/**AC current unit code. centiAmpere.*/
+#define HID_POWER_UNIT_AC_CURRENT           0x67, 0x01, 0x00, 0x10, 0x00, 0x55, 0xFE
+/**Frequency unit code. Hertz.*/
+#define HID_POWER_UNIT_FREQUENCY            0x66, 0x01, 0xF0, 0x55, 0x00
+/**DC voltage unit code. Volt.*/
+#define HID_POWER_UNIT_DC_VOLTAGE           0x67, 0x21, 0xD1, 0xF0, 0x00, 0x55, 0x07
+/**Time unit code. Second.*/
+#define HID_POWER_UNIT_TIME                 0x66, 0x01, 0x10, 0x55, 0x00
+/**DC current unit code. centiAmpere.*/
+#define HID_POWER_UNIT_DC_CURRENT           0x67, 0x01, 0x00, 0x10, 0x00, 0x55, 0xFE
+/**Power unic code. Watt.*/
+#define HID_POWER_UNIT_POWER                0x66, 0x21, 0xD1, 0x55, 0x07
+/**Temperature unit code. K degree.*/
+#define HID_POWER_UNIT_TEMPERATURE          0x67, 0x01, 0x00, 0x01, 0x00, 0x55, 0x00
+/**Battery capacity unit code. AmpSec.*/
+#define HID_POWER_UNIT_BATTERY_CAPACITY     0x67, 0x01, 0x10, 0x10, 0x00, 0x55, 0x00
+//@}
+/** Macro to encode battery manufacturing date.
+ * \param y Year [1980 - 2108]
+ * \param m Month [1 - 12]
+ * \param d Day [1 - 31]
+*/
+#define BATTERY_MGF_DATE(y,m,d) (((((y) - 1980) & 0x7F) << 9) + (((m) & 0x0F) << 5) + ((d) & 0x1F))
+
+/** \addtogroup HID_POWER_DEVICE Power Device Page */
+//@{
+#define HID_POWER_PAGE                      0x84    /**<Power device page*/
+/**\name Power Device Structure */
+//@{
+#define HID_POWER_INAME                     0x01    /**<[SV] Index of the name string descriptor.*/
+#define HID_POWER_PRESENT_STATUS            0x02    /**<[CL] Collection of Present status information related to an object.*/
+#define HID_POWER_CHANGED_STATUS            0x03    /**<[CL] Collection of Changed status information related to an object. */
+#define HID_POWER_UPS                       0x04    /**<[CA] Collection that defines an Uninterruptible Power Supply.*/
+#define HID_POWER_POWER_SUPPLY              0x05    /**<[CA] Collection that defines a Power Supply.*/
+#define HID_POWER_BATTERY_SYSTEM            0x10    /**<[CP] Collection that defines a Battery System power module.*/
+#define HID_POWER_BATTERY_SYSTEM_ID         0x11    /**<[SV] Number that points to a particular Battery System.*/
+#define HID_POWER_BATTERY                   0x12    /**<[CP] Collection that defines a Battery.*/
+#define HID_POWER_BATTERY_ID                0x13    /**<[SV] Number that points to a particular Battery.*/
+#define HID_POWER_CHARGER                   0x14    /**<[CP] Collection that defines a Charger.*/
+#define HID_POWER_CHARGER_ID                0x15    /**<[SV] Number that points to a particular Charger.*/
+#define HID_POWER_POWER_CONVERTER           0x16    /**<[CP] Collection that defines a Power Converter power module.*/
+#define HID_POWER_POWER_CONVERTER_ID        0x17    /**<[SV] Number that points to a particular Power Converter.*/
+#define HID_POWER_OUTLET_SYSTEM             0x18    /**<[CP] Collection that defines a Outlet System power module.*/
+#define HID_POWER_OUTLET_SYSTEM_ID          0x19    /**<[SV] Number that points to a particular Outlet System.*/
+#define HID_POWER_INPUT                     0x1A    /**<[CP] Collection that defines an Input.*/
+#define HID_POWER_INPUT_ID                  0x1B    /**<[SV] Number that points to a particular Input.*/
+#define HID_POWER_OUTPUT                    0x1C    /**<[CP] Collection that defines an Output.*/
+#define HID_POWER_OUTPUT_ID                 0x1D    /**<[SV] Number that points to a particular Output.*/
+#define HID_POWER_FLOW                      0x1E    /**<[CP] Collection that defines a Flow.*/
+#define HID_POWER_FLOW_ID                   0x1F    /**<[SV] Number that points to a particular Flow.*/
+#define HID_POWER_OUTLET                    0x20    /**<[CP] Collection that defines an Outlet.*/
+#define HID_POWER_OUTLET_ID                 0x21    /**<[SV] Number that points to a particular Outlet*/
+#define HID_POWER_GANG                      0x22    /**<[CL/CP] Collection that defines ganged objects.*/
+#define HID_POWER_GANG_ID                   0x23    /**<[SV] Number that points to a particular Gang.*/
+#define HID_POWER_POWER_SUMMARY             0x24    /**<[CL/CP] Collection that defines a Power Summary.*/
+#define HID_POWER_POWER_SUMMARY_ID          0x25    /**<[SV] Number that points to a particular Power Summary.*/
+//@}
+/**\name Power Measures */
+//@{
+#define HID_POWER_VOLTAGE                   0x30    /**<[DV] Actual value of the voltage.*/
+#define HID_POWER_CURRENT                   0x31    /**<[DV] Actual value of the current.*/
+#define HID_POWER_FREQUENCY                 0x32    /**<[DV] Actual value of the frequency.*/
+#define HID_POWER_APPARENT_POWER            0x33    /**<[DV] Actual value of the apparent power.*/
+#define HID_POWER_ACTIVE_POWER              0x34    /**<[DV] Actual value of the active (RMS) power.*/
+#define HID_POWER_PERCENT_LOAD              0x35    /**<[DV] Actual value of the percentage of the power capacity presently being used on this input or output line.*/
+#define HID_POWER_TEMPERATURE               0x36    /**<[DV] Actual value of the temperature.*/
+#define HID_POWER_HUMIDITY                  0x37    /**<[DV] Actual value of the humidity.*/
+#define HID_POWER_BAD_COUNT                 0x38    /**<[DV] Number of times the device, module, or sub-module entered a bad condition.*/
+//@}
+/**\name Power configuration controls */
+//@{
+#define HID_POWER_CONFIG_VOLTAGE            0x40    /**<[SV/DV] Nominal value of the voltage.*/
+#define HID_POWER_CONFIG_CURRENT            0x41    /**<[SV/DV] Nominal value of the current.*/
+#define HID_POWER_CONFIG_FREQUENCY          0x42    /**<[SV/DV] Nominal value of the frequency.*/
+#define HID_POWER_CONFIG_APPARENT_POWER     0x43    /**<[SV/DV] Nominal value of the apparent power.*/
+#define HID_POWER_CONFIG_ACTIVE_POWER       0x44    /**<[SV/DV] Nominal value of the active (RMS) power.*/
+#define HID_POWER_CONFIG_PERCENT_LOAD       0x45    /**<[SV/DV] Nominal value of the percentage load that could be used without critical overload.*/
+#define HID_POWER_CONFIG_TEMPERATURE        0x46    /**<[SV/DV] Nominal value of the temperature.*/
+#define HID_POWER_CONFIG_HUMIDITY           0x47    /**<[SV/DV] Nominal value of the humidity.*/
+//@}
+/**\name Power controls */
+//@{
+#define HID_POWER_SWITCH_ON_CONTROL         0x50    /**<[DV] Controls the Switch ON sequence. \see \ref HID_POWER_SWITCH_VALUES */
+#define HID_POWER_SWITCH_OFF_CONTROL        0x51    /**<[DV] Controls the Switch OFF sequence. \see \ref HID_POWER_SWITCH_VALUES */
+#define HID_POWER_TOGGLE_CONTROL            0x52    /**<[DV] Controls the Toggle sequence. \see \ref HID_POWER_SWITCH_VALUES */
+#define HID_POWER_LOW_VOLTAGE_TRANSFER      0x53    /**<[DV] Minimum line voltage allowed before the PS system transfers to battery backup.*/
+#define HID_POWER_HIGH_VOLTAGE_TRANSFER     0x54    /**<[DV] Maximum line voltage allowed before the PS system transfers to battery backup.*/
+#define HID_POWER_DELAY_BEFORE_REBOOT       0x55    /**<[DV] Writing this value immediately shuts down (i.e., turns off) the output for a
+                                                     * period equal to the indicated number of seconds, after which time the output is
+                                                     * started. If the number of seconds required to perform the request is greater than
+                                                     * the requested duration, then the requested shutdown and startup cycle shall be
+                                                     * performed in the minimum time possible, but in no case shall this require more than
+                                                     * the requested duration plus 60 seconds. If the startup should occur during a utility
+                                                     * failure, the startup shall not occur until the utility power is restored. \n When read,
+                                                     * returns the number of seconds remaining in the countdown, or –1 if no countdown is in
+                                                     * progress.*/
+#define HID_POWER_DELAY_BEFORE_STARTUP      0x56    /**<[DV] Writing this value starts the output after the indicated number of seconds.
+                                                     * Sending this command with 0 causes the startup to occur immediately. Sending this
+                                                     * command with –1 aborts the countdown. If the output is already on at the time the
+                                                     * countdown reaches 0, nothing happens. On some systems, if the USB driver on the
+                                                     * device side is restarted while a startup countdown is in effect, the countdown is
+                                                     * aborted. If the countdown expires during a utility failure, the startup shall not
+                                                     * occur until the utility power is restored. Writing this value overrides the effect
+                                                     * of any countdown in progress. \n When read, returns the number of seconds remaining
+                                                     * in the countdown, or –1 if no countdown is in progress. */
+#define HID_POWER_DELAY_BEFORE_SHUTDOWN     0x57    /**<[DV] Writing this value shuts down either the output after the indicated number of
+                                                     * seconds, or sooner if the batteries become depleted. Sending this command with 0
+                                                     * causes the shutdown to occur immediately. Sending this command with –1 aborts the
+                                                     * countdown. If the system is already in the desired state at the time the countdown
+                                                     * reaches 0, there is no additional action. On some systems, if the USB driver on the
+                                                     * device side is restarted while a shutdown countdown is in effect, the countdown may
+                                                     * be aborted. Writing this value overrides any DelayBeforeShutdown countdown already
+                                                     * in effect. \n When read, will return the number of seconds remaining until shutdown,
+                                                     * or –1 if no shutdown countdown is in effect.*/
+#define HID_POWER_TEST                      0x58    /**<[DV] Test request or result value. \see \ref HID_POWER_TEST_VALUES */
+#define HID_POWER_MODULE_RESET              0x59    /**<[DV] Module Reset request value. \see \ref HID_POWER_RESET_VALUES */
+#define HID_POWER_AUDIBLE_ALARM_CONTROL     0x5A    /**<[DV] Audible alarm value. \see \ref HID_POWER_ALARM_VALUES */
+//@}
+/**\name Power generic status */
+//@{
+#define HID_POWER_PRESENT                   0x60    /**<[DF] Power present flag.*/
+#define HID_POWER_GOOD                      0x61    /**<[DF] Power good flag.*/
+#define HID_POWER_INTERNAL_FAILURE          0x62    /**<[DF] Inetrnal failure flag.*/
+#define HID_POWER_VOLTAGE_OUT_OF_RANGE      0x63    /**<[DF] Voltage out of range flag.*/
+#define HID_POWER_FREQUENCY_OUT_OF_RANGE    0x64    /**<[DF] Frequency out of range flag.*/
+#define HID_POWER_OVERLOAD                  0x65    /**<[DF] Overload flag.*/
+#define HID_POWER_OVERCHARGED               0x66    /**<[DF] Overcharged flag.*/
+#define HID_POWER_OVERTEMPERATURE           0x67    /**<[DF] Overtemperature flag.*/
+#define HID_POWER_SUTDOWN_REQUESTED         0x68    /**<[DF] Shutdown requested flag.*/
+#define HID_POWER_SHUTDOWN_IMMINENT         0x69    /**<[DF] Shutdown imminent flag.*/
+#define HID_POWER_SWITCH_ON_OFF             0x6B    /**<[DF] Switch ON flag.*/
+#define HID_POWER_SWITHABLE                 0x6C    /**<[DF] Swithable flag.*/
+#define HID_POWER_USED                      0x6D    /**<[DF] Used flag.*/
+#define HID_POWER_BOOST                     0x6E    /**<[DF] Voltage boosted flag.*/
+#define HID_POWER_BUCK                      0x6F    /**<[DF] Voltage bucked flag.*/
+#define HID_POWER_INITIALIZED               0x70    /**<[DF] Initialized flag.*/
+#define HID_POWER_TESTED                    0x71    /**<[DF] Tested flag.*/
+#define HID_POWER_AWAITING_POWER            0x72    /**<[DF] Awaiting power flag.*/
+#define HID_POWER_COMMUNICATION_LOST        0x73    /**<[DF] Communication lost flag.*/
+//@}
+/**\name Power device identification */
+#define HID_POWER_IMANUFACTURER             0xFD    /**<[SV] Index of the manufacturer string descriptor.*/
+#define HID_POWER_IPRODUCT                  0xFE    /**<[SV] Index of the prodict string descriptor.*/
+#define HID_POWER_ISERIALNUMBER             0xFF    /**<[SV] Index of the serial number string descriptor.*/
+/**\name Switch ON/OFF/TOGGLE sequence values
+ * \anchor HID_POWER_SWITCH_VALUES */
+#define HID_POWER_STOP_SEQUENCE             0x00    /**<Write value. Stop sequence.*/
+#define HID_POWER_START_SEQUENCE            0x01    /**<Write value. Start sequence.*/
+#define HID_POWER_SEQUENCE_NONE             0x00    /**<Read value. No sequence.*/
+#define HID_POWER_SEQUENCE_STARTED          0x01    /**<Read value. Sequence started.*/
+#define HID_POWER_SEQUENCE_INPROGRESS       0x02    /**<Read value. Sequence in progress.*/
+#define HID_POWER_SEQUENCE_STOPPED          0x03    /**<Read value. Sequence completed.*/
+/**\name Test request/result values
+ * \anchor HID_POWER_TEST_VALUES */
+#define HID_POWER_TEST_NO                   0x00    /**<Write value. No test.*/
+#define HID_POWER_TEST_QUICK                0x01    /**<Write value. Quck test.*/
+#define HID_POWER_TEST_DEEP                 0x02    /**<Write value. Deep test.*/
+#define HID_POWER_TEST_ABORT                0x03    /**<Write valie. Abort test.*/
+#define HID_POWER_TEST_PASSED               0x01    /**<Read value. Test done and passed.*/
+#define HID_POWER_TEST_WARNED               0x02    /**<Read value. Test done with warnings.*/
+#define HID_POWER_TEST_ERROR                0x03    /**<Read value. Test done with errors.*/
+#define HID_POWER_TEST_ABORTED              0x04    /**<Read value. Test aborted.*/
+#define HID_POWER_TEST_INPROGRESS           0x05    /**<Read value. Test in progress.*/
+#define HID_POWER_TEST_NOT_INITIATED        0x06    /**<Read value. No test inititted.*/
+
+/**\name Module reset values
+ * \anchor HID_POWER_RESET_VALUES */
+#define HID_POWER_RESET_NO                  0x00    /**<Read/Write value. No reset.*/
+#define HID_POWER_RESET_MODULE              0x01    /**<Read/Write value. Reset module.*/
+#define HID_POWER_RESET_ALARMS              0x02    /**<Read/Write value. Reset module's alarms.*/
+#define HID_POWER_RESET_COUNTERS            0x03    /**<Read/Write value. Reset module's counters.*/
+
+/**\name Audible alarm values
+ * \anchor HID_POWER_ALARM_VALUES
+ * @{ */
+#define HID_POWER_ALARM_DISABLED            0x00    /**<Read/Write value. Audible alarm disabled.*/
+#define HID_POWER_ALARM_ENABLED             0x01    /**<Read/Write value. Audible alarm enabled.*/
+#define HID_POWER_ALARM_MUTED               0x02    /**<Read/Write value. Audible alarm muted.*/
+/** @} */
+/** @} */
+
+/** \addtogroup HID_BATTERY_DEVICE Battery Device Page
+ * @{ */
+#define HID_BATTERY_PAGE                    0x85    /**<[CL] Battery usage page.*/
+#define HID_BATTERY_SMB_BATTERY_MODE        0x01    /**<[CL] SMB-specific collection used by the battery for mode setting.*/
+#define HID_BATTERY_SMB_BATTERY_STATUS      0x02    /**<[CL] SMB-specific collection used by the battery for Status and Alarm read.*/
+#define HID_BATTERY_SMB_ALARM_WARNING       0x03    /**<[CL] SMB-specific collection used by the battery for Alarm transmission to Charger and Host.*/
+#define HID_BATTERY_SMB_CHARGER_MODE        0x04    /**<[CL] SMB-specific collection used by the Charger for mode setting.*/
+#define HID_BATTERY_SMB_CHARGER_STATUS      0x05    /**<[CL] SMB-specific collection used by the Charger for status transmission.*/
+#define HID_BATTERY_SMB_CHARGER_SPECINFO    0x06    /**<[CL] SMB-specific collection used by the Charger for extended status information.*/
+#define HID_BATTERY_SMB_SELECTOR_STATE      0x07    /**<[CL] SMB-specific collection to manage Selector Features.*/
+#define HID_BATTERY_SMB_SELECTOR_PRESETS    0x08    /**<[CL] SMB-specific collection to select the next battery to power the system in the
+                                                     * event the current battery is removed or falls below its cutoff voltage.*/
+#define HID_BATTERY_SMB_SELECTOR_INFO       0x09    /**<[CL] SMB-specific collection of information used by the host to determine the capabilities of the selector.*/
+/**\name Battery system (or selector) settings and controls */
+#define HID_BATTERY_OPTIONAL_MFG_FUNC1      0x10    /**<[DV] An optional SMB-manufacturer-specific Read and Write function.*/
+#define HID_BATTERY_OPTIONAL_MFG_FUNC2      0x11    /**<[DV] An optional SMB-manufacturer-specific Read and Write function.*/
+#define HID_BATTERY_OPTIONAL_MFG_FUNC3      0x12    /**<[DV] An optional SMB-manufacturer-specific Read and Write function.*/
+#define HID_BATTERY_OPTIONAL_MFG_FUNC4      0x13    /**<[DV] An optional SMB-manufacturer-specific Read and Write function.*/
+#define HID_BATTERY_OPTIONAL_MFG_FUNC5      0x14    /**<[DV] An optional SMB-manufacturer-specific Read and Write function.*/
+#define HID_BATTERY_CONNECTION_TO_SMBUS     0x15    /**<[DF] State of connection to the system SMBus.*/
+#define HID_BATTERY_OUTPUT_CONNECTION       0x16    /**<[DV] Connection status of the specified Output.*/
+#define HID_BATTERY_CHARGER_CONNECTION      0x17    /**<[DV] ID of the specified Charger to the specified Battery.*/
+#define HID_BATTERY_BATTERY_INSERTION       0x18    /**<[DF] Insertion status of the specified Battery into the system.*/
+#define HID_BATTERY_USE_NEXT                0x19    /**<[DF] Whether or not this Battery will be used for next discharge.*/
+#define HID_BATTERY_OK_TO_USE               0x1A    /**<[DF] Whether or not this Battery is usable.*/
+#define HID_BATTERY_BATTERY_SUPPORTED       0x1B    /**<[DF] Whether or not this Battery is supported by the selector.*/
+#define HID_BATTERY_SELECTOR_REVISION       0x1C    /**<[DV] Version of the Smart Battery Selector specification.*/
+#define HID_BATTERY_CHARGING_INDICATOR      0x1D    /**<[DF] A bit flag that indicates whether the selector reports the charger’s status in the POWERBY nibble of SelectorState.*/
+/**\name Battery controls */
+#define HID_BATTERY_MANUFACTURER_ACCESS     0x28    /**<[DV] Read/Write according to the Smart Battery Data Specification.*/
+#define HID_BATTERY_REMAINING_CAP_LIMIT     0x29    /**<[DV] */
+#define HID_BATTERY_REMAINING_TIME_LIMIT    0x2A    /**<[DV] */
+#define HID_BATTERY_ATRATE                  0x2B    /**<[DV] */
+#define HID_BATTERY_CAPACITY_MODE           0x2C    /**<[DV] Battery capacity units. \see \ref HID_BATTERY_CAPACITY_UNITS */
+#define HID_BATTERY_BROADCAST_TO_CHARGER    0x2D    /**<[DF] Enable broadcast to charger.*/
+#define HID_BATTERY_PRIMARY_BATTERY         0x2E    /**<[DF] Battery operates in its primary role.*/
+#define HID_BATTERY_CHARGE_CONTROLLER       0x2F    /**<[DF] Internal charge control enabled.*/
+/**\name Battery status */
+#define HID_BATTERY_TERMINATE_CHARGE        0x40    /**<[DF] Terminate charge.*/
+#define HID_BATTERY_TERMINATE_DISCHARGE     0x41    /**<[DF] Terminate discharge.*/
+#define HID_BATTERY_BELOW_REM_CAP_LIMIT     0x42    /**<[DF] Battery below remained capacity limit.*/
+#define HID_BATTERY_REM_TIME_LIMIT_EXPIRED  0x43    /**<[DF] Remaining time limit expired.*/
+#define HID_BATTERY_CHARGING                0x44    /**<[DF] Battery charging.*/
+#define HID_BATTERY_DISCHARGING             0x45    /**<[DF] Battery discharging.*/
+#define HID_BATTERY_FULLY_CHARGED           0x46    /**<[DF] Battery fully charged flag.*/
+#define HID_BATTERY_FULLY_DISCHARGED        0x47    /**<[DF] Battery fully discharged flag.*/
+#define HID_BATTERY_CONDITIONING_FLAG       0x48    /**<[DF] Battery needs conditioning cycle.*/
+#define HID_BATTERY_ATRATE_OK               0x49    /**<[DF] At Rate values recalculated and available.*/
+#define HID_BATTERY_SMB_ERROR_CODE          0x4A    /**<[DV] An SMB-specific 4-bit error code.*/
+#define HID_BATTERY_NEED_REPLACEMENT        0x4B    /**<[DF] Battery need replacement flag.*/
+/**\name Battery measures */
+#define HID_BATTERY_ATRATE_TIME_TO_FILL     0x60    /**<[DV] The predicted remaining time in minutes to fully charge the battery at the AtRate value.*/
+#define HID_BATTERY_ATRATE_TIME_TO_EMPTY    0x61    /**<[DV] The predicted operating time if the battery is discharged at the AtRate value.*/
+#define HID_BATTERY_AVERAGE_CURRENT         0x62    /**<[DV] An one-minute rolling average of the current being supplied or accepted through the battery terminals.*/
+#define HID_BATTERY_MAXERROR                0x63    /**<[DV] The expected margin error (%) in the state of charge calculation.*/
+#define HID_BATTERY_REL_STATE_OF_CHARGE     0x64    /**<[DV] The predicted remaining battery capacity expressed as a percentage of the last measured full charge capacity. */
+#define HID_BATTERY_ABS_STATE_OF_CHARGE     0x65    /**<[DV] The predicted remaining battery capacity expressed as a percentage of design capacity.*/
+#define HID_BATTERY_REMAINING_CAPACITY      0x66    /**<[DV] The predicted remaining capacity.*/
+#define HID_BATTERY_FULL_CHARGE_CAPACITY    0x67    /**<[DV] The predicted pack capacity when it is fully charged.*/
+#define HID_BATTERY_RUN_TIME_TO_EMPTY       0x68    /**<[DV] The predicted remaining battery life, in minutes, at the present rate of discharge.*/
+#define HID_BATTERY_AVG_TIME_TO_EMPTY       0x69    /**<[DV] A one-minute rolling average, in minutes, of the predicted remaining battery time life.*/
+#define HID_BATTERY_AVG_TIME_TO_FULL        0x6A    /**<[DV] An one-minute rolling average, in minutes, of the predicted remaining time until the battery reaches full charge.*/
+#define HID_BATTERY_CYCLE_COUNT             0x6B    /**<[DV] The number, in cycles, of charge/discharge cycles the battery has experienced.*/
+/**\name Battery settings */
+#define HID_BATTERY_BATT_PACK_MODEL_LEVEL   0x80    /**<[SV] Battery model level for the battery pack. \see \ref HID_BATTERY_MODEL_LEVELS */
+#define HID_BATTERY_INT_CHARGE_CONTROLLER   0x81    /**<[SF] Charge controller function supported in the battery pack.*/
+#define HID_BATTERY_PRIMARY_BATTERY_SUPPORT 0x82    /**<[SF] Primary battery function supported in the battery pack.*/
+#define HID_BATTERY_DESIGN_CAPACITY         0x83    /**<[SV] The theoretical capacity of a new pack.*/
+#define HID_BATTERY_SPECIFICATION_INFO      0x84    /**<[SV] The version number of the Smart Battery Data Specification.*/
+#define HID_BATTERY_MANUFACTURER_DATE       0x85    /**<[SV] The date the pack was manufactured in a packed integer. \see \ref BATTERY_MGF_DATE(y,m,d) */
+#define HID_BATTERY_SERIAL_NUMBER           0x86    /**<[SV] The cell pack serial number.*/
+#define HID_BATTERY_IMANUFACTURER_NAME      0x87    /**<[SV] Index of a string descriptor containing the battery manufacturer’s name.*/
+#define HID_BATTERY_IDEVICE_NAME            0x88    /**<[SV] Index of a string descriptor containing the battery’s name.*/
+#define HID_BATTERY_IDEVICE_CHEMISTERY      0x89    /**<[SV] Index of a string descriptor containing the battery’s chemistry.*/
+#define HID_BATTERY_MANUFACTURER_DATA       0x8A    /**<[SV] A binary data block containing manufacturer specific data.*/
+/**\name Battery settings (ACPI specific) */
+#define HID_BATTERY_RECHARGEABLE            0x8B    /**<[SF] It's a rechargeable battery.*/
+#define HID_BATTERY_WARNINIG_CAP_LIMIT      0x8C    /**<[SV] OEM-designed battery warning capacity.*/
+#define HID_BATTERY_CAP_GRANULARITY1        0x8D    /**<[SV] Battery capacity granularity between low and warning.*/
+#define HID_BATTERY_CAP_GRANULARITY2        0x8E    /**<[SV] Battery capacity granularity between warning and full.*/
+#define HID_BATTERY_IOEM_INFORMATION        0x8F    /**<[SV] Index of a string descriptor defining OEM specific information for the battery.*/
+/**\name Charger controls */
+#define HID_BATTERY_INHIBIT_CHARGE          0xC0    /**<[DF] Inhibit charging.*/
+#define HID_BATTERY_ENABLE_POLLING          0xC1    /**<[DF] Enable polling.*/
+#define HID_BATTERY_RESET_TO_ZERO           0xC2    /**<[DF] Reset Charging Current and Voltage values to zero.*/
+/**\name Charger status */
+#define HID_BATTERY_AC_PRESENT              0xD0    /**<[DF] AC present.*/
+#define HID_BATTERY_BATTERY_PRESENT         0xD1    /**<[DF] Battery present.*/
+#define HID_BATTERY_POWER_FAIL              0xD2    /**<[DF] Power fail.*/
+#define HID_BATTERY_ALARM_INHIBITED         0xD3    /**<[DF] Alarm inhibited.*/
+#define HID_BATTERY_THERMISTOR_UNDER_RANGE  0xD4    /**<[DF] Thermistor under range.*/
+#define HID_BATTERY_THERMISTOR_HOT          0xD5    /**<[DF] Thermistor hot.*/
+#define HID_BATTERY_THERMISTOR_COLD         0xD6    /**<[DF] Thermistor cold.*/
+#define HID_BATTERY_THERMISTOR_OVER_RANGE   0xD7    /**<[DF] Thermistor over range.*/
+#define HID_BATTERY_VOLTAGE_OUT_OF_RANGE    0xD8    /**<[DF] Voltage out of range.*/
+#define HID_BATTERY_CURRENT_OUT_OF_RANGE    0xD9    /**<[DF] Current out of range.*/
+#define HID_BATTERY_CURRENT_NOT_REGULATED   0xDA    /**<[DF] Current not regulated.*/
+#define HID_BATTERY_VOLTAGE_NOT_REGULATED   0xDB    /**<[DF] Voltage not regulated.*/
+#define HID_BATTERY_MASTER_MODE             0xDC    /**<[DF] Master mode (polling is enabled).*/
+/**\name Charger settings */
+//@{
+#define HID_BATTERY_CHARGER_SELECTOR_SUPP   0xF0    /**<[SF] Charger selector support.*/
+#define HID_BATTERY_CHARGER_SPEC            0xF1    /**<[SV] Specification reference. (0001 for SMB charger 1.0).*/
+#define HID_BATTERY_LEVEL2                  0xF2    /**<[SF] Charger level flag 2*/
+#define HID_BATTERY_LEVEL3                  0xF3    /**<[SF] Charger level flag 3*/
+//@}
+
+/**\name Battery capacity units
+ * \anchor HID_BATTERY_CAPACITY_UNITS */
+//@{
+#define HID_BATTERY_CAPACITY_MAH            0x00    /**<Capacity unit is mAH (used in SMB) */
+#define HID_BATTERY_CAPACITY_MWH            0x01    /**<Capacity unit is mWH (used in SMB) */
+#define HID_BATTERY_CAPACITY_PERCENT        0x02    /**<Capacity unit is percent. */
+#define HID_BATTERY_CAPACITY_BOOL           0x03    /**<Boolean unit (OK or not OK) */
+//@}
+
+/**\name Battery model levels
+ * \anchor HID_BATTERY_MODEL_LEVELS */
+//@{
+#define HID_BATTERY_MODEL_BASIC             0x00    /**<Basic model.*/
+#define HID_BATTERY_MODEL_INTELLIGENT       0x01    /**<Intelligent model.*/
+#define HID_BATTERY_MODEL_SMART             0x02    /**<Smart battery.*/
+//@}
+
+//@}
+/** @} */
+
+
+#endif
+


change DEL to DELETE

change DEL to DELETE

--- include/HTTPRequest.h
+++ include/HTTPRequest.h
@@ -10,7 +10,7 @@
     GET = 1,
     POST,
     PUT,
-    DEL
+    DELETE
   };

  HTTPRequest(RequestType _type, const std::string & _uri) : type(_type), uri(_uri) { }
@@ -20,7 +20,7 @@
     case GET: return "GET";
     case POST: return "POST";
     case PUT: return "PUT";
-    case DEL: return "DEL";
+    case DELETE: return "DELETE";
     }
     return "";
   }


forbid direct use atoi function in uniset and uniset related projects

--- include/UniSetTypes.h
+++ include/UniSetTypes.h
@@ -224,5 +224,7 @@
 	IDList explode( const std::string str, char sep=',' );
 }

+#define atoi atoi##_Do_not_use_atoi_function_directly_Use_getIntProp90,_getArgInt_or_uni_atoi
+
 // -----------------------------------------------------------------------------------------
 #endif


ACPICA: Update TPM2 ACPI table

ACPICA: Update TPM2 ACPI table

ACPICA commit 254bf77e7ca01cb27e026fa5737f7df8dae03f2c

- Add constans for the start_method.
- Remove the control structure, not part of ACPI, not defined in the current
TCG spec.

Link: https://github.com/acpica/acpica/commit/254bf77e
Reported-by: Jarkko Sakkinen <6e0a3da6445cd298bc4a6b3aaa269075849c9510@linux.intel.com>
Signed-off-by: Bob Moore <861d61e839a6c9cacf88c3a26b10371d2c9b211f@intel.com>
Signed-off-by: Lv Zheng <687b611ec106f085ac3db1fd0c8e91dc3509d58c@intel.com>
Signed-off-by: Rafael J. Wysocki <27ffc44a8ec6a212fba98cfc3246c6ce8ab131e0@intel.com>


Changed spacing.

Changed spacing.

--- include/amissl/tags.h
+++ include/amissl/tags.h
@@ -3,20 +3,20 @@

 #include <utility/tagitem.h>

-#define	AmiSSL_SocketBase		(TAG_USER + 0x01)
-#define	AmiSSL_Version			(TAG_USER + 0x02) /* OBSOLETE */
-#define	AmiSSL_Revision			(TAG_USER + 0x03) /* OBSOLETE */
-#define	AmiSSL_VersionOverride	(TAG_USER + 0x04) /* OBSOLETE */
-/* #define	AmiSSL_TCPStack		(TAG_USER + 0x05)    OBSOLETE */
-#define	AmiSSL_SSLVersionApp	(TAG_USER + 0x06)
+#define AmiSSL_SocketBase       (TAG_USER + 0x01)
+#define AmiSSL_Version          (TAG_USER + 0x02) /* OBSOLETE */
+#define AmiSSL_Revision         (TAG_USER + 0x03) /* OBSOLETE */
+#define AmiSSL_VersionOverride  (TAG_USER + 0x04) /* OBSOLETE */
+/* #define  AmiSSL_TCPStack     (TAG_USER + 0x05)    OBSOLETE */
+#define AmiSSL_SSLVersionApp    (TAG_USER + 0x06)

 #ifdef __amigaos4__
-#define	AmiSSL_ISocket			(TAG_USER + 0x07) /* Only accessible from ppc code */
-#define	AmiSSL_ISocketPtr		(TAG_USER + 0x08) /* Used by auto initializer to avoid dependancy on opening order */
+#define AmiSSL_ISocket          (TAG_USER + 0x07) /* Only accessible from ppc code */
+#define AmiSSL_ISocketPtr       (TAG_USER + 0x08) /* Used by auto initializer to avoid dependancy on opening order */
 #endif

-#define	AmiSSL_SocketBaseBrand	(TAG_USER + 0x09)
-#define	AmiSSL_MLinkLock		(TAG_USER + 0x0a)
-#define	AmiSSL_ErrNoPtr			(TAG_USER + 0x0b)
+#define AmiSSL_SocketBaseBrand  (TAG_USER + 0x09)
+#define AmiSSL_MLinkLock        (TAG_USER + 0x0a)
+#define AmiSSL_ErrNoPtr         (TAG_USER + 0x0b)

 #endif /* !AMISSL_TAGS_H */


Add result_NOT_SUPPORTED

Add result_NOT_SUPPORTED

--- include/base/result.h
+++ include/base/result.h
@@ -43,6 +43,7 @@
 #define result_EXISTS                           (result_BASE_GENERIC     + 10)  /* Item already exists */
 #define result_CLASHES                          (result_BASE_GENERIC     + 11)  /* Key clashes with existing one */
 #define result_NULL_ARG                         (result_BASE_GENERIC     + 12)  /* An argument was NULL */
+#define result_NOT_SUPPORTED                    (result_BASE_GENERIC     + 13)  /* Not supported, e.g. no hardware */

 /* Stream result codes are in io/stream.h */


rework code for more effective message retry and graceful failure, includes:
	. ensuring that failed messages are properly unregistered.
	. bulks are aborted
	. message expiration is checked
	. list mgmt is maintained for failures and retries

remove cruft

add PSCRPC_IMP_NOOP for rq_send_state since IMP_FULL has no real meaning for us.

logging changes.

git-svn-id: f2acecaac6fbd5a03f3d4799db58dda434111981@16855 3eda493b-6a19-0410-b2e0-ec8ea4dd8fda

--- psc_fsutil_libs/psc_rpc/rpcclient.c
+++ psc_fsutil_libs/psc_rpc/rpcclient.c
@@ -69,7 +69,6 @@
 	return (req);
 }

-//struct pscrpc_import *class_new_import(struct obd_device *obd)
 struct pscrpc_import *
 pscrpc_new_import(void)
 {
@@ -134,32 +133,6 @@
 	PSCRPC_OBD_FREE(import, sizeof(*import));
 }

-#if 0 //try to get away without uuid's
-struct pscrpc_connection *
-pscrpc_uuid_to_connection(struct obd_uuid *uuid)
-{
-	struct pscrpc_connection *c;
-	lnet_nid_t                self;
-	lnet_process_id_t         peer;
-	int                       err;
-
-	err = pscrpc_uuid_to_peer(uuid, &peer, &self);
-	if (err) {
-		CERROR("cannot find peer %s!\n", uuid->uuid);
-		return NULL;
-	}
-
-	c = pscrpc_get_connection(peer, self, uuid);
-	if (c) {
-		memcpy(c->c_remote_uuid.uuid,
-		       uuid->uuid, sizeof(c->c_remote_uuid.uuid));
-	}
-
-	CDEBUG(D_INFO, "%s -> %p\n", uuid->uuid, c);
-
-	return c;
-}
-#endif

 #if 0
 static struct pscrpc_request *
@@ -241,7 +214,7 @@
 	else
 		request->rq_timeout = PSCRPC_OBD_TIMEOUT;

-	request->rq_send_state = PSCRPC_IMP_FULL;
+	request->rq_send_state = PSCRPC_IMP_NOOP;
 	request->rq_type = PSCRPC_MSG_REQUEST;
 	request->rq_import = pscrpc_import_get(imp);
 	request->rq_export = NULL;
@@ -532,37 +505,10 @@
 	spinlock(&imp->imp_lock);

 	req->rq_import_generation = imp->imp_generation;
-#if 0
-	if (pscrpc_import_delay_req(imp, req, &rc)) {
-		spinlock(&req->rq_lock);
-		req->rq_waiting = 1;
-		freelock(&req->rq_lock);
-
-		DEBUG_REQ(D_HA, req, "req from PID %d waiting for recovery: "
-			  "(%s != %s)",
-			  req->rq_reqmsg->status,
-			pscrpc_import_state_name(req->rq_send_state),
-			  pscrpc_import_state_name(imp->imp_state));
-
-		psclist_add_tail(&req->rq_lentry, &imp->imp_delayed_list);
-		freelock(&imp->imp_lock);
-		return (0);
-	}
-
-	if (rc) {
-		freelock(&imp->imp_lock);
-		req->rq_status = rc;
-		req->rq_phase = PSCRPC_RQ_PHASE_INTERPRET;
-		return (rc);
-	}
-#endif
-
-	/* XXX this is the same as pscrpc_queue_wait */
+
 	psclist_add_tail(&req->rq_lentry, &imp->imp_sending_list);
 	freelock(&imp->imp_lock);

-	// we don't have a 'current' struct - paul
-	//req->rq_reqmsg->status = current->pid;
 	rc = pscrpc_send_rpc(req, 0);
 	if (rc) {
 		DEBUG_REQ(PLL_WARN, req,
@@ -642,6 +588,9 @@

 	psc_assert(!in_interrupt());             /* might sleep */

+	DEBUG_REQ(PLL_INFO, request, "receving_reply=%d",
+		  pscrpc_client_receiving_reply(request));
+
 	if (!pscrpc_client_receiving_reply(request))
 		return;

@@ -655,18 +604,24 @@
 	else
 		wq = &request->rq_reply_waitq;

+
+	if (request->rq_abort_reply) {
+		//request->rq_receiving_reply = 0;
+		//return;
+	}
+
 	for (;;) {
 		/* Network access will complete in finite time but the HUGE
 		 * timeout lets us CWARN for visibility of sluggish NALs */
-		lwi = LWI_TIMEOUT(300, NULL, NULL);
+		lwi = LWI_TIMEOUT(10, NULL, NULL);
 		rc = pscrpc_cli_wait_event(wq,
-				    !pscrpc_client_receiving_reply(request),
-				    &lwi);
+		    !pscrpc_client_receiving_reply(request), &lwi);
 		if (rc == 0)
 			return;

 		psc_assert(rc == -ETIMEDOUT);
-		DEBUG_REQ(PLL_WARN, request, "Unexpectedly long timeout");
+		DEBUG_REQ(PLL_ERROR, request, "Unexpectedly long timeout");
+		//abort();
 	}
 }

@@ -684,6 +639,7 @@

 	if (err < 0) {
 		DEBUG_REQ(PLL_INFO, req, "status is %d", err);
+
 	} else if (err > 0) {
 		/* XXX: translate this error from net to host */
 		DEBUG_REQ(PLL_INFO, req, "status is %d", err);
@@ -730,39 +686,11 @@
 	 */
 	if ((rc == -ENOTCONN) || (rc == -ENODEV)) {
 		psclog_errorx("ENOTCONN or ENODEV");
-#if 0
-		if (req->rq_send_state != PSCRPC_IMP_FULL ||
-		    imp->imp_obd->obd_no_recov || imp->imp_dlm_fake) {
-			return (-ENOTCONN);
-		}
-
-		pscrpc_request_handle_notconn(req);
-#endif
 		return (rc);
 	}

 	/* Store transno in reqmsg for replay. */
 	req->rq_reqmsg->transno = req->rq_transno = req->rq_repmsg->transno;
-
-#if 0
-	if (req->rq_import->imp_replayable) {
-		spinlock(&imp->imp_lock);
-		if (req->rq_transno)
-			pscrpc_retain_replayable_request(req, imp);
-		else if (req->rq_commit_cb) {
-			freelock(&imp->imp_lock);
-			req->rq_commit_cb(req);
-			spinlock(&imp->imp_lock);
-		}
-
-		/* Replay-enabled imports return commit-status information. */
-		if (req->rq_repmsg->last_committed)
-			imp->imp_peer_committed_transno =
-				req->rq_repmsg->last_committed;
-		pscrpc_free_committed(imp);
-		freelock(&imp->imp_lock);
-	}
-#endif

 	psc_iostats_intv_add(&req->rq_import->imp_connection->c_iostats_rcv,
 	    req->rq_replen);
@@ -783,67 +711,20 @@
 	atomic_inc(&imp->imp_inflight);

 	psc_assert(imp);
-	psclog_info("Sending RPC cookie:pid:xid:nid:opc "
-	      "%#"PRIx64":%d:%"PRIu64":%s:%d",
-	      req->rq_reqmsg->handle.cookie,
-	      imp->imp_connection->c_peer.pid, req->rq_xid,
-	      libcfs_nid2str(imp->imp_connection->c_peer.nid),
-	      req->rq_reqmsg->opc);
+	DEBUG_REQ(PLL_INFO, req, "sending..");

 	/* Mark phase here for a little debug help */
 	req->rq_phase = PSCRPC_RQ_PHASE_RPC;

 	spinlock(&imp->imp_lock);
 	req->rq_import_generation = imp->imp_generation;
+
  restart:
-	/*
-#if 0
-	if (pscrpc_import_delay_req(imp, req, &rc)) {
-		psclist_del(&req->rq_lentry);
-
-		psclist_add_tail(&req->rq_lentry, &imp->imp_delayed_list);
-		freelock(&imp->imp_lock);
-
-		DEBUG_REQ(PLL_WARN, req, "\"%s\" waiting for recovery: (%s != %s)",
-			  current->comm,
-			  pscrpc_import_state_name(req->rq_send_state),
-			  pscrpc_import_state_name(imp->imp_state));
-		lwi = LWI_INTR(interrupted_request, req);
-		rc = l_wait_event(req->rq_reply_waitq,
-				  (req->rq_send_state == imp->imp_state ||
-				   req->rq_err || req->rq_intr),
-				  &lwi);
-		DEBUG_REQ(PLL_WARN, req, "\"%s\" awake: (%s == %s or %d/%d == 1)",
-			  current->comm,
-			  pscrpc_import_state_name(imp->imp_state),
-			  pscrpc_import_state_name(req->rq_send_state),
-			  req->rq_err, req->rq_intr);
-
-		spinlock(&imp->imp_lock);
-		psclist_del(&req->rq_lentry);
-
-		if (req->rq_err) {
-			rc = -EIO;
-		} else if (req->rq_intr) {
-			rc = -EINTR;
-		} else if (req->rq_no_resend) {
-			freelock(&imp->imp_lock);
-			GOTO(out, rc = -ETIMEDOUT);
-		} else {
-			GOTO(restart, rc);
-		}
-	}
-#endif
-	*/
-	if (rc) {
-		psclist_del(&req->rq_lentry,
-		    psc_lentry_hd(&req->rq_lentry));
-		freelock(&imp->imp_lock);
-		req->rq_status = rc; // XXX this ok?
-		GOTO(out, rc);
-	}
-
 	if (req->rq_resend) {
+		DEBUG_REQ(PLL_WARN, req, "resending (receiving_reply=%d)",
+			  req->rq_receiving_reply);
+		psc_assert(!req->rq_no_resend);
+		pscrpc_unregister_reply(req);
 		pscrpc_msg_add_flags(req->rq_reqmsg, MSG_RESENT);

 		if (req->rq_bulk) {
@@ -858,10 +739,7 @@
 			DEBUG_REQ(PLL_INFO, req, "bumping xid for bulk: ");
 			req->rq_xid = pscrpc_next_xid();
 		}
-
-		DEBUG_REQ(PLL_WARN, req, "resending: ");
-	}
-	/* XXX this is the same as pscrpc_set_wait */
+	}
 	psclist_add_tail(&req->rq_lentry, &imp->imp_sending_list);
 	freelock(&imp->imp_lock);

@@ -875,38 +753,20 @@
 	} else {
 		//timeout = MAX(req->rq_timeout * 100, 1);
 		timeout = MAX(req->rq_timeout, 1);
-		DEBUG_REQ(PLL_INFO, req,
-			  "-- sleeping for %d jiffies", timeout);
-	}
-	lwi = LWI_TIMEOUT_INTR(timeout, expired_request,
-			       interrupted_request, req);
+		DEBUG_REQ(PLL_INFO, req,"sleeping for %d sec", timeout);
+	}
+	lwi = LWI_TIMEOUT_INTR(timeout, expired_request, interrupted_request,
+	       req);

 	rc = pscrpc_cli_wait_event(&req->rq_reply_waitq,
 	    pscrpc_check_reply(req), &lwi);
-	/* !!! might have timed out !!! */
-	if (rc)
-		DEBUG_REQ(PLL_INFO, req,
-		  "pscrpc_cli_wait_event(pscrpc_check_reply) returned %d", rc);
-
-	DEBUG_REQ(PLL_INFO, req, "-- done sleeping");
-
-	psclog_info("Completed RPC status:err:xid:nid:opc %d:%d:%"PRIx64":%s:%d",
-	      req->rq_reqmsg->status, req->rq_err, req->rq_xid,
-	      libcfs_nid2str(imp->imp_connection->c_peer.nid),
-	      req->rq_reqmsg->opc);
-
-	if (req->rq_replied)
-		DEBUG_REQ(PLL_INFO, req, "REPLIED:");
+
+	DEBUG_REQ(rc ? PLL_ERROR : PLL_INFO, req,
+		  "completed (rc=%d), replied=%d", rc, req->rq_replied);

 	spinlock(&imp->imp_lock);
-	psclist_del(&req->rq_lentry,
-	    psc_lentry_hd(&req->rq_lentry));
+	psclist_del(&req->rq_lentry, psc_lentry_hd(&req->rq_lentry));
 	freelock(&imp->imp_lock);
-
-	/* If the reply was received normally, this just grabs the spinlock
-	 * (ensuring the reply callback has returned), sees that
-	 * req->rq_receiving_reply is clear and returns. */
-	pscrpc_unregister_reply(req);

 	if (rc)
 		GOTO(out, 0);
@@ -948,13 +808,12 @@
 	}

 	rc = after_reply(req);
-	/* NB may return +ve success rc */
-	if (req->rq_resend) {
-		spinlock(&imp->imp_lock);
-		goto restart;
-	}
-
  out:
+	/* If the reply was received normally, this just grabs the spinlock
+	 * (ensuring the reply callback has returned), sees that
+	 * req->rq_receiving_reply is clear and returns. */
+	pscrpc_unregister_reply(req);
+
 	if (req->rq_bulk) {
 		struct pscrpc_msg *m;

@@ -993,7 +852,6 @@
 	req->rq_phase = PSCRPC_RQ_PHASE_INTERPRET;

 	atomic_dec(&imp->imp_inflight);
-	psc_waitq_wakeall(&imp->imp_recovery_waitq);
 	return (rc);
 }

@@ -1032,7 +890,7 @@
 		struct pscrpc_import *imp = req->rq_import;
 		int rc = 0;

-		DEBUG_REQ(PLL_TRACE, req, "reqset=%p", set);
+		DEBUG_REQ(PLL_NOTIFY, req, "reqset=%p", set);

 		if (req->rq_phase == PSCRPC_RQ_PHASE_NEW &&
 		    pscrpc_push_req(req)) {
@@ -1058,17 +916,18 @@
 			GOTO(interpret, req->rq_status);

 		if (req->rq_net_err && !req->rq_timedout) {
-			/* expire this request,
-			 * which will eventually pscrpc_fail_import() too... */
 			pscrpc_expire_one_request(req);
-
-			/* NTBS: make sure net errors get flagged as error cases */
 			if (!req->rq_err)
 				req->rq_err = 1;
 		}
-
+	handle_error:
 		if (req->rq_err) {
+			/* Catch errored out RPC's here.
+			 */
 			pscrpc_unregister_reply(req);
+			if (req->rq_bulk)
+				pscrpc_abort_bulk(req->rq_bulk);
+
 			if (req->rq_status == 0)
 				req->rq_status = -EIO;
 			req->rq_phase = PSCRPC_RQ_PHASE_INTERPRET;
@@ -1086,7 +945,7 @@
 		 * path sets rq_intr irrespective of whether pscrpcd has
 		 * seen a timeout.  our policy is to only interpret
 		 * interrupted rpcs after they have timed out */
-		if (req->rq_intr && (req->rq_timedout || req->rq_waiting)) {
+		if (req->rq_intr && req->rq_timedout) {
 			/* NB could be on delayed list */
 			pscrpc_unregister_reply(req);
 			req->rq_status = -EINTR;
@@ -1101,93 +960,80 @@
 		}

 		if (req->rq_phase == PSCRPC_RQ_PHASE_RPC) {
-			if (req->rq_timedout ||
-			    req->rq_waiting  ||
-			    req->rq_resend) {
-				int status=0;
-				pscrpc_unregister_reply(req);
-
-				spinlock(&imp->imp_lock);
-
-#if 0
-				if (pscrpc_import_delay_req(imp, req, &status)) {
-					freelock(&imp->imp_lock);
-					continue;
+			int status = 0;
+			/* If using a non-blocking set, then check for expired
+			 *   requests here.
+			 */
+			if (!check_allsent && pscrpc_is_expired(req)) {
+				/* rc == 0 means we're resending the request!
+				 *   otherwise, this request is getting nuked.
+				 */
+				status = expired_request(req);
+				DEBUG_REQ(PLL_WARN, req, "expired (resend=%d)",                                     !status);
+
+				if (status) {
+					psc_assert(req->rq_status);
+					psc_assert(req->rq_err);
+					psc_assert(req->rq_timedout);
+					goto handle_error;
 				}
-#endif
-				psclist_del(&req->rq_lentry,
-				    psc_lentry_hd(&req->rq_lentry));
-				if (status) {
-					req->rq_status = status;
-					req->rq_phase = PSCRPC_RQ_PHASE_INTERPRET;
-					freelock(&imp->imp_lock);
-					GOTO(interpret, req->rq_status);
+			}
+			if (req->rq_resend) {
+				if (req->rq_no_resend) {
+					if (!req->rq_err)
+						req->rq_err = 1;
+					req->rq_status = -ENOTCONN;
+					goto handle_error;
 				}
-				if (req->rq_no_resend) {
-					req->rq_status = -ENOTCONN;
-					req->rq_phase = PSCRPC_RQ_PHASE_INTERPRET;
-					freelock(&imp->imp_lock);
-					GOTO(interpret, req->rq_status);
-				}
-				psclist_add_tail(&req->rq_lentry,
-					      &imp->imp_sending_list);
-
-				freelock(&imp->imp_lock);
-
-				req->rq_waiting = 0;
-				if (req->rq_resend) {
-					pscrpc_msg_add_flags(req->rq_reqmsg,
-							     MSG_RESENT);
-					if (req->rq_bulk) {
-						uint64_t old_xid = req->rq_xid;
-
-						pscrpc_unregister_bulk(req);
-
-						/* ensure previous bulk fails */
-						req->rq_xid = pscrpc_next_xid();
-						CDEBUG(D_HA, "resend bulk "
-						       "old x%"PRIu64" "
-						       "new x%"PRIu64"\n",
-						       old_xid, req->rq_xid);
-					}
-				}
-
+
+                                pscrpc_unregister_reply(req);
+                                /* Move to the tail of the list.
+                                 */
+                                spinlock(&imp->imp_lock);
+                                psclist_del(&req->rq_lentry,
+					    psc_lentry_hd(&req->rq_lentry));
+                                psclist_add_tail(&req->rq_lentry,
+						 &imp->imp_sending_list);
+                                freelock(&imp->imp_lock);
+
+				pscrpc_msg_add_flags(req->rq_reqmsg,
+				     MSG_RESENT);
+                                if (req->rq_bulk) {
+                                        uint64_t old_xid = req->rq_xid;
+
+                                        pscrpc_unregister_bulk(req);
+
+                                        /* ensure previous bulk fails */
+					req->rq_xid = pscrpc_next_xid();
+                                        DEBUG_REQ(PLL_NOTIFY, req,
+						  "resend bulk: old x%"PRIu64
+						  " new x%"PRIu64,
+						  old_xid, req->rq_xid);
+                                }
+
 				rc = pscrpc_send_rpc(req, 0);
 				if (rc) {
 					DEBUG_REQ(PLL_ERROR, req,
 						  "send failed (%d)", rc);
-					force_timer_recalc = 1;
 					req->rq_net_err = 1;
 				}
 				/* need to reset the timeout */
 				force_timer_recalc = 1;
 			}

-			/* Still waiting for a reply? */
-			if (pscrpc_client_receiving_reply(req))
-				continue;
-
-			/* Did we actually receive a reply? */
-			if (!pscrpc_client_replied(req))
-				continue;
-
+                        if (pscrpc_client_receiving_reply(req) ||
+                            !pscrpc_client_replied(req))
+				/* Req is not finished.
+				 */
+                                continue;
+
 			spinlock(&imp->imp_lock);
 			psclist_del(&req->rq_lentry,
-			    psc_lentry_hd(&req->rq_lentry));
+				    psc_lentry_hd(&req->rq_lentry));
 			freelock(&imp->imp_lock);
-
+
 			req->rq_status = after_reply(req);
-			if (req->rq_resend) {
-				/* Add this req to the delayed list so
-				   it can be errored if the import is
-				   evicted after recovery. */
-				spinlock(&req->rq_lock);
-				psclist_add_tail(&req->rq_lentry,
-					      &imp->imp_delayed_list);
-				freelock(&req->rq_lock);
-				continue;
-			}
-
+
 			/* If there is no bulk associated with this request,
 			 * then we're done and should let the interpreter
 			 * process the reply.  Similarly if the RPC returned
@@ -1197,14 +1043,14 @@
 				req->rq_phase = PSCRPC_RQ_PHASE_INTERPRET;
 				GOTO(interpret, req->rq_status);
 			}
-
+
 			req->rq_phase = PSCRPC_RQ_PHASE_BULK;
 		}
-
+
 		psc_assert(req->rq_phase == PSCRPC_RQ_PHASE_BULK);
 		if (pscrpc_bulk_active(req->rq_bulk))
 			continue;
-
+
 		if (!req->rq_bulk->bd_success) {
 			/* The RPC reply arrived OK, but the bulk screwed
 			 * up!  Dead weird since the server told us the RPC
@@ -1213,23 +1059,23 @@
 			DEBUG_REQ(PLL_ERROR, req, "bulk transfer failed");
 			LBUG();
 		}
-
+
 		req->rq_phase = PSCRPC_RQ_PHASE_INTERPRET;
-
- interpret:
+
+	interpret:
 		psc_assert(req->rq_phase == PSCRPC_RQ_PHASE_INTERPRET);
 		psc_assert(!req->rq_receiving_reply);
-
+
 		pscrpc_unregister_reply(req);
 		if (req->rq_bulk)
 			pscrpc_unregister_bulk(req);
-
+
 		req->rq_phase = PSCRPC_RQ_PHASE_COMPLETE;
 		ncompleted++;
-
+
 		if (req->rq_interpret_reply)
 			req->rq_status = req->rq_interpret_reply(req,
-				&req->rq_async_args);
+				 &req->rq_async_args);
 		req->rq_interpret_reply = NULL;
 		set->set_remaining--;

@@ -1307,48 +1153,28 @@
 	    "timeout (sent at %"PSCPRI_TIMET", %"PSCPRI_TIMET"s ago)",
 	    req->rq_sent, CURRENT_SECONDS - req->rq_sent);

-#if 0
-	/* Leave this out normally: it creates too much console noise and we
-	 * only need it when we're debugging networks */
-	if (imp)
-		LNetCtl(IOC_LIBCFS_DEBUG_PEER, &imp->imp_connection->c_peer);
-#endif
+	psc_assert(req->rq_send_state == PSCRPC_IMP_NOOP);
+
 	spinlock(&req->rq_lock);
-	req->rq_timedout = 1;
-	freelock(&req->rq_lock);
+	/* Error out the request here so that the upper layers may
+	 *    retry.
+	 */
+        req->rq_err = req->rq_timedout = 1;
+        req->rq_status = -ETIMEDOUT;
+        freelock(&req->rq_lock);

 	pscrpc_unregister_reply(req);
-
-	//if (obd_dump_on_timeout)
-	//        libcfs_debug_dumplog();

 	if (req->rq_bulk)
 		pscrpc_unregister_bulk(req);

-	if (imp == NULL) {
+	if (imp == NULL)
 		DEBUG_REQ(PLL_WARN, req, "NULL import: already cleaned up?");
-		return (1);
-	}
-
-	/* If this request is for recovery or other primordial tasks,
-	 * then error it out here. */
-	//if (req->rq_send_state != PSCRPC_IMP_FULL ||
-	//    imp->imp_obd->obd_no_recov) {
-
-	if (req->rq_send_state != PSCRPC_IMP_FULL) {
-		spinlock(&req->rq_lock);
-		req->rq_status = -ETIMEDOUT;
-		req->rq_err = 1;
-		freelock(&req->rq_lock);
-		return (1);
-	}
-
-	if (!imp->imp_igntimeout) {
+
+	else if (!imp->imp_igntimeout)
 		pscrpc_fail_import(imp, req->rq_reqmsg->conn_cnt);
-		return (1);
-	}
-
-	return (req->rq_timeoutable);
+
+	return (1);
 }

 int
@@ -1435,7 +1261,7 @@
 	}
 }

-#if WEDONTNEEDTHISRIGTHNOW
+#ifdef PSCRPC_IMPORT_DELAY
 static int
 pscrpc_import_delay_req(struct pscrpc_import *imp,
     struct pscrpc_request *req, int *status)
@@ -1497,9 +1323,8 @@
 		 */
 		CDEBUG(D_NET, "set %p going to sleep for %d seconds\n",
 		       set, timeout);
-		lwi = LWI_TIMEOUT_INTR((timeout ? timeout : 1) * 100,
-				       pscrpc_expired_set,
-				       pscrpc_interrupted_set, set);
+		lwi = LWI_TIMEOUT_INTR(timeout ? timeout : 1,
+		       pscrpc_expired_set, pscrpc_interrupted_set, set);

 		rc = pscrpc_cli_wait_event(&set->set_waitq,
 		    pscrpc_check_set(set, 1), &lwi);
@@ -1515,23 +1340,20 @@
 		 * I don't really care if we go once more round the loop in
 		 * the error cases -eeb.
 		 */
-		/* let the real timeouts bubble back up to the caller
-		 */
-		if (rc == -ETIMEDOUT)
-			return (rc);
 	} while (rc || set->set_remaining);

 	psc_assert(set->set_remaining == 0);

 	rc = 0;
-	psclist_for_each_entry(req, &set->set_requests,
-	    rq_set_chain_lentry) {
+	psclist_for_each_entry(req, &set->set_requests, rq_set_chain_lentry) {
+		DEBUG_REQ(PLL_INFO, req, "set wait..");
+
 		if (req->rq_import->imp_failed) {
 			psclog_errorx("failed import detected!");
 			rc = -ECONNABORTED;
 			continue;
 		}
-#if 0
+#if 1
 		/*
 		 * This assumes 100% reliable delivery
 		 * which simply doesn't exist.
@@ -1555,12 +1377,12 @@

 	if (rc)
 		psclog_errorx("set %p failed, rc=%d", set, rc);
-	//else
-		if (set->set_interpret) {
-			rc = set->set_interpret(set, set->set_arg, rc);
-			if (rc)
-				psclog_errorx("set interpreter failed (%d)", rc);
-		}
+
+	if (set->set_interpret) {
+		rc = set->set_interpret(set, set->set_arg, rc);
+		if (rc)
+			psclog_errorx("set interpreter failed (%d)", rc);
+	}

 	return (rc);
 }
@@ -1583,12 +1405,8 @@
  set_wait:
 		rc = pscrpc_set_wait(set);
 		if (rc) {
-			/* ??? set imp_failed here ???
-			 * IFF it's not being set by the lower layers
-			 * AND... even if it is, this mighth be a good place
-			 *        for a fall-back (timeout-based?) */
 			errno = -rc;
-			psclog_errorx("pscrpc_set_wait() failed for set %p: %s",
+			psclog_errorx("pscrpc_set_wait() failed (set=%p): %s",
 			    set, strerror(-rc));
 			return (rc);
 		} else {
@@ -1673,7 +1491,8 @@

 	 /* Make sure that no new requests get processed for this import.
 	  * pscrpc_{queue,set}_wait must (and does) hold imp_lock while testing
-	  * this flag and then putting requests on sending_list or delayed_list.
+	  * this flag and then putting requests on sending_list or
+	  * delayed_list.
 	  */
 	 spinlock(&imp->imp_lock);

@@ -1683,45 +1502,20 @@
 	  */
 	 psclist_for_each_entry_safe(req, next, &imp->imp_sending_list,
 	     rq_lentry) {
-		DEBUG_REQ(PLL_WARN, req, "inflight");
+		 DEBUG_REQ(PLL_WARN, req,
+			   "aborted -- am I freed later (bulk, cb's, reply)");

 		spinlock(&req->rq_lock);
 		if (req->rq_import_generation < imp->imp_generation) {
 			req->rq_err = 1;
 			pscrpc_wake_client_req(req);
 		}
-		freelock(&req->rq_lock);
-
-		if (req->rq_interpret_reply) {
-			//psc_enter_debugger("abort inflight");
-			req->rq_interpret_reply(req, &req->rq_async_args);
-			req->rq_interpret_reply = NULL;
-		}
-
-		if (req->rq_comp)
-			pscrpc_completion_one(req->rq_comp);
-
-		//XXX deal with me!!!
-		//_pscrpc_req_finished(req, 0);
-	 }
-
-#if 0
-	 psclist_for_each_entry_safe(req, next, &imp->imp_delayed_list, rq_lentry) {
-		DEBUG_REQ(PLL_WARN, req, "aborting waiting req");
-
-		spinlock(&req->rq_lock);
-		if (req->rq_import_generation < imp->imp_generation) {
-			req->rq_err = 1;
-			pscrpc_wake_client_req(req);
-		}
+		req->rq_abort_reply = 1;
+		if (req->rq_bulk)
+                        req->rq_bulk->bd_abort = 1;
+
 		freelock(&req->rq_lock);
 	 }
-
-	 /* Last chance to free reqs left on the replay list, but we
-	  * will still leak reqs that haven't committed.  */
-	 if (imp->imp_replayable)
-		 pscrpc_free_committed(imp);
-#endif

 	 freelock(&imp->imp_lock);
 }


Update for 014

Update for 014

--- include/data/Config.h
+++ include/data/Config.h
@@ -1,516 +0,0 @@
-/*
- Copyright (c) 2015, Paul Houx - All rights reserved.
- This code is intended for use with the Cinder C++ library: http://libcinder.org
-
- Redistribution and use in source and binary forms, with or without modification, are permitted provided that
- the following conditions are met:
-
- * Redistributions of source code must retain the above copyright notice, this list of conditions and
- the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
- the following disclaimer in the documentation and/or other materials provided with the distribution.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
- WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
- ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- POSSIBILITY OF SUCH DAMAGE.
- */
-
-#pragma once
-
-#include "cinder/Color.h"
-#include "cinder/DataSource.h"
-#include "cinder/DataTarget.h"
-#include "cinder/Log.h"
-#include "cinder/Utilities.h"
-#include "cinder/Vector.h"
-#include "cinder/app/Event.h"
-#include "jsoncpp/json.h"
-
-namespace tools {
-
-    using ConfigRef = std::shared_ptr<class Config>;
-
-    //! Reads and writes a JSON configuration file. Allows you to specify default values in case a setting does not exist.
-    class Config {
-    public:
-        class Options {
-            friend class Config;
-
-        public:
-            Options()
-            : mSetIfDefault( false )
-            , mWriteIfSet( false )
-            {
-            }
-
-            //! If \a enabled, add the default value to the configuration file if the key was not found.
-            Options &setIfDefault( bool enabled = true )
-            {
-                mSetIfDefault = enabled;
-                return *this;
-            }
-            //! If \a enabled, write the config file immediately after setting the new value.
-            Options &writeIfSet( bool enabled = true )
-            {
-                mWriteIfSet = enabled;
-                return *this;
-            }
-
-        private:
-            bool mSetIfDefault;
-            bool mWriteIfSet;
-        };
-
-    public:
-        ~Config() {}
-
-        static Config &instance()
-        {
-            static Config sInstance;
-            return sInstance;
-        }
-
-        void setOptions( const Options &options ) { mOptions = options; }
-
-        bool read( const ci::DataSourceRef &source )
-        {
-            mSource = source;
-
-            if( mSource->isFilePath() ) {
-                mTarget = ci::DataTargetPath::createRef( mSource->getFilePath() );
-            }
-            else {
-                // We can only write to files on disk.
-                mTarget.reset();
-            }
-
-            CI_LOG_I( "Reading configurations from: " << source->getFilePath() );
-
-            try {
-                std::string data = ci::loadString( source );
-
-                Json::Reader reader;
-                reader.parse( data, mRoot );
-
-                mDirty = false;
-                return true;
-            }
-            catch( ... ) {
-                return false;
-            }
-        }
-
-        bool write() { return write( mTarget ); }
-
-        bool write( const ci::DataTargetRef &target )
-        {
-            if( target ) {
-                const ci::fs::path &path = target->getFilePath();
-
-                if( !ci::fs::exists( path ) ) {
-                    ci::fs::create_directories( path.parent_path() );
-                    mDirty = true;
-                }
-
-                if( mDirty ) {
-                    CI_LOG_I( "Writing configurations to: " << target->getFilePath() );
-
-                    Json::StyledWriter writer;
-                    std::string        data = writer.write( mRoot );
-
-                    auto stream = target->getStream();
-                    if( stream ) {
-                        stream->seekAbsolute( 0 );
-                        stream->writeData( data.data(), data.size() );
-                        mDirty = false;
-                    }
-                }
-
-                return true;
-            }
-
-            return false;
-        }
-
-        const ci::fs::path &path() const
-        {
-            if( mSource && mSource->isFilePath() )
-                return mSource->getFilePath();
-
-            static ci::fs::path kEmpty;
-            return kEmpty;
-        }
-
-        template <typename T>
-        T get( const std::string &category, const std::string &key, const T &defaultValue, const char *comment )
-        {
-            auto str = mRoot["configuration"][category][key].asString();
-
-            if( str.empty() ) {
-                if( mOptions.mSetIfDefault ) {
-                    set( category, key, defaultValue, comment );
-                }
-
-                return defaultValue;
-            }
-
-            try {
-                auto result = ci::fromString<T>( str );
-                return result;
-            }
-            catch( const std::exception & ) {
-                return defaultValue;
-            }
-        }
-
-        template <typename T>
-        T get( const std::string &category, const std::string &key, const T &defaultValue )
-        {
-            return get<T>( category, key, defaultValue, nullptr );
-        }
-
-        template <typename T>
-        bool set( const std::string &category, const std::string &key, const T &value, const char *comment )
-        {
-            std::string str;
-            if( nullptr != comment ) {
-                // Make sure comments start with 2 forward slashes.
-                if( strncmp( comment, "//", 2 ) == 0 ) {
-                    str.append( comment );
-                }
-                else {
-                    str.append( "// " );
-                    str.append( comment );
-                }
-            }
-            else if( mRoot["configuration"].isMember( category ) && mRoot["configuration"][category].isMember( key ) )
-                str = mRoot["configuration"][category][key].getComment( Json::CommentPlacement::commentAfterOnSameLine );
-
-            mRoot["configuration"][category][key] = Json::Value( value );
-            mRoot["configuration"][category][key].setComment( str, Json::CommentPlacement::commentAfterOnSameLine );
-
-            mDirty = true;
-
-            if( mOptions.mWriteIfSet )
-                write();
-
-            return true;
-        }
-
-        template <typename T>
-        bool set( const std::string &category, const std::string &key, const T &value )
-        {
-            return set<T>( category, key, value, nullptr );
-        }
-
-        static std::string toHex( uint32_t argb )
-        {
-            std::stringstream stream;
-            stream << std::hex << argb;
-            return std::string( stream.str() );
-        }
-
-        static std::string toHex( const ci::ColorA &color )
-        {
-            uint32_t argb = uint8_t( color.a * 255 ) << 24 | uint8_t( color.r * 255 ) << 16 | uint8_t( color.g * 255 ) << 8 | uint8_t( color.b * 255 );
-            return toHex( argb );
-        }
-
-        static uint32_t fromHex( const std::string &hex )
-        {
-            std::stringstream stream;
-            stream << std::hex << hex;
-
-            uint32_t result;
-            stream >> result;
-
-            return result;
-        }
-
-    private:
-        Config()
-        : mDirty( false )
-        {
-        }
-        Config( const Options &options )
-        : mDirty( false )
-        , mOptions( options )
-        {
-        }
-
-        Config( const Config & ) = delete;
-        Config &operator=( const Config & ) = delete;
-
-    private:
-        Options             mOptions;
-        mutable bool        mDirty;
-        mutable Json::Value mRoot;
-        ci::DataSourceRef   mSource;
-        ci::DataTargetRef   mTarget;
-    };
-
-    template <>
-    inline bool Config::set<bool>( const std::string &category, const std::string &key, const bool &value, const char *comment )
-    {
-        return set( category, key, (int)value );
-    }
-
-    template <>
-    inline bool Config::set<ci::ivec2>( const std::string &category, const std::string &key, const ci::ivec2 &value, const char *comment )
-    {
-        Json::Value v;
-        v["x"] = value.x;
-        v["y"] = value.y;
-        set( category, key, v, comment );
-        return true;
-    }
-
-    template <>
-    inline bool Config::set<ci::ivec3>( const std::string &category, const std::string &key, const ci::ivec3 &value, const char *comment )
-    {
-        Json::Value v;
-        v["x"] = value.x;
-        v["y"] = value.y;
-        v["z"] = value.z;
-        set( category, key, v, comment );
-        return true;
-    }
-
-    template <>
-    inline bool Config::set<ci::vec2>( const std::string &category, const std::string &key, const ci::vec2 &value, const char *comment )
-    {
-        Json::Value v;
-        v["x"] = value.x;
-        v["y"] = value.y;
-        set( category, key, v, comment );
-        return true;
-    }
-
-    template <>
-    inline bool Config::set<ci::vec3>( const std::string &category, const std::string &key, const ci::vec3 &value, const char *comment )
-    {
-        Json::Value v;
-        v["x"] = value.x;
-        v["y"] = value.y;
-        v["z"] = value.z;
-        set( category, key, v, comment );
-        return true;
-    }
-
-    template <>
-    inline bool Config::set<ci::vec4>( const std::string &category, const std::string &key, const ci::vec4 &value, const char *comment )
-    {
-        Json::Value v;
-        v["x"] = value.x;
-        v["y"] = value.y;
-        v["z"] = value.z;
-        v["w"] = value.w;
-        set( category, key, v, comment );
-        return true;
-    }
-
-    template <>
-    inline bool Config::set<ci::Color>( const std::string &category, const std::string &key, const ci::Color &value, const char *comment )
-    {
-        Json::Value v = toHex( value );
-        set( category, key, v, comment );
-        return true;
-    }
-
-    template <>
-    inline bool Config::set<ci::ColorA>( const std::string &category, const std::string &key, const ci::ColorA &value, const char *comment )
-    {
-        Json::Value v = toHex( value );
-        set( category, key, v, comment );
-        return true;
-    }
-
-    template <>
-    inline int Config::get<int>( const std::string &category, const std::string &key, const int &defaultValue, const char *comment )
-    {
-        auto json = mRoot["configuration"][category][key];
-        if( json.empty() ) {
-            if( mOptions.mSetIfDefault )
-                set( category, key, defaultValue, comment );
-            return defaultValue;
-        }
-
-        return json.asInt();
-    }
-
-    template <>
-    inline float Config::get<float>( const std::string &category, const std::string &key, const float &defaultValue, const char *comment )
-    {
-        auto json = mRoot["configuration"][category][key];
-        if( json.empty() ) {
-            if( mOptions.mSetIfDefault )
-                set( category, key, defaultValue, comment );
-            return defaultValue;
-        }
-
-        return json.asFloat();
-    }
-
-    template <>
-    inline double Config::get<double>( const std::string &category, const std::string &key, const double &defaultValue, const char *comment )
-    {
-        auto json = mRoot["configuration"][category][key];
-        if( json.empty() ) {
-            if( mOptions.mSetIfDefault )
-                set( category, key, defaultValue, comment );
-            return defaultValue;
-        }
-
-        return json.asDouble();
-    }
-
-    template <>
-    inline bool Config::get<bool>( const std::string &category, const std::string &key, const bool &defaultValue, const char *comment )
-    {
-        return get<int>( category, key, (int)defaultValue, comment ) != 0;
-    }
-
-    template <>
-    inline ci::ivec2 Config::get<ci::ivec2>( const std::string &category, const std::string &key, const ci::ivec2 &defaultValue, const char *comment )
-    {
-        auto json = mRoot["configuration"][category][key];
-        if( json.empty() ) {
-            if( mOptions.mSetIfDefault )
-                set( category, key, defaultValue, comment );
-            return defaultValue;
-        }
-
-        ci::ivec2 v;
-        v.x = json["x"].asInt();
-        v.y = json["y"].asInt();
-        return v;
-    }
-
-    template <>
-    inline ci::ivec3 Config::get<ci::ivec3>( const std::string &category, const std::string &key, const ci::ivec3 &defaultValue, const char *comment )
-    {
-        auto json = mRoot["configuration"][category][key];
-        if( json.empty() ) {
-            if( mOptions.mSetIfDefault )
-                set( category, key, defaultValue, comment );
-            return defaultValue;
-        }
-
-        ci::ivec3 v;
-        v.x = json["x"].asInt();
-        v.y = json["y"].asInt();
-        v.z = json["z"].asInt();
-        return v;
-    }
-
-    template <>
-    inline ci::vec2 Config::get<ci::vec2>( const std::string &category, const std::string &key, const ci::vec2 &defaultValue, const char *comment )
-    {
-        auto json = mRoot["configuration"][category][key];
-        if( json.empty() ) {
-            if( mOptions.mSetIfDefault )
-                set( category, key, defaultValue, comment );
-            return defaultValue;
-        }
-
-        ci::vec2 v;
-        v.x = json["x"].asFloat();
-        v.y = json["y"].asFloat();
-        return v;
-    }
-
-    template <>
-    inline ci::vec3 Config::get<ci::vec3>( const std::string &category, const std::string &key, const ci::vec3 &defaultValue, const char *comment )
-    {
-        auto json = mRoot["configuration"][category][key];
-        if( json.empty() ) {
-            if( mOptions.mSetIfDefault )
-                set( category, key, defaultValue, comment );
-            return defaultValue;
-        }
-
-        ci::vec3 v;
-        v.x = json["x"].asFloat();
-        v.y = json["y"].asFloat();
-        v.z = json["z"].asFloat();
-        return v;
-    }
-
-    template <>
-    inline ci::vec4 Config::get<ci::vec4>( const std::string &category, const std::string &key, const ci::vec4 &defaultValue, const char *comment )
-    {
-        auto json = mRoot["configuration"][category][key];
-        if( json.empty() ) {
-            if( mOptions.mSetIfDefault )
-                set( category, key, defaultValue, comment );
-            return defaultValue;
-        }
-
-        ci::vec4 v;
-        v.x = json["x"].asFloat();
-        v.y = json["y"].asFloat();
-        v.z = json["z"].asFloat();
-        v.w = json["w"].asFloat();
-        return v;
-    }
-
-    template <>
-    inline ci::Color Config::get<ci::Color>( const std::string &category, const std::string &key, const ci::Color &defaultValue, const char *comment )
-    {
-        auto json = mRoot["configuration"][category][key];
-        if( json.empty() ) {
-            if( mOptions.mSetIfDefault )
-                set( category, key, defaultValue, comment );
-            return defaultValue;
-        }
-
-        return ci::Color::hex( fromHex( json.asString() ) );
-    }
-
-    template <>
-    inline ci::ColorA Config::get<ci::ColorA>( const std::string &category, const std::string &key, const ci::ColorA &defaultValue, const char *comment )
-    {
-        auto json = mRoot["configuration"][category][key];
-        if( json.empty() ) {
-            if( mOptions.mSetIfDefault )
-                set( category, key, defaultValue, comment );
-            return defaultValue;
-        }
-
-        return ci::Color::hex( fromHex( json.asString() ) );
-    }
-
-    static inline Config &config()
-    {
-        return Config::instance();
-    }
-
-    // ------------------------------------------------------------------------------------------------
-
-    class ConfigEvent : public ci::app::Event {
-    public:
-        ConfigEvent( Config &config )
-        : mConfig( config )
-        {
-        }
-
-        Config &getConfig() const { return mConfig; }
-
-    private:
-        Config &mConfig;
-    };
-
-    class ConfigChangedEvent : public ConfigEvent {
-    public:
-        ConfigChangedEvent( Config &config )
-        : ConfigEvent( config )
-        {
-        }
-    };
-
-} // namespace tools


Drop current font from graphics state when setting new font.

Ignore-this: b5988a6f11ed629fcf48f104f94eb3c9

darcs-hash:20091130013719-86a4e-8c9645a030e08eaf05862c167dcbb81e88b09efa.gz

--- mupdf/pdf_interpret.c
+++ mupdf/pdf_interpret.c
@@ -867,6 +867,9 @@
 			if (!obj)
 				return fz_throw("cannot find font resource: %s", fz_toname(csi->stack[0]));

+			if (gstate->font)
+				pdf_dropfont(gstate->font);
+
 			error = pdf_loadfont(&gstate->font, xref, rdb, obj);
 			if (error)
 				return fz_rethrow(error, "cannot load font");


drm/gem: Check locking in drm_gem_object_unreference

Pretty soon only some drivers will need dev->struct_mutex in their
gem_free_object callbacks. Hence it's really important to make sure
everything still keeps getting this right.

v2: Don't check for locking before we check for non-NULL obj. Spotted
by Dan Carpenter.

Link: e2db36b4c601bd2d831471bd3fb467e998d09127@ffwll.ch
Reviewed-by: David Herrmann <fb53b2ddb8d141e0cb39d7c67c2f81b6bc2eb0f7@gmail.com>
Signed-off-by: Daniel Vetter <c1b6782c4af8f0673da8923a0702a1832e5940f4@intel.com>

--- include/drm/drm_gem.h
+++ include/drm/drm_gem.h
@@ -142,8 +142,11 @@
 static inline void
 drm_gem_object_unreference(struct drm_gem_object *obj)
 {
-	if (obj != NULL)
+	if (obj != NULL) {
+		WARN_ON(!mutex_is_locked(&obj->dev->struct_mutex));
+
 		kref_put(&obj->refcount, drm_gem_object_free);
+	}
 }

 static inline void


sched: Add missing state chars to TASK_STATE_TO_CHAR_STR

We grew 3 new task states since the last time someone touched
it.

Signed-off-by: Peter Zijlstra <645ca7d3a8d3d4f60557176cd361ea8351edc32b@chello.nl>
LKML-Reference: <933e641ae401bb88e1d80b5ff8f11fcbc81285cf@chello.nl>
Signed-off-by: Ingo Molnar <9dbbbf0688fedc85ad4da37637f1a64b8c718ee2@elte.hu>

--- include/linux/sched.h
+++ include/linux/sched.h
@@ -193,7 +193,7 @@
 #define TASK_WAKEKILL		128
 #define TASK_WAKING		256

-#define TASK_STATE_TO_CHAR_STR "RSDTtZX"
+#define TASK_STATE_TO_CHAR_STR "RSDTtZXxKW"

 /* Convenience macros for the sake of set_task_state */
 #define TASK_KILLABLE		(TASK_WAKEKILL | TASK_UNINTERRUPTIBLE)


Remove invalid doxygen docs from deprecated func

--- include/mbedtls/md2.h
+++ include/mbedtls/md2.h
@@ -225,8 +225,6 @@
  * \param input    buffer holding the  data
  * \param ilen     length of the input data
  * \param output   MD2 checksum result
- *
- * \return         0 if successful
  */
 MBEDTLS_DEPRECATED static inline void mbedtls_md2( const unsigned char *input,
                                                    size_t ilen,


Improve the documentation of legacy msg layer transforms

Signed-off-by: Hanno Becker <4d488caff78d6184f59bbe6e137e34d4606b9fe8@arm.com>

--- include/mbedtls/ssl.h
+++ include/mbedtls/ssl.h
@@ -1328,10 +1328,18 @@
     /*
      * Record layer transformations
      */
-    mbedtls_ssl_transform *MBEDTLS_PRIVATE(transform_in);        /*!<  current transform params (in)   */
-    mbedtls_ssl_transform *MBEDTLS_PRIVATE(transform_out);       /*!<  current transform params (out)  */
-    mbedtls_ssl_transform *MBEDTLS_PRIVATE(transform);           /*!<  negotiated transform params     */
-    mbedtls_ssl_transform *MBEDTLS_PRIVATE(transform_negotiate); /*!<  transform params in negotiation */
+    mbedtls_ssl_transform *MBEDTLS_PRIVATE(transform_in);        /*!<  current transform params (in)
+                                                                  *    This is always a reference,
+                                                                  *    never an owning pointer.        */
+    mbedtls_ssl_transform *MBEDTLS_PRIVATE(transform_out);       /*!<  current transform params (out)
+                                                                  *    This is always a reference,
+                                                                  *    never an owning pointer.        */
+    mbedtls_ssl_transform *MBEDTLS_PRIVATE(transform);           /*!<  negotiated transform params
+                                                                  *    This pointer owns the transform
+                                                                  *    it references.                  */
+    mbedtls_ssl_transform *MBEDTLS_PRIVATE(transform_negotiate); /*!<  transform params in negotiation
+                                                                  *    This pointer owns the transform
+                                                                  *    it references.                  */

     /*
      * Timers


Remove unused MTD types

Remove unused MTD types

Three types are never set or checked for.  Remove.

Signed-off-by: Jörn Engel <aea8d21973be359ec7d72dd5882345200e3616a6@wohnheim.fh-wedel.de>
Signed-off-by: David Woodhouse <97b3379caa91f4ee97e44013ae4dc6350540fa9d@infradead.org>

--- include/mtd/mtd-abi.h
+++ include/mtd/mtd-abi.h
@@ -28,10 +28,7 @@
 #define MTD_ROM			2
 #define MTD_NORFLASH		3
 #define MTD_NANDFLASH		4
-#define MTD_PEROM		5
 #define MTD_DATAFLASH		6
-#define MTD_OTHER		14
-#define MTD_UNKNOWN		15

 #define MTD_CLEAR_BITS		1       // Bits can be cleared (flash)
 #define MTD_SET_BITS		2       // Bits can be set


Add missing function prototype for hash_fast

--- include/nc4internal.h
+++ include/nc4internal.h
@@ -317,6 +317,9 @@
 } NC_HDF5_FILE_INFO_T;

+/* Defined in lookup3.c */
+extern uint32_t hash_fast(const void *key, size_t length);
+
 /* These functions convert between netcdf and HDF5 types. */
 int nc4_get_typelen_mem(NC_HDF5_FILE_INFO_T *h5, nc_type xtype,
 			int is_long, size_t *len);


fixed some macros so they can be properly used in conditionals


GH1383: Add casts to ERR_PACK

GH1383: Add casts to ERR_PACK

Reviewed-by: Emilia Käsper <6521fc25e7624eef7c3a0d89b71de7e612d27d37@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/1385

--- include/openssl/err.h
+++ include/openssl/err.h
@@ -133,11 +133,13 @@
 # define ASYNCerr(f,r) ERR_PUT_error(ERR_LIB_ASYNC,(f),(r),OPENSSL_FILE,OPENSSL_LINE)
 # define KDFerr(f,r) ERR_PUT_error(ERR_LIB_KDF,(f),(r),OPENSSL_FILE,OPENSSL_LINE)

-# define ERR_PACK(l,f,r) \
-  ( ((unsigned int)((l) & 0x0FF) << 24L) | (((f) & 0xFFF) << 12L) | ((r) & 0xFFF) )
-# define ERR_GET_LIB(l)          (int)((((unsigned long)l)>>24L)&0xffL)
-# define ERR_GET_FUNC(l)         (int)((((unsigned long)l)>>12L)&0xfffL)
-# define ERR_GET_REASON(l)       (int)((l)&0xfffL)
+# define ERR_PACK(l,f,r) ( \
+        (((unsigned int)(l) & 0x0FF) << 24L) | \
+        (((unsigned int)(f) & 0xFFF) << 12L) | \
+        (((unsigned int)(r) & 0xFFF)       ) )
+# define ERR_GET_LIB(l)          (int)(((l) >> 24L) & 0x0FFL)
+# define ERR_GET_FUNC(l)         (int)(((l) >> 12L) & 0xFFFL)
+# define ERR_GET_REASON(l)       (int)( (l)         & 0xFFFL)

 /* OS functions */
 # define SYS_F_FOPEN             1


Fix for TT#1794

Fix for TT#1794

git-svn-id: 6e74a02f85675cec270f5d931b0f6998666294a3@49176 d31e2699-5ff4-0310-a27c-f18f2fbe73fe

--- include/parrot/hash.h
+++ include/parrot/hash.h
@@ -72,7 +72,6 @@
 };

 /* Utility macros - use them, do not reinvent the wheel */
-#define parrot_hash_iterate parrot_hash_iterate_linear

 #define parrot_hash_iterate_linear(_hash, _code)                            \
 {                                                                           \
@@ -89,7 +88,7 @@

 #define parrot_hash_iterate_indexed(_hash, _code)                           \
 {                                                                           \
-    INTVAL _loc;                                                            \
+    UINTVAL _loc;                                                           \
     if ((_hash)->entries){                                                  \
         for (_loc = 0; _loc <= (_hash)->mask; ++_loc) {                     \
             HashBucket *_bucket = (_hash)->index[_loc];                     \
@@ -101,6 +100,14 @@
     }                                                                       \
 }

+#define parrot_hash_iterate(_hash, _code)                                   \
+{                                                                           \
+    if ((_hash)->key_type == Hash_key_type_int)                             \
+        parrot_hash_iterate_indexed(_hash, _code)                           \
+    else                                                                    \
+        parrot_hash_iterate_linear(_hash, _code)                            \
+}
+
 typedef void (*value_free)(ARGFREE(void *));

 /* To avoid creating OrderedHashItem PMC we reuse FixedPMCArray PMC */


Remove wrong semicolon from LIST_APPEND macro

git-svn-id: 0925b7c4d71351b4fea77b99f2cfcd1a0170cafc@49348 d31e2699-5ff4-0310-a27c-f18f2fbe73fe

--- include/parrot/list.h
+++ include/parrot/list.h
@@ -66,7 +66,7 @@
                                             \
     SET_LIST_OWNER(_list, _item)            \
     _list->count++;                         \
-} while (0);
+} while (0)

 #define LIST_REMOVE(l, i)                   \
 do {                                        \


Forgot to reenable vstat plugin

Forgot to reenable vstat plugin

--- include/plugin-list.h
+++ include/plugin-list.h
@@ -46,7 +46,7 @@
 PLUGIN(vadmin)
 PLUGIN(vparams)
 PLUGIN(vban)
-/* PLUGIN(vstat) */
+PLUGIN(vstat)
 /* PLUGIN(vlog) */
 PLUGIN(curl)
 PLUGIN(vac_register)


Got rid of the references to sizeof(dig_t).

--- include/relic_types.h
+++ include/relic_types.h
@@ -48,7 +48,7 @@
 /**
  * Size in bits of a digit.
  */
-#define DIGIT	(8 * sizeof(dig_t))
+#define DIGIT			(WORD)

 /**
  * Logarithm of the digit size in bits in base two.


git-svn-id: http://10.144.169.20/repos/um/branches/l7vsd-3.x-shamshel@6386 1ed66053-1c2d-0410-8867-f7571e6e31d3

--- include/replication.h
+++ include/replication.h
@@ -154,7 +154,7 @@
 	void						sock_fini();
 	unsigned long long			make_serial();
 	int							send_data( struct replication_data* indata );
-	int							recv_data( struct replication_data* indata );
+	int							recv_data( struct replication_data* outdata );
 	void						releaserpl();
 	void						releasecmp();
 	void						releasesrf();


Convert status to its name

Convert status to its name

--- include/truth/types.h
+++ include/truth/types.h
@@ -39,7 +39,24 @@
     Error_Permissions,
     Error_Present,
     Error_Absent,
+    // Not an error message, but rather the number of error messages.
+    Error_Count,
 };
+
+static inline const char *status_message(enum status status) {
+    const char *messages[Error_Count] = {
+        "Ok",
+        "Not enough memory",
+        "Invalid",
+        "Permissions",
+        "Already present",
+        "Absent",
+    };
+    if (status >= Error_Count) {
+        return "Bad error";
+    }
+    return messages[status];
+}

 #define bubble(condition, message) { \
         enum status error = condition; \


I recently received the Debian bug report below about missing iconv
support for the dbf2pg contrib module.

The submitter created a patch which replaces the silent ignoring of -F
(when iconv support is disabled) with a meaningful warning.

Martin Pitt

--- contrib/dbase/dbf2pg.c
+++ contrib/dbase/dbf2pg.c
@@ -618,10 +618,14 @@
 			case 'U':
 				username = (char *) strdup(optarg);
 				break;
-#ifdef HAVE_ICONV_H
 			case 'F':
+#ifdef HAVE_ICONV_H
 				charset_from = (char *) strdup(optarg);
-				break;
+#else
+				printf("WARNING: dbf2pg was compiled without iconv support, ignoring -F option\n");
+#endif
+				break;
+#ifdef HAVE_ICONV_H
 			case 'T':
 				charset_to = (char *) strdup(optarg);
 				break;