@@ -192,28 +192,20 @@ static int as5011_configure_chip(struct as5011_device *as5011,
/* write threshold */
error = as5011_i2c_write(client, AS5011_XP, plat_dat->xp);
- if (error < 0) {
- dev_err(&client->dev, "Can't write threshold\n");
- return error;
- }
+ if (error < 0)
+ goto report_write_failure;
error = as5011_i2c_write(client, AS5011_XN, plat_dat->xn);
- if (error < 0) {
- dev_err(&client->dev, "Can't write threshold\n");
- return error;
- }
+ if (error < 0)
+ goto report_write_failure;
error = as5011_i2c_write(client, AS5011_YP, plat_dat->yp);
- if (error < 0) {
- dev_err(&client->dev, "Can't write threshold\n");
- return error;
- }
+ if (error < 0)
+ goto report_write_failure;
error = as5011_i2c_write(client, AS5011_YN, plat_dat->yn);
- if (error < 0) {
- dev_err(&client->dev, "Can't write threshold\n");
- return error;
- }
+ if (error < 0)
+ goto report_write_failure;
/* to free irq gpio in chip */
error = as5011_i2c_read(client, AS5011_X_RES_INT, &value);
@@ -223,6 +215,10 @@ static int as5011_configure_chip(struct as5011_device *as5011,
}
return 0;
+
+report_write_failure:
+ dev_err(&client->dev, "Can't write threshold\n");
+ return error;
}
static int as5011_probe(struct i2c_client *client,