/* Initialize and verify the chip. The datasheet says that the version register should be 0x10. If not, or the chip is malfunctioning or it is not a MAX17048 at all  */
static int max17048_init(const struct device *dev)
/* Initialize and verify the chip. The datasheet says that the version register should be 0x10. If not, or the chip is malfunctioning or it is not a MAX17048 at all  */
static int max17048_init(const struct device *dev)
{
	const struct max17048_config *cfg = dev->config;
	uint16_t version;
	int rc = max17048_read_register(dev, REGISTER_VERSION, &version);
	if (!device_is_ready(cfg->i2c.bus)) {
		LOG_ERR("Bus device is not ready");
		return -ENODEV;
	}
	if (rc < 0) {
		LOG_ERR("Cannot read from I2C");
		return rc;
	}
	version = version & 0xFFF0;
	if (version != 0x10) {
		LOG_ERR("Something found at the provided I2C address, but it is not a MAX17048");
		LOG_ERR("The version registers should be 0x10 but got %x. Maybe your wiring is "
			"wrong or it is a fake chip\n",
			version);
		return -ENODEV;
	}
	return 0;
}