diff options
Diffstat (limited to 'drivers/video')
-rw-r--r-- | drivers/video/backlight/adp8860_bl.c | 18 | ||||
-rw-r--r-- | drivers/video/backlight/adp8870_bl.c | 10 | ||||
-rw-r--r-- | drivers/video/backlight/gpio_backlight.c | 10 | ||||
-rw-r--r-- | drivers/video/backlight/pwm_bl.c | 28 | ||||
-rw-r--r-- | drivers/video/backlight/tps65217_bl.c | 9 | ||||
-rw-r--r-- | drivers/video/fbdev/fsl-diu-fb.c | 13 | ||||
-rw-r--r-- | drivers/video/fbdev/via/via-gpio.c | 19 |
7 files changed, 77 insertions, 30 deletions
diff --git a/drivers/video/backlight/adp8860_bl.c b/drivers/video/backlight/adp8860_bl.c index 98ffe71..510e559 100644 --- a/drivers/video/backlight/adp8860_bl.c +++ b/drivers/video/backlight/adp8860_bl.c @@ -566,11 +566,13 @@ static ssize_t adp8860_bl_ambient_light_level_show(struct device *dev, mutex_lock(&data->lock); error = adp8860_read(data->client, ADP8860_PH1LEVL, ®_val); - ret_val = reg_val; - error |= adp8860_read(data->client, ADP8860_PH1LEVH, ®_val); + if (!error) { + ret_val = reg_val; + error = adp8860_read(data->client, ADP8860_PH1LEVH, ®_val); + } mutex_unlock(&data->lock); - if (error < 0) + if (error) return error; /* Return 13-bit conversion value for the first light sensor */ @@ -621,10 +623,12 @@ static ssize_t adp8860_bl_ambient_light_zone_store(struct device *dev, /* Set user supplied ambient light zone */ mutex_lock(&data->lock); - adp8860_read(data->client, ADP8860_CFGR, ®_val); - reg_val &= ~(CFGR_BLV_MASK << CFGR_BLV_SHIFT); - reg_val |= (val - 1) << CFGR_BLV_SHIFT; - adp8860_write(data->client, ADP8860_CFGR, reg_val); + ret = adp8860_read(data->client, ADP8860_CFGR, ®_val); + if (!ret) { + reg_val &= ~(CFGR_BLV_MASK << CFGR_BLV_SHIFT); + reg_val |= (val - 1) << CFGR_BLV_SHIFT; + adp8860_write(data->client, ADP8860_CFGR, reg_val); + } mutex_unlock(&data->lock); } diff --git a/drivers/video/backlight/adp8870_bl.c b/drivers/video/backlight/adp8870_bl.c index 9d73835..21acac9 100644 --- a/drivers/video/backlight/adp8870_bl.c +++ b/drivers/video/backlight/adp8870_bl.c @@ -807,10 +807,12 @@ static ssize_t adp8870_bl_ambient_light_zone_store(struct device *dev, /* Set user supplied ambient light zone */ mutex_lock(&data->lock); - adp8870_read(data->client, ADP8870_CFGR, ®_val); - reg_val &= ~(CFGR_BLV_MASK << CFGR_BLV_SHIFT); - reg_val |= (val - 1) << CFGR_BLV_SHIFT; - adp8870_write(data->client, ADP8870_CFGR, reg_val); + ret = adp8870_read(data->client, ADP8870_CFGR, ®_val); + if (!ret) { + reg_val &= ~(CFGR_BLV_MASK << CFGR_BLV_SHIFT); + reg_val |= (val - 1) << CFGR_BLV_SHIFT; + adp8870_write(data->client, ADP8870_CFGR, reg_val); + } mutex_unlock(&data->lock); } diff --git a/drivers/video/backlight/gpio_backlight.c b/drivers/video/backlight/gpio_backlight.c index 5fbbc2e..1813441 100644 --- a/drivers/video/backlight/gpio_backlight.c +++ b/drivers/video/backlight/gpio_backlight.c @@ -89,6 +89,7 @@ static int gpio_backlight_probe(struct platform_device *pdev) struct backlight_device *bl; struct gpio_backlight *gbl; struct device_node *np = pdev->dev.of_node; + unsigned long flags = GPIOF_DIR_OUT; int ret; if (!pdata && !np) { @@ -114,9 +115,12 @@ static int gpio_backlight_probe(struct platform_device *pdev) gbl->def_value = pdata->def_value; } - ret = devm_gpio_request_one(gbl->dev, gbl->gpio, GPIOF_DIR_OUT | - (gbl->active ? GPIOF_INIT_LOW - : GPIOF_INIT_HIGH), + if (gbl->active) + flags |= gbl->def_value ? GPIOF_INIT_HIGH : GPIOF_INIT_LOW; + else + flags |= gbl->def_value ? GPIOF_INIT_LOW : GPIOF_INIT_HIGH; + + ret = devm_gpio_request_one(gbl->dev, gbl->gpio, flags, pdata ? pdata->name : "backlight"); if (ret < 0) { dev_err(&pdev->dev, "unable to request GPIO\n"); diff --git a/drivers/video/backlight/pwm_bl.c b/drivers/video/backlight/pwm_bl.c index ae3c6b6..64f9e1b 100644 --- a/drivers/video/backlight/pwm_bl.c +++ b/drivers/video/backlight/pwm_bl.c @@ -198,7 +198,9 @@ static int pwm_backlight_probe(struct platform_device *pdev) struct platform_pwm_backlight_data defdata; struct backlight_properties props; struct backlight_device *bl; + struct device_node *node = pdev->dev.of_node; struct pwm_bl_data *pb; + int initial_blank = FB_BLANK_UNBLANK; int ret; if (!data) { @@ -242,7 +244,7 @@ static int pwm_backlight_probe(struct platform_device *pdev) pb->enabled = false; pb->enable_gpio = devm_gpiod_get_optional(&pdev->dev, "enable", - GPIOD_OUT_HIGH); + GPIOD_ASIS); if (IS_ERR(pb->enable_gpio)) { ret = PTR_ERR(pb->enable_gpio); goto err_alloc; @@ -264,15 +266,32 @@ static int pwm_backlight_probe(struct platform_device *pdev) pb->enable_gpio = gpio_to_desc(data->enable_gpio); } + if (pb->enable_gpio) { + /* + * If the driver is probed from the device tree and there is a + * phandle link pointing to the backlight node, it is safe to + * assume that another driver will enable the backlight at the + * appropriate time. Therefore, if it is disabled, keep it so. + */ + if (node && node->phandle && + gpiod_get_direction(pb->enable_gpio) == GPIOF_DIR_OUT && + gpiod_get_value(pb->enable_gpio) == 0) + initial_blank = FB_BLANK_POWERDOWN; + else + gpiod_direction_output(pb->enable_gpio, 1); + } + pb->power_supply = devm_regulator_get(&pdev->dev, "power"); if (IS_ERR(pb->power_supply)) { ret = PTR_ERR(pb->power_supply); goto err_alloc; } + if (node && node->phandle && !regulator_is_enabled(pb->power_supply)) + initial_blank = FB_BLANK_POWERDOWN; + pb->pwm = devm_pwm_get(&pdev->dev, NULL); - if (IS_ERR(pb->pwm) && PTR_ERR(pb->pwm) != -EPROBE_DEFER - && !pdev->dev.of_node) { + if (IS_ERR(pb->pwm) && PTR_ERR(pb->pwm) != -EPROBE_DEFER && !node) { dev_err(&pdev->dev, "unable to request PWM, trying legacy API\n"); pb->legacy = true; pb->pwm = pwm_request(data->pwm_id, "pwm-backlight"); @@ -309,6 +328,8 @@ static int pwm_backlight_probe(struct platform_device *pdev) if (IS_ERR(bl)) { dev_err(&pdev->dev, "failed to register backlight\n"); ret = PTR_ERR(bl); + if (pb->legacy) + pwm_free(pb->pwm); goto err_alloc; } @@ -320,6 +341,7 @@ static int pwm_backlight_probe(struct platform_device *pdev) } bl->props.brightness = data->dft_brightness; + bl->props.power = initial_blank; backlight_update_status(bl); platform_set_drvdata(pdev, bl); diff --git a/drivers/video/backlight/tps65217_bl.c b/drivers/video/backlight/tps65217_bl.c index 61d72bf..fd524ad 100644 --- a/drivers/video/backlight/tps65217_bl.c +++ b/drivers/video/backlight/tps65217_bl.c @@ -320,10 +320,19 @@ static int tps65217_bl_probe(struct platform_device *pdev) return 0; } +#ifdef CONFIG_OF +static const struct of_device_id tps65217_bl_of_match[] = { + { .compatible = "ti,tps65217-bl", }, + { /* sentinel */ }, +}; +MODULE_DEVICE_TABLE(of, tps65217_bl_of_match); +#endif + static struct platform_driver tps65217_bl_driver = { .probe = tps65217_bl_probe, .driver = { .name = "tps65217-bl", + .of_match_table = of_match_ptr(tps65217_bl_of_match), }, }; diff --git a/drivers/video/fbdev/fsl-diu-fb.c b/drivers/video/fbdev/fsl-diu-fb.c index b335c1a..fe00a07 100644 --- a/drivers/video/fbdev/fsl-diu-fb.c +++ b/drivers/video/fbdev/fsl-diu-fb.c @@ -479,7 +479,10 @@ static enum fsl_diu_monitor_port fsl_diu_name_to_port(const char *s) port = FSL_DIU_PORT_DLVDS; } - return diu_ops.valid_monitor_port(port); + if (diu_ops.valid_monitor_port) + port = diu_ops.valid_monitor_port(port); + + return port; } /* @@ -1915,6 +1918,14 @@ static int __init fsl_diu_init(void) #else monitor_port = fsl_diu_name_to_port(monitor_string); #endif + + /* + * Must to verify set_pixel_clock. If not implement on platform, + * then that means that there is no platform support for the DIU. + */ + if (!diu_ops.set_pixel_clock) + return -ENODEV; + pr_info("Freescale Display Interface Unit (DIU) framebuffer driver\n"); #ifdef CONFIG_NOT_COHERENT_CACHE diff --git a/drivers/video/fbdev/via/via-gpio.c b/drivers/video/fbdev/via/via-gpio.c index 6f433b8..1e89c34 100644 --- a/drivers/video/fbdev/via/via-gpio.c +++ b/drivers/video/fbdev/via/via-gpio.c @@ -6,7 +6,7 @@ */ #include <linux/spinlock.h> -#include <linux/gpio.h> +#include <linux/gpio/driver.h> #include <linux/platform_device.h> #include <linux/via-core.h> #include <linux/via-gpio.h> @@ -83,9 +83,7 @@ struct viafb_gpio_cfg { static void via_gpio_set(struct gpio_chip *chip, unsigned int nr, int value) { - struct viafb_gpio_cfg *cfg = container_of(chip, - struct viafb_gpio_cfg, - gpio_chip); + struct viafb_gpio_cfg *cfg = gpiochip_get_data(chip); u8 reg; struct viafb_gpio *gpio; unsigned long flags; @@ -115,9 +113,7 @@ static int via_gpio_dir_out(struct gpio_chip *chip, unsigned int nr, */ static int via_gpio_dir_input(struct gpio_chip *chip, unsigned int nr) { - struct viafb_gpio_cfg *cfg = container_of(chip, - struct viafb_gpio_cfg, - gpio_chip); + struct viafb_gpio_cfg *cfg = gpiochip_get_data(chip); struct viafb_gpio *gpio; unsigned long flags; @@ -131,9 +127,7 @@ static int via_gpio_dir_input(struct gpio_chip *chip, unsigned int nr) static int via_gpio_get(struct gpio_chip *chip, unsigned int nr) { - struct viafb_gpio_cfg *cfg = container_of(chip, - struct viafb_gpio_cfg, - gpio_chip); + struct viafb_gpio_cfg *cfg = gpiochip_get_data(chip); u8 reg; struct viafb_gpio *gpio; unsigned long flags; @@ -142,7 +136,7 @@ static int via_gpio_get(struct gpio_chip *chip, unsigned int nr) gpio = cfg->active_gpios[nr]; reg = via_read_reg(VIASR, gpio->vg_port_index); spin_unlock_irqrestore(&cfg->vdev->reg_lock, flags); - return reg & (0x04 << gpio->vg_mask_shift); + return !!(reg & (0x04 << gpio->vg_mask_shift)); } @@ -255,7 +249,8 @@ static int viafb_gpio_probe(struct platform_device *platdev) * Get registered. */ viafb_gpio_config.gpio_chip.base = -1; /* Dynamic */ - ret = gpiochip_add(&viafb_gpio_config.gpio_chip); + ret = gpiochip_add_data(&viafb_gpio_config.gpio_chip, + &viafb_gpio_config); if (ret) { printk(KERN_ERR "viafb: failed to add gpios (%d)\n", ret); viafb_gpio_config.gpio_chip.ngpio = 0; |