static int bmm_wakeup(struct i2c_client *client) { int err = 0; int try_times = BMM_MAX_RETRY_WAKEUP; const u8 value = 0x01; u8 dummy; PINFO("waking up the chip..."); while (try_times) { err = bmm_i2c_write(client, BMM_REG_NAME(POWER_CNTL), (u8 *)&value, 1); mdelay(BMM_I2C_WRITE_DELAY_TIME); dummy = 0; err = bmm_i2c_read(client, BMM_REG_NAME(POWER_CNTL), &dummy, 1); if (value == dummy) break; try_times--; } PINFO("wake up result: %s, tried times: %d", (try_times > 0) ? "succeed" : "fail", BMM_MAX_RETRY_WAKEUP - try_times + 1); err = (try_times > 0) ? 0 : -1; return err; }
static int bmm_wakeup(struct i2c_client *client) { int err = 0; int try_times = BMM_MAX_RETRY_WAKEUP; const u8 value = 0x01; u8 dummy; pr_info("%s -waking up the chip...",__func__); usleep_range(4900, 5000); /*BMM_I2C_WRITE_DELAY_TIME*/ while (try_times) { err = bmm_i2c_write(client, BMM_REG_NAME(POWER_CNTL), (u8 *)&value, 1); usleep_range(4900, 5000); dummy = 0; err = bmm_i2c_read(client, BMM_REG_NAME(POWER_CNTL), &dummy, 1); if (value == dummy) break; try_times--; } pr_info("%s -wake up result: %s, tried times: %d",__func__, (try_times > 0) ? "succeed" : "fail", BMM_MAX_RETRY_WAKEUP - try_times + 1); err = (try_times > 0) ? 0 : -1; return err; }