[PATCH 2/2] backlight: Add new lm3509 backlight driver
Krzysztof Kozlowski
krzysztof.kozlowski at linaro.org
Mon Mar 4 08:23:53 UTC 2024
On 02/03/2024 22:27, Patrick Gansterer wrote:
> This is a general driver for LM3509 backlight chip of TI.
> LM3509 is High Efficiency Boost for White LEDs and/or OLED Displays with
> Dual Current Sinks. This driver supports OLED/White LED select, brightness
> control and sub/main control.
> The datasheet can be found at http://www.ti.com/product/lm3509.
>
> Signed-off-by: Patrick Gansterer <paroga at paroga.com>
> ---
...
> +
> +static int lm3509_probe(struct i2c_client *client)
> +{
> + struct lm3509_bl *data;
> + struct device *dev = &client->dev;
> + int ret;
> + bool unison_mode = false;
> + bool oled_mode = false;
> + unsigned int reg_gp_val = 0;
> + u32 rate_of_change = 0;
> + u32 brightness = LM3509_DEF_BRIGHTNESS;
> + u32 max_brightness = LM3509_MAX_BRIGHTNESS;
> +
> + if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
> + dev_err(dev, "fail : i2c functionality check\n");
Drop the "fail : " everywhere and instead write something useful.
> + return -EOPNOTSUPP;
> + }
> +
> + data = devm_kzalloc(dev, sizeof(struct lm3509_bl), GFP_KERNEL);
> + if (!data)
> + return -ENOMEM;
> +
> + data->regmap = devm_regmap_init_i2c(client, &lm3509_regmap);
> + if (IS_ERR(data->regmap)) {
> + dev_err(dev, "fail : allocate register map\n");
This message can be dropped entirely.
> + return PTR_ERR(data->regmap);
> + }
> + i2c_set_clientdata(client, data);
> +
> + data->reset_gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW);
> + if (IS_ERR(data->reset_gpio)) {
> + ret = PTR_ERR(data->reset_gpio);
> + if (ret != -EPROBE_DEFER)
> + dev_err(dev, "fail : get reset GPIO: %d\n", ret);
No, don't upstream old vendor code directly but instead choose existing
mainline driver and customize it. The syntax is `return dev_err_probe()`.
> + return ret;
> + }
> +
> + lm3509_reset(data);
> +
> + of_property_read_u32(dev->of_node, "default-brightness", &brightness);
> + of_property_read_u32(dev->of_node, "max-brightness", &max_brightness);
> + unison_mode = of_property_read_bool(dev->of_node, "ti,unison-mode");
> + oled_mode = of_property_read_bool(dev->of_node, "ti,oled-mode");
> +
Best regards,
Krzysztof
More information about the dri-devel
mailing list