On Mon, Nov 03, 2025 at 07:06:48PM +0800, Junjie Cao wrote:
> +struct reg_init_data;
> +
> +struct aw99706_device {
> + struct i2c_client *client;
> + struct device *dev;
> + struct regmap *regmap;
> + struct backlight_device *bl_dev;
> + struct gpio_desc *hwen_gpio;
> + struct reg_init_data *init_tbl;
> + int init_tbl_size;
> + bool bl_enable;
> +};
> +
> +enum reg_access {
> + REG_NONE_ACCESS = 0,
> + REG_RD_ACCESS = 1,
> + REG_WR_ACCESS = 2,
> +};
> +
> +const u8 aw99706_regs[AW99706_REG_MAX + 1] = {
Why isn't this static?
> + [AW99706_CFG0_REG] = REG_RD_ACCESS | REG_WR_ACCESS,
> + [AW99706_CFG1_REG] = REG_RD_ACCESS | REG_WR_ACCESS,
> + [AW99706_CFG2_REG] = REG_RD_ACCESS | REG_WR_ACCESS,
> + [AW99706_CFG3_REG] = REG_RD_ACCESS | REG_WR_ACCESS,
> + [AW99706_CFG4_REG] = REG_RD_ACCESS | REG_WR_ACCESS,
> + [AW99706_CFG5_REG] = REG_RD_ACCESS | REG_WR_ACCESS,
> + [AW99706_CFG6_REG] = REG_RD_ACCESS | REG_WR_ACCESS,
> + [AW99706_CFG7_REG] = REG_RD_ACCESS | REG_WR_ACCESS,
> + [AW99706_CFG8_REG] = REG_RD_ACCESS | REG_WR_ACCESS,
> + [AW99706_CFG9_REG] = REG_RD_ACCESS | REG_WR_ACCESS,
> + [AW99706_CFGA_REG] = REG_RD_ACCESS | REG_WR_ACCESS,
> + [AW99706_CFGB_REG] = REG_RD_ACCESS | REG_WR_ACCESS,
> + [AW99706_CFGC_REG] = REG_RD_ACCESS | REG_WR_ACCESS,
> + [AW99706_CFGD_REG] = REG_RD_ACCESS | REG_WR_ACCESS,
> + [AW99706_FLAG_REG] = REG_RD_ACCESS,
> + [AW99706_CHIPID_REG] = REG_RD_ACCESS,
> + [AW99706_LED_OPEN_FLAG_REG] = REG_RD_ACCESS,
> + [AW99706_LED_SHORT_FLAG_REG] = REG_RD_ACCESS,
> +
> + /*
> + * Write bit is dropped here, writing BIT(0) to MTPLDOSEL will unlock
> + * Multi-time Programmable (MTP).
> + */
> + [AW99706_MTPLDOSEL_REG] = REG_RD_ACCESS,
> + [AW99706_MTPRUN_REG] = REG_NONE_ACCESS,
> +};
> +
...
> + aw = devm_kzalloc(dev, sizeof(*aw), GFP_KERNEL);
> + if (!aw)
> + return -ENOMEM;
> +
> + aw->client = client;
> + aw->dev = dev;
> + i2c_set_clientdata(client, aw);
> +
> + aw->regmap = devm_regmap_init_i2c(client, &aw99706_regmap_config);
> + if (IS_ERR(aw->regmap))
> + return dev_err_probe(dev, PTR_ERR(aw->regmap),
> + "Failed to init regmap\n");
> +
> + ret = aw99706_chip_id_read(aw);
> + if (ret != AW99706_ID)
> + return dev_err_probe(dev, ret,
> + "Failed to validate chip id\n")
Why are you exiting the probe with a positive value like 4 or 8? This
makes no sense. Registers do not coontain Linux return codes.
Best regards,
Krzysztof