-/* Message logging helpers with driver-specific prefix string. */
-#define DRIVER_LOG_DOMAIN "fs9922: "
-#define sr_log(l, s, args...) sr_log(l, DRIVER_LOG_DOMAIN s, ## args)
-#define sr_spew(s, args...) sr_spew(DRIVER_LOG_DOMAIN s, ## args)
-#define sr_dbg(s, args...) sr_dbg(DRIVER_LOG_DOMAIN s, ## args)
-#define sr_info(s, args...) sr_info(DRIVER_LOG_DOMAIN s, ## args)
-#define sr_warn(s, args...) sr_warn(DRIVER_LOG_DOMAIN s, ## args)
-#define sr_err(s, args...) sr_err(DRIVER_LOG_DOMAIN s, ## args)
+#define LOG_PREFIX "fs9922"
+
+static gboolean flags_valid(const struct fs9922_info *info)
+{
+ int count;
+
+ /* Does the packet have more than one multiplier? */
+ count = 0;
+ count += (info->is_nano) ? 1 : 0;
+ count += (info->is_micro) ? 1 : 0;
+ count += (info->is_milli) ? 1 : 0;
+ count += (info->is_kilo) ? 1 : 0;
+ count += (info->is_mega) ? 1 : 0;
+ if (count > 1) {
+ sr_dbg("More than one multiplier detected in packet.");
+ return FALSE;
+ }
+
+ /*
+ * Does the packet "measure" more than one type of value?
+ *
+ * Note: In "diode mode", both is_diode and is_volt will be set.
+ * That is a valid use-case, so we don't want to error out below
+ * if it happens. Thus, we don't check for is_diode here.
+ */
+ count = 0;
+ // count += (info->is_diode) ? 1 : 0;
+ count += (info->is_percent) ? 1 : 0;
+ count += (info->is_volt) ? 1 : 0;
+ count += (info->is_ampere) ? 1 : 0;
+ count += (info->is_ohm) ? 1 : 0;
+ count += (info->is_hfe) ? 1 : 0;
+ count += (info->is_hertz) ? 1 : 0;
+ count += (info->is_farad) ? 1 : 0;
+ count += (info->is_celsius) ? 1 : 0;
+ count += (info->is_fahrenheit) ? 1 : 0;
+ if (count > 1) {
+ sr_dbg("More than one measurement type detected in packet.");
+ return FALSE;
+ }
+
+ /* Both AC and DC set? */
+ if (info->is_ac && info->is_dc) {
+ sr_dbg("Both AC and DC flags detected in packet.");
+ return FALSE;
+ }
+
+ /* Both Celsius and Fahrenheit set? */
+ if (info->is_celsius && info->is_fahrenheit) {
+ sr_dbg("Both Celsius and Fahrenheit flags detected in packet.");
+ return FALSE;
+ }
+
+ return TRUE;
+}