Re: [PATCH 2/2] backlight: Add new lm3509 backlight driver

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
> ---


...

> +
> +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





[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]


  Powered by Linux