@@ -31,22 +31,29 @@
#include "m5mols.h"
#include "m5mols_reg.h"
-static int m5mols_capture_error_handler(struct m5mols_info *info,
- int timeout)
+/**
+ * m5mols_capture_post_work - Handle post work after capture interrupt occur
+ *
+ * Return 0 if all condition associated with capture is fine.
+ */
+static int m5mols_capture_post_work(struct m5mols_info *info, int timeout)
{
int ret;
- /* Disable all interrupts and clear relevant interrupt staus bits */
+ /* First, disable capture interrupt */
ret = m5mols_write(&info->sd, SYSTEM_INT_ENABLE,
info->interrupt & ~(REG_INT_CAPTURE));
if (ret)
return ret;
+ /* Then, if timeout is exhasted, return ETIMEDOUT */
if (timeout == 0)
return -ETIMEDOUT;
+ /* All condition is satisfied, return 0 */
return 0;
}
+
/**
* m5mols_read_rational - I2C read of a rational number
*
@@ -150,7 +157,7 @@ int m5mols_start_capture(struct m5mols_info *info)
test_bit(ST_CAPT_IRQ, &info->flags),
msecs_to_jiffies(2000));
if (test_and_clear_bit(ST_CAPT_IRQ, &info->flags))
- ret = m5mols_capture_error_handler(info, timeout);
+ ret = m5mols_capture_post_work(info, timeout);
}
if (!ret)
ret = m5mols_lock_3a(info, false);
@@ -187,5 +194,5 @@ int m5mols_start_capture(struct m5mols_info *info)
}
}
- return m5mols_capture_error_handler(info, timeout);
+ return m5mols_capture_post_work(info, timeout);
}