struct watchdog_device wdog;
};
+static int abx80x_write_config_key(struct i2c_client *client, u8 key)
+{
+ if (i2c_smbus_write_byte_data(client, ABX8XX_REG_CFG_KEY, key) < 0) {
+ dev_err(&client->dev, "Unable to write configuration key\n");
+ return -EIO;
+ }
+
+ return 0;
+}
+
static int abx80x_is_rc_mode(struct i2c_client *client)
{
int flags = 0;
* Write the configuration key register to enable access to the Trickle
* register
*/
- err = i2c_smbus_write_byte_data(client, ABX8XX_REG_CFG_KEY,
- ABX8XX_CFG_KEY_MISC);
- if (err < 0) {
- dev_err(&client->dev, "Unable to write configuration key\n");
+ if (abx80x_write_config_key(client, ABX8XX_CFG_KEY_MISC) < 0)
return -EIO;
- }
err = i2c_smbus_write_byte_data(client, ABX8XX_REG_TRICKLE,
ABX8XX_TRICKLE_CHARGE_ENABLE |
}
/* Unlock write access to Oscillator Control Register */
- retval = i2c_smbus_write_byte_data(client, ABX8XX_REG_CFG_KEY,
- ABX8XX_CFG_KEY_OSC);
- if (retval < 0) {
- dev_err(dev, "Failed to write CONFIG_KEY register\n");
- return retval;
- }
+ if (abx80x_write_config_key(client, ABX8XX_CFG_KEY_OSC) < 0)
+ return -EIO;
retval = i2c_smbus_write_byte_data(client, ABX8XX_REG_OSC, flags);
flags |= (ABX8XX_OSC_OSEL);
/* Unlock write access on Oscillator Control register */
- retval = i2c_smbus_write_byte_data(client, ABX8XX_REG_CFG_KEY,
- ABX8XX_CFG_KEY_OSC);
- if (retval < 0) {
- dev_err(dev, "Failed to write CONFIG_KEY register\n");
- return retval;
- }
+ if (abx80x_write_config_key(client, ABX8XX_CFG_KEY_OSC) < 0)
+ return -EIO;
retval = i2c_smbus_write_byte_data(client, ABX8XX_REG_OSC, flags);
if (retval < 0) {
* Write the configuration key register to enable access to
* the config2 register
*/
- err = i2c_smbus_write_byte_data(client, ABX8XX_REG_CFG_KEY,
- ABX8XX_CFG_KEY_MISC);
- if (err < 0) {
- dev_err(&client->dev,
- "Unable to write configuration key\n");
+ if (abx80x_write_config_key(client, ABX8XX_CFG_KEY_MISC) < 0)
return -EIO;
- }
err = i2c_smbus_write_byte_data(client, ABX8XX_REG_OUT_CTRL,
data | ABX8XX_OUT_CTRL_EXDS);