Would be 4-bit/16. I thought I do a little check about the revision and print a warning message to inform about the probably untested revision. Or is that not necessary?+#define AS3668_CHIP_REV1 0x01
How many REVs can one chip have?
Should I omit the write function as well? I do some error handling there. Is it okay to err |= write() the returned error codes in init or should I handle every possible write error by itself?+static int as3668_read_value(struct i2c_client *client, u8 reg)
+{
+ return i2c_smbus_read_byte_data(client, reg);
+}
+
+static int as3668_write_value(struct i2c_client *client, u8 reg, u8 value)
+{
+ int err = i2c_smbus_write_byte_data(client, reg, value);
+
+ if (err)
+ dev_err(&client->dev, "error writing to reg 0x%02x, returned %d\n", reg, err);
+
+ return err;
+}
These look like abstractions for the sake of abstractions.
Just use the i2c_smbus_*() calls directly.
Error message not descriptive, understood. Changing that to "unexpected ..." as above. Or am I misunderstanding and the check should be omitted entirely?+ /* Read identifier from chip */
+ chip_id1 = as3668_read_value(client, AS3668_CHIP_ID1);
+
+ if (chip_id1 != AS3668_CHIP_IDENT)
+ return dev_err_probe(&client->dev, -ENODEV,
+ "chip reported wrong id: 0x%02x\n", chip_id1);
Unlikely. This too is unexpected, as above.
chip_id2 is directly related to the defined register CHIP_ID2 which name is taken from the datasheet of the AS3668. (Not sure if I'm allowed to link it)+ /* Check the revision */
+ chip_id2 = as3668_read_value(client, AS3668_CHIP_ID2);
Is child_id2 not for another chip?
This is ambiguous, please improve the variable nomenclature.
Doing if(error) return error; then...?+ err = as3668_dt_init(as3668);
+ if (err)
+ return dev_err_probe(&client->dev, err, "failed to initialize device\n");
No need for 2 error messages.