}
}
-static void lm8323_reset(struct lm8323_chip *lm)
+static int lm8323_reset(struct lm8323_chip *lm)
{
/* The docs say we must pass 0xAA as the data byte. */
- lm8323_write(lm, 2, LM8323_CMD_RESET, 0xAA);
+ return lm8323_write(lm, 2, LM8323_CMD_RESET, 0xAA);
}
static int lm8323_configure(struct lm8323_chip *lm)
int clock = (CLK_SLOWCLKEN | CLK_RCPWM_EXTERNAL);
int debounce = lm->debounce_time >> 2;
int active = lm->active_time >> 2;
+ int ret;
/*
* Active time must be greater than the debounce time: if it's
if (debounce >= active)
active = debounce + 3;
- lm8323_write(lm, 2, LM8323_CMD_WRITE_CFG, 0);
- lm8323_write(lm, 2, LM8323_CMD_WRITE_CLOCK, clock);
- lm8323_write(lm, 2, LM8323_CMD_SET_KEY_SIZE, keysize);
+ ret = lm8323_write(lm, 2, LM8323_CMD_WRITE_CFG, 0);
+ if (ret)
+ goto err;
+ ret = lm8323_write(lm, 2, LM8323_CMD_WRITE_CLOCK, clock);
+ if (ret)
+ goto err;
+ ret = lm8323_write(lm, 2, LM8323_CMD_SET_KEY_SIZE, keysize);
+ if (ret)
+ goto err;
lm8323_set_active_time(lm, lm->active_time);
- lm8323_write(lm, 2, LM8323_CMD_SET_DEBOUNCE, debounce);
- lm8323_write(lm, 3, LM8323_CMD_WRITE_PORT_STATE, 0xff, 0xff);
- lm8323_write(lm, 3, LM8323_CMD_WRITE_PORT_SEL, 0, 0);
+ ret = lm8323_write(lm, 2, LM8323_CMD_SET_DEBOUNCE, debounce);
+ if (ret)
+ goto err;
+ ret = lm8323_write(lm, 3, LM8323_CMD_WRITE_PORT_STATE, 0xff, 0xff);
+ if (ret)
+ goto err;
+ ret = lm8323_write(lm, 3, LM8323_CMD_WRITE_PORT_SEL, 0, 0);
+ if (ret)
+ goto err;
/*
* Not much we can do about errors at this point, so just hope
*/
return 0;
+
+err:
+ dev_err(&lm->client->dev, "failed to configure lm8323\n");
+
+ return ret;
}
/*
else if (lm->active_time == -1) /* Disable sleep. */
lm->active_time = 0;
- lm8323_reset(lm);
+ err = lm8323_reset(lm);
+ if (err)
+ goto fail2;
/* Nothing's set up to service the IRQ yet, so just spin for max.
* 100ms until we can configure. */
msleep(1);
}
- lm8323_configure(lm);
+ err = lm8323_configure(lm);
+ if (err)
+ goto fail2;
/* If a true probe check the device */
if (lm8323_read_id(lm, data) != 0) {