summaryrefslogtreecommitdiffstats
path: root/drivers/video/backlight
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-08-07 13:11:40 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-08-07 13:11:40 +0000
commit8b0a8165cdad0f4133837d753649ef4682e42c3b (patch)
tree5c58f869f31ddb1f7bd6e8bdea269b680b36c5b6 /drivers/video/backlight
parentReleasing progress-linux version 6.8.12-1~progress7.99u1. (diff)
downloadlinux-8b0a8165cdad0f4133837d753649ef4682e42c3b.tar.xz
linux-8b0a8165cdad0f4133837d753649ef4682e42c3b.zip
Merging upstream version 6.9.7.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'drivers/video/backlight')
-rw-r--r--drivers/video/backlight/Kconfig7
-rw-r--r--drivers/video/backlight/Makefile1
-rw-r--r--drivers/video/backlight/as3711_bl.c6
-rw-r--r--drivers/video/backlight/bd6107.c9
-rw-r--r--drivers/video/backlight/corgi_lcd.c1
-rw-r--r--drivers/video/backlight/gpio_backlight.c10
-rw-r--r--drivers/video/backlight/hx8357.c57
-rw-r--r--drivers/video/backlight/ktd2801-backlight.c128
-rw-r--r--drivers/video/backlight/l4f00242t03.c34
-rw-r--r--drivers/video/backlight/lm3630a_bl.c27
-rw-r--r--drivers/video/backlight/mp3309c.c96
-rw-r--r--drivers/video/backlight/pandora_bl.c4
12 files changed, 240 insertions, 140 deletions
diff --git a/drivers/video/backlight/Kconfig b/drivers/video/backlight/Kconfig
index ea2d0d69bd..230bca07b0 100644
--- a/drivers/video/backlight/Kconfig
+++ b/drivers/video/backlight/Kconfig
@@ -183,6 +183,13 @@ config BACKLIGHT_KTD253
which is a 1-wire GPIO-controlled backlight found in some mobile
phones.
+config BACKLIGHT_KTD2801
+ tristate "Backlight Driver for Kinetic KTD2801"
+ select LEDS_EXPRESSWIRE
+ help
+ Say Y to enable the backlight driver for the Kinetic KTD2801 1-wire
+ GPIO-controlled backlight found in Samsung Galaxy Core Prime VE LTE.
+
config BACKLIGHT_KTZ8866
tristate "Backlight Driver for Kinetic KTZ8866"
depends on I2C
diff --git a/drivers/video/backlight/Makefile b/drivers/video/backlight/Makefile
index 06966cb204..8d2cb25204 100644
--- a/drivers/video/backlight/Makefile
+++ b/drivers/video/backlight/Makefile
@@ -34,6 +34,7 @@ obj-$(CONFIG_BACKLIGHT_HP680) += hp680_bl.o
obj-$(CONFIG_BACKLIGHT_HP700) += jornada720_bl.o
obj-$(CONFIG_BACKLIGHT_IPAQ_MICRO) += ipaq_micro_bl.o
obj-$(CONFIG_BACKLIGHT_KTD253) += ktd253-backlight.o
+obj-$(CONFIG_BACKLIGHT_KTD2801) += ktd2801-backlight.o
obj-$(CONFIG_BACKLIGHT_KTZ8866) += ktz8866.o
obj-$(CONFIG_BACKLIGHT_LM3533) += lm3533_bl.o
obj-$(CONFIG_BACKLIGHT_LM3630A) += lm3630a_bl.o
diff --git a/drivers/video/backlight/as3711_bl.c b/drivers/video/backlight/as3711_bl.c
index 28437c2da0..e6f66bb35e 100644
--- a/drivers/video/backlight/as3711_bl.c
+++ b/drivers/video/backlight/as3711_bl.c
@@ -383,10 +383,8 @@ static int as3711_backlight_probe(struct platform_device *pdev)
if (pdev->dev.parent->of_node) {
ret = as3711_backlight_parse_dt(&pdev->dev);
- if (ret < 0) {
- dev_err(&pdev->dev, "DT parsing failed: %d\n", ret);
- return ret;
- }
+ if (ret < 0)
+ return dev_err_probe(&pdev->dev, ret, "DT parsing failed\n");
}
if (!pdata->su1_fb && !pdata->su2_fb) {
diff --git a/drivers/video/backlight/bd6107.c b/drivers/video/backlight/bd6107.c
index c95a12bf0c..b1e7126380 100644
--- a/drivers/video/backlight/bd6107.c
+++ b/drivers/video/backlight/bd6107.c
@@ -119,7 +119,6 @@ static int bd6107_probe(struct i2c_client *client)
struct backlight_device *backlight;
struct backlight_properties props;
struct bd6107 *bd;
- int ret;
if (pdata == NULL) {
dev_err(&client->dev, "No platform data\n");
@@ -147,11 +146,9 @@ static int bd6107_probe(struct i2c_client *client)
* the reset.
*/
bd->reset = devm_gpiod_get(&client->dev, "reset", GPIOD_OUT_HIGH);
- if (IS_ERR(bd->reset)) {
- dev_err(&client->dev, "unable to request reset GPIO\n");
- ret = PTR_ERR(bd->reset);
- return ret;
- }
+ if (IS_ERR(bd->reset))
+ return dev_err_probe(&client->dev, PTR_ERR(bd->reset),
+ "unable to request reset GPIO\n");
memset(&props, 0, sizeof(props));
props.type = BACKLIGHT_RAW;
diff --git a/drivers/video/backlight/corgi_lcd.c b/drivers/video/backlight/corgi_lcd.c
index 0a57033ae3..dd765098ad 100644
--- a/drivers/video/backlight/corgi_lcd.c
+++ b/drivers/video/backlight/corgi_lcd.c
@@ -11,6 +11,7 @@
* by Eric Miao <eric.miao@marvell.com>
*/
+#include <linux/backlight.h>
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/init.h>
diff --git a/drivers/video/backlight/gpio_backlight.c b/drivers/video/backlight/gpio_backlight.c
index d28c30b2a3..e0c8c2a3f5 100644
--- a/drivers/video/backlight/gpio_backlight.c
+++ b/drivers/video/backlight/gpio_backlight.c
@@ -64,13 +64,9 @@ static int gpio_backlight_probe(struct platform_device *pdev)
def_value = device_property_read_bool(dev, "default-on");
gbl->gpiod = devm_gpiod_get(dev, NULL, GPIOD_ASIS);
- if (IS_ERR(gbl->gpiod)) {
- ret = PTR_ERR(gbl->gpiod);
- if (ret != -EPROBE_DEFER)
- dev_err(dev,
- "Error: The gpios parameter is missing or invalid.\n");
- return ret;
- }
+ if (IS_ERR(gbl->gpiod))
+ return dev_err_probe(dev, PTR_ERR(gbl->gpiod),
+ "The gpios parameter is missing or invalid\n");
memset(&props, 0, sizeof(props));
props.type = BACKLIGHT_RAW;
diff --git a/drivers/video/backlight/hx8357.c b/drivers/video/backlight/hx8357.c
index bf18337ff0..339d9128fb 100644
--- a/drivers/video/backlight/hx8357.c
+++ b/drivers/video/backlight/hx8357.c
@@ -8,9 +8,9 @@
#include <linux/delay.h>
#include <linux/gpio/consumer.h>
#include <linux/lcd.h>
+#include <linux/mod_devicetable.h>
#include <linux/module.h>
-#include <linux/of.h>
-#include <linux/of_device.h>
+#include <linux/property.h>
#include <linux/spi/spi.h>
#define HX8357_NUM_IM_PINS 3
@@ -564,41 +564,28 @@ static struct lcd_ops hx8357_ops = {
.get_power = hx8357_get_power,
};
-static const struct of_device_id hx8357_dt_ids[] = {
- {
- .compatible = "himax,hx8357",
- .data = hx8357_lcd_init,
- },
- {
- .compatible = "himax,hx8369",
- .data = hx8369_lcd_init,
- },
- {},
-};
-MODULE_DEVICE_TABLE(of, hx8357_dt_ids);
+typedef int (*hx8357_init_fn)(struct lcd_device *);
static int hx8357_probe(struct spi_device *spi)
{
struct device *dev = &spi->dev;
struct lcd_device *lcdev;
struct hx8357_data *lcd;
- const struct of_device_id *match;
+ hx8357_init_fn init_fn;
int i, ret;
- lcd = devm_kzalloc(&spi->dev, sizeof(*lcd), GFP_KERNEL);
+ lcd = devm_kzalloc(dev, sizeof(*lcd), GFP_KERNEL);
if (!lcd)
return -ENOMEM;
ret = spi_setup(spi);
- if (ret < 0) {
- dev_err(&spi->dev, "SPI setup failed.\n");
- return ret;
- }
+ if (ret < 0)
+ return dev_err_probe(dev, ret, "SPI setup failed.\n");
lcd->spi = spi;
- match = of_match_device(hx8357_dt_ids, &spi->dev);
- if (!match || !match->data)
+ init_fn = device_get_match_data(dev);
+ if (!init_fn)
return -EINVAL;
lcd->reset = devm_gpiod_get(dev, "reset", GPIOD_OUT_LOW);
@@ -617,8 +604,7 @@ static int hx8357_probe(struct spi_device *spi)
gpiod_set_consumer_name(lcd->im_pins->desc[i], "im_pins");
}
- lcdev = devm_lcd_device_register(&spi->dev, "mxsfb", &spi->dev, lcd,
- &hx8357_ops);
+ lcdev = devm_lcd_device_register(dev, "mxsfb", dev, lcd, &hx8357_ops);
if (IS_ERR(lcdev)) {
ret = PTR_ERR(lcdev);
return ret;
@@ -627,17 +613,28 @@ static int hx8357_probe(struct spi_device *spi)
hx8357_lcd_reset(lcdev);
- ret = ((int (*)(struct lcd_device *))match->data)(lcdev);
- if (ret) {
- dev_err(&spi->dev, "Couldn't initialize panel\n");
- return ret;
- }
+ ret = init_fn(lcdev);
+ if (ret)
+ return dev_err_probe(dev, ret, "Couldn't initialize panel\n");
- dev_info(&spi->dev, "Panel probed\n");
+ dev_info(dev, "Panel probed\n");
return 0;
}
+static const struct of_device_id hx8357_dt_ids[] = {
+ {
+ .compatible = "himax,hx8357",
+ .data = hx8357_lcd_init,
+ },
+ {
+ .compatible = "himax,hx8369",
+ .data = hx8369_lcd_init,
+ },
+ {}
+};
+MODULE_DEVICE_TABLE(of, hx8357_dt_ids);
+
static struct spi_driver hx8357_driver = {
.probe = hx8357_probe,
.driver = {
diff --git a/drivers/video/backlight/ktd2801-backlight.c b/drivers/video/backlight/ktd2801-backlight.c
new file mode 100644
index 0000000000..d295c27660
--- /dev/null
+++ b/drivers/video/backlight/ktd2801-backlight.c
@@ -0,0 +1,128 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Datasheet:
+ * https://www.kinet-ic.com/uploads/web/KTD2801/KTD2801-04b.pdf
+ */
+#include <linux/backlight.h>
+#include <linux/gpio/consumer.h>
+#include <linux/leds-expresswire.h>
+#include <linux/platform_device.h>
+#include <linux/property.h>
+
+#define KTD2801_DEFAULT_BRIGHTNESS 100
+#define KTD2801_MAX_BRIGHTNESS 255
+
+/* These values have been extracted from Samsung's driver. */
+static const struct expresswire_timing ktd2801_timing = {
+ .poweroff_us = 2600,
+ .detect_delay_us = 150,
+ .detect_us = 270,
+ .data_start_us = 5,
+ .short_bitset_us = 5,
+ .long_bitset_us = 15,
+ .end_of_data_low_us = 10,
+ .end_of_data_high_us = 350
+};
+
+struct ktd2801_backlight {
+ struct expresswire_common_props props;
+ struct backlight_device *bd;
+ bool was_on;
+};
+
+static int ktd2801_update_status(struct backlight_device *bd)
+{
+ struct ktd2801_backlight *ktd2801 = bl_get_data(bd);
+ u8 brightness = (u8) backlight_get_brightness(bd);
+
+ if (backlight_is_blank(bd)) {
+ expresswire_power_off(&ktd2801->props);
+ ktd2801->was_on = false;
+ return 0;
+ }
+
+ if (!ktd2801->was_on) {
+ expresswire_enable(&ktd2801->props);
+ ktd2801->was_on = true;
+ }
+
+ expresswire_write_u8(&ktd2801->props, brightness);
+
+ return 0;
+}
+
+static const struct backlight_ops ktd2801_backlight_ops = {
+ .update_status = ktd2801_update_status,
+};
+
+static int ktd2801_backlight_probe(struct platform_device *pdev)
+{
+ struct device *dev = &pdev->dev;
+ struct backlight_device *bd;
+ struct ktd2801_backlight *ktd2801;
+ u32 brightness, max_brightness;
+ int ret;
+
+ ktd2801 = devm_kzalloc(dev, sizeof(*ktd2801), GFP_KERNEL);
+ if (!ktd2801)
+ return -ENOMEM;
+ ktd2801->was_on = true;
+ ktd2801->props.timing = ktd2801_timing;
+
+ ret = device_property_read_u32(dev, "max-brightness", &max_brightness);
+ if (ret)
+ max_brightness = KTD2801_MAX_BRIGHTNESS;
+ if (max_brightness > KTD2801_MAX_BRIGHTNESS) {
+ dev_err(dev, "illegal max brightness specified\n");
+ max_brightness = KTD2801_MAX_BRIGHTNESS;
+ }
+
+ ret = device_property_read_u32(dev, "default-brightness", &brightness);
+ if (ret)
+ brightness = KTD2801_DEFAULT_BRIGHTNESS;
+ if (brightness > max_brightness) {
+ dev_err(dev, "default brightness exceeds max\n");
+ brightness = max_brightness;
+ }
+
+ ktd2801->props.ctrl_gpio = devm_gpiod_get(dev, "ctrl", GPIOD_OUT_HIGH);
+ if (IS_ERR(ktd2801->props.ctrl_gpio))
+ return dev_err_probe(dev, PTR_ERR(ktd2801->props.ctrl_gpio),
+ "failed to get backlight GPIO");
+ gpiod_set_consumer_name(ktd2801->props.ctrl_gpio, dev_name(dev));
+
+ bd = devm_backlight_device_register(dev, dev_name(dev), dev, ktd2801,
+ &ktd2801_backlight_ops, NULL);
+ if (IS_ERR(bd))
+ return dev_err_probe(dev, PTR_ERR(bd),
+ "failed to register backlight");
+
+ bd->props.max_brightness = max_brightness;
+ bd->props.brightness = brightness;
+
+ ktd2801->bd = bd;
+ platform_set_drvdata(pdev, bd);
+ backlight_update_status(bd);
+
+ return 0;
+}
+
+static const struct of_device_id ktd2801_of_match[] = {
+ { .compatible = "kinetic,ktd2801" },
+ { }
+};
+MODULE_DEVICE_TABLE(of, ktd2801_of_match);
+
+static struct platform_driver ktd2801_backlight_driver = {
+ .driver = {
+ .name = "ktd2801-backlight",
+ .of_match_table = ktd2801_of_match,
+ },
+ .probe = ktd2801_backlight_probe,
+};
+module_platform_driver(ktd2801_backlight_driver);
+
+MODULE_IMPORT_NS(EXPRESSWIRE);
+MODULE_AUTHOR("Duje Mihanović <duje.mihanovic@skole.hr>");
+MODULE_DESCRIPTION("Kinetic KTD2801 Backlight Driver");
+MODULE_LICENSE("GPL");
diff --git a/drivers/video/backlight/l4f00242t03.c b/drivers/video/backlight/l4f00242t03.c
index cc763cf15f..bd5137ee20 100644
--- a/drivers/video/backlight/l4f00242t03.c
+++ b/drivers/video/backlight/l4f00242t03.c
@@ -179,34 +179,28 @@ static int l4f00242t03_probe(struct spi_device *spi)
priv->spi = spi;
priv->reset = devm_gpiod_get(&spi->dev, "reset", GPIOD_OUT_HIGH);
- if (IS_ERR(priv->reset)) {
- dev_err(&spi->dev,
- "Unable to get the lcd l4f00242t03 reset gpio.\n");
- return PTR_ERR(priv->reset);
- }
+ if (IS_ERR(priv->reset))
+ return dev_err_probe(&spi->dev, PTR_ERR(priv->reset),
+ "Unable to get the lcd l4f00242t03 reset gpio.\n");
gpiod_set_consumer_name(priv->reset, "lcd l4f00242t03 reset");
priv->enable = devm_gpiod_get(&spi->dev, "enable", GPIOD_OUT_LOW);
- if (IS_ERR(priv->enable)) {
- dev_err(&spi->dev,
- "Unable to get the lcd l4f00242t03 data en gpio.\n");
- return PTR_ERR(priv->enable);
- }
+ if (IS_ERR(priv->enable))
+ return dev_err_probe(&spi->dev, PTR_ERR(priv->enable),
+ "Unable to get the lcd l4f00242t03 data en gpio.\n");
gpiod_set_consumer_name(priv->enable, "lcd l4f00242t03 data enable");
priv->io_reg = devm_regulator_get(&spi->dev, "vdd");
- if (IS_ERR(priv->io_reg)) {
- dev_err(&spi->dev, "%s: Unable to get the IO regulator\n",
- __func__);
- return PTR_ERR(priv->io_reg);
- }
+ if (IS_ERR(priv->io_reg))
+ return dev_err_probe(&spi->dev, PTR_ERR(priv->io_reg),
+ "%s: Unable to get the IO regulator\n",
+ __func__);
priv->core_reg = devm_regulator_get(&spi->dev, "vcore");
- if (IS_ERR(priv->core_reg)) {
- dev_err(&spi->dev, "%s: Unable to get the core regulator\n",
- __func__);
- return PTR_ERR(priv->core_reg);
- }
+ if (IS_ERR(priv->core_reg))
+ return dev_err_probe(&spi->dev, PTR_ERR(priv->core_reg),
+ "%s: Unable to get the core regulator\n",
+ __func__);
priv->ld = devm_lcd_device_register(&spi->dev, "l4f00242t03", &spi->dev,
priv, &l4f_ops);
diff --git a/drivers/video/backlight/lm3630a_bl.c b/drivers/video/backlight/lm3630a_bl.c
index 26ff4178cc..76d47e2e82 100644
--- a/drivers/video/backlight/lm3630a_bl.c
+++ b/drivers/video/backlight/lm3630a_bl.c
@@ -189,10 +189,11 @@ static int lm3630a_bank_a_update_status(struct backlight_device *bl)
int ret;
struct lm3630a_chip *pchip = bl_get_data(bl);
enum lm3630a_pwm_ctrl pwm_ctrl = pchip->pdata->pwm_ctrl;
+ int brightness = backlight_get_brightness(bl);
/* pwm control */
if ((pwm_ctrl & LM3630A_PWM_BANK_A) != 0)
- return lm3630a_pwm_ctrl(pchip, bl->props.brightness,
+ return lm3630a_pwm_ctrl(pchip, brightness,
bl->props.max_brightness);
/* disable sleep */
@@ -201,9 +202,9 @@ static int lm3630a_bank_a_update_status(struct backlight_device *bl)
goto out_i2c_err;
usleep_range(1000, 2000);
/* minimum brightness is 0x04 */
- ret = lm3630a_write(pchip, REG_BRT_A, bl->props.brightness);
+ ret = lm3630a_write(pchip, REG_BRT_A, brightness);
- if (backlight_is_blank(bl) || (backlight_get_brightness(bl) < 0x4))
+ if (brightness < 0x4)
/* turn the string off */
ret |= lm3630a_update(pchip, REG_CTRL, LM3630A_LEDA_ENABLE, 0);
else
@@ -263,10 +264,11 @@ static int lm3630a_bank_b_update_status(struct backlight_device *bl)
int ret;
struct lm3630a_chip *pchip = bl_get_data(bl);
enum lm3630a_pwm_ctrl pwm_ctrl = pchip->pdata->pwm_ctrl;
+ int brightness = backlight_get_brightness(bl);
/* pwm control */
if ((pwm_ctrl & LM3630A_PWM_BANK_B) != 0)
- return lm3630a_pwm_ctrl(pchip, bl->props.brightness,
+ return lm3630a_pwm_ctrl(pchip, brightness,
bl->props.max_brightness);
/* disable sleep */
@@ -275,9 +277,9 @@ static int lm3630a_bank_b_update_status(struct backlight_device *bl)
goto out_i2c_err;
usleep_range(1000, 2000);
/* minimum brightness is 0x04 */
- ret = lm3630a_write(pchip, REG_BRT_B, bl->props.brightness);
+ ret = lm3630a_write(pchip, REG_BRT_B, brightness);
- if (backlight_is_blank(bl) || (backlight_get_brightness(bl) < 0x4))
+ if (brightness < 0x4)
/* turn the string off */
ret |= lm3630a_update(pchip, REG_CTRL, LM3630A_LEDB_ENABLE, 0);
else
@@ -538,10 +540,8 @@ static int lm3630a_probe(struct i2c_client *client)
pchip->enable_gpio = devm_gpiod_get_optional(&client->dev, "enable",
GPIOD_OUT_HIGH);
- if (IS_ERR(pchip->enable_gpio)) {
- rval = PTR_ERR(pchip->enable_gpio);
- return rval;
- }
+ if (IS_ERR(pchip->enable_gpio))
+ return PTR_ERR(pchip->enable_gpio);
/* chip initialize */
rval = lm3630a_chip_init(pchip);
@@ -558,10 +558,9 @@ static int lm3630a_probe(struct i2c_client *client)
/* pwm */
if (pdata->pwm_ctrl != LM3630A_PWM_DISABLE) {
pchip->pwmd = devm_pwm_get(pchip->dev, "lm3630a-pwm");
- if (IS_ERR(pchip->pwmd)) {
- dev_err(&client->dev, "fail : get pwm device\n");
- return PTR_ERR(pchip->pwmd);
- }
+ if (IS_ERR(pchip->pwmd))
+ return dev_err_probe(&client->dev, PTR_ERR(pchip->pwmd),
+ "fail : get pwm device\n");
pwm_init_state(pchip->pwmd, &pchip->pwmd_state);
}
diff --git a/drivers/video/backlight/mp3309c.c b/drivers/video/backlight/mp3309c.c
index 34d71259fa..4e98e60417 100644
--- a/drivers/video/backlight/mp3309c.c
+++ b/drivers/video/backlight/mp3309c.c
@@ -15,6 +15,8 @@
#include <linux/delay.h>
#include <linux/gpio/consumer.h>
#include <linux/i2c.h>
+#include <linux/mod_devicetable.h>
+#include <linux/property.h>
#include <linux/pwm.h>
#include <linux/regmap.h>
@@ -131,7 +133,7 @@ static int mp3309c_bl_update_status(struct backlight_device *bl)
chip->pdata->levels[brightness],
chip->pdata->levels[chip->pdata->max_brightness]);
pwmstate.enabled = true;
- ret = pwm_apply_state(chip->pwmd, &pwmstate);
+ ret = pwm_apply_might_sleep(chip->pwmd, &pwmstate);
if (ret)
return ret;
@@ -199,20 +201,16 @@ static const struct backlight_ops mp3309c_bl_ops = {
.update_status = mp3309c_bl_update_status,
};
-static int pm3309c_parse_dt_node(struct mp3309c_chip *chip,
- struct mp3309c_platform_data *pdata)
+static int mp3309c_parse_fwnode(struct mp3309c_chip *chip,
+ struct mp3309c_platform_data *pdata)
{
- struct device_node *node = chip->dev->of_node;
- struct property *prop_pwms;
- struct property *prop_levels = NULL;
- int length = 0;
int ret, i;
- unsigned int num_levels, tmp_value;
+ unsigned int tmp_value;
+ struct device *dev = chip->dev;
+ int num_levels;
- if (!node) {
- dev_err(chip->dev, "failed to get DT node\n");
- return -ENODEV;
- }
+ if (!dev_fwnode(dev))
+ return dev_err_probe(dev, -ENODEV, "failed to get firmware node\n");
/*
* Dimming mode: the MP3309C provides two dimming control mode:
@@ -224,12 +222,10 @@ static int pm3309c_parse_dt_node(struct mp3309c_chip *chip,
* found in the backlight node, the mode switches to PWM mode.
*/
pdata->dimming_mode = DIMMING_ANALOG_I2C;
- prop_pwms = of_find_property(node, "pwms", &length);
- if (prop_pwms) {
- chip->pwmd = devm_pwm_get(chip->dev, NULL);
+ if (device_property_present(dev, "pwms")) {
+ chip->pwmd = devm_pwm_get(dev, NULL);
if (IS_ERR(chip->pwmd))
- return dev_err_probe(chip->dev, PTR_ERR(chip->pwmd),
- "error getting pwm data\n");
+ return dev_err_probe(dev, PTR_ERR(chip->pwmd), "error getting pwm data\n");
pdata->dimming_mode = DIMMING_PWM;
pwm_apply_args(chip->pwmd);
}
@@ -247,21 +243,17 @@ static int pm3309c_parse_dt_node(struct mp3309c_chip *chip,
num_levels = ANALOG_I2C_NUM_LEVELS;
/* Enable GPIO used in I2C dimming mode only */
- chip->enable_gpio = devm_gpiod_get(chip->dev, "enable",
- GPIOD_OUT_HIGH);
+ chip->enable_gpio = devm_gpiod_get(dev, "enable", GPIOD_OUT_HIGH);
if (IS_ERR(chip->enable_gpio))
- return dev_err_probe(chip->dev,
- PTR_ERR(chip->enable_gpio),
+ return dev_err_probe(dev, PTR_ERR(chip->enable_gpio),
"error getting enable gpio\n");
} else {
/*
* PWM control mode: check for brightness level in DT
*/
- prop_levels = of_find_property(node, "brightness-levels",
- &length);
- if (prop_levels) {
+ if (device_property_present(dev, "brightness-levels")) {
/* Read brightness levels from DT */
- num_levels = length / sizeof(u32);
+ num_levels = device_property_count_u32(dev, "brightness-levels");
if (num_levels < 2)
return -EINVAL;
} else {
@@ -271,14 +263,12 @@ static int pm3309c_parse_dt_node(struct mp3309c_chip *chip,
}
/* Fill brightness levels array */
- pdata->levels = devm_kcalloc(chip->dev, num_levels,
- sizeof(*pdata->levels), GFP_KERNEL);
+ pdata->levels = devm_kcalloc(dev, num_levels, sizeof(*pdata->levels), GFP_KERNEL);
if (!pdata->levels)
return -ENOMEM;
- if (prop_levels) {
- ret = of_property_read_u32_array(node, "brightness-levels",
- pdata->levels,
- num_levels);
+ if (device_property_present(dev, "brightness-levels")) {
+ ret = device_property_read_u32_array(dev, "brightness-levels",
+ pdata->levels, num_levels);
if (ret < 0)
return ret;
} else {
@@ -288,13 +278,11 @@ static int pm3309c_parse_dt_node(struct mp3309c_chip *chip,
pdata->max_brightness = num_levels - 1;
- ret = of_property_read_u32(node, "default-brightness",
- &pdata->default_brightness);
+ ret = device_property_read_u32(dev, "default-brightness", &pdata->default_brightness);
if (ret)
pdata->default_brightness = pdata->max_brightness;
if (pdata->default_brightness > pdata->max_brightness) {
- dev_err(chip->dev,
- "default brightness exceeds max brightness\n");
+ dev_err_probe(dev, -ERANGE, "default brightness exceeds max brightness\n");
pdata->default_brightness = pdata->max_brightness;
}
@@ -310,8 +298,8 @@ static int pm3309c_parse_dt_node(struct mp3309c_chip *chip,
* If missing, the default value for OVP is 35.5V
*/
pdata->over_voltage_protection = REG_I2C_1_OVP1;
- if (!of_property_read_u32(node, "mps,overvoltage-protection-microvolt",
- &tmp_value)) {
+ ret = device_property_read_u32(dev, "mps,overvoltage-protection-microvolt", &tmp_value);
+ if (!ret) {
switch (tmp_value) {
case 13500000:
pdata->over_voltage_protection = 0x00;
@@ -328,62 +316,59 @@ static int pm3309c_parse_dt_node(struct mp3309c_chip *chip,
}
/* Synchronous (default) and non-synchronous mode */
- pdata->sync_mode = true;
- if (of_property_read_bool(node, "mps,no-sync-mode"))
- pdata->sync_mode = false;
+ pdata->sync_mode = !device_property_read_bool(dev, "mps,no-sync-mode");
return 0;
}
static int mp3309c_probe(struct i2c_client *client)
{
- struct mp3309c_platform_data *pdata = dev_get_platdata(&client->dev);
+ struct device *dev = &client->dev;
+ struct mp3309c_platform_data *pdata = dev_get_platdata(dev);
struct mp3309c_chip *chip;
struct backlight_properties props;
struct pwm_state pwmstate;
int ret;
- if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
- dev_err(&client->dev, "failed to check i2c functionality\n");
- return -EOPNOTSUPP;
- }
+ if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C))
+ return dev_err_probe(dev, -EOPNOTSUPP, "failed to check i2c functionality\n");
- chip = devm_kzalloc(&client->dev, sizeof(*chip), GFP_KERNEL);
+ chip = devm_kzalloc(dev, sizeof(*chip), GFP_KERNEL);
if (!chip)
return -ENOMEM;
- chip->dev = &client->dev;
+ chip->dev = dev;
chip->regmap = devm_regmap_init_i2c(client, &mp3309c_regmap);
if (IS_ERR(chip->regmap))
- return dev_err_probe(&client->dev, PTR_ERR(chip->regmap),
+ return dev_err_probe(dev, PTR_ERR(chip->regmap),
"failed to allocate register map\n");
i2c_set_clientdata(client, chip);
if (!pdata) {
- pdata = devm_kzalloc(chip->dev, sizeof(*pdata), GFP_KERNEL);
+ pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
if (!pdata)
return -ENOMEM;
- ret = pm3309c_parse_dt_node(chip, pdata);
+ ret = mp3309c_parse_fwnode(chip, pdata);
if (ret)
return ret;
}
chip->pdata = pdata;
/* Backlight properties */
+ memset(&props, 0, sizeof(struct backlight_properties));
props.brightness = pdata->default_brightness;
props.max_brightness = pdata->max_brightness;
props.scale = BACKLIGHT_SCALE_LINEAR;
props.type = BACKLIGHT_RAW;
props.power = FB_BLANK_UNBLANK;
props.fb_blank = FB_BLANK_UNBLANK;
- chip->bl = devm_backlight_device_register(chip->dev, "mp3309c",
- chip->dev, chip,
+ chip->bl = devm_backlight_device_register(dev, "mp3309c", dev, chip,
&mp3309c_bl_ops, &props);
if (IS_ERR(chip->bl))
- return dev_err_probe(chip->dev, PTR_ERR(chip->bl),
+ return dev_err_probe(dev, PTR_ERR(chip->bl),
"error registering backlight device\n");
/* In PWM dimming mode, enable pwm device */
@@ -393,10 +378,9 @@ static int mp3309c_probe(struct i2c_client *client)
chip->pdata->default_brightness,
chip->pdata->max_brightness);
pwmstate.enabled = true;
- ret = pwm_apply_state(chip->pwmd, &pwmstate);
+ ret = pwm_apply_might_sleep(chip->pwmd, &pwmstate);
if (ret)
- return dev_err_probe(chip->dev, ret,
- "error setting pwm device\n");
+ return dev_err_probe(dev, ret, "error setting pwm device\n");
}
chip->pdata->status = FIRST_POWER_ON;
diff --git a/drivers/video/backlight/pandora_bl.c b/drivers/video/backlight/pandora_bl.c
index f946470ce9..51faa889e0 100644
--- a/drivers/video/backlight/pandora_bl.c
+++ b/drivers/video/backlight/pandora_bl.c
@@ -114,10 +114,8 @@ static int pandora_backlight_probe(struct platform_device *pdev)
u8 r;
priv = devm_kmalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
- if (!priv) {
- dev_err(&pdev->dev, "failed to allocate driver private data\n");
+ if (!priv)
return -ENOMEM;
- }
memset(&props, 0, sizeof(props));
props.max_brightness = MAX_USER_VALUE;