- Fix-ups

- Constification; pwm_bl
    - Use new GPIO API; gpio_backlight
    - Remove unused functionality; gpio_backlight
 
  - Bug Fixes
    - Fix artificial MAXREG limit; lm3630a_bl
 -----BEGIN PGP SIGNATURE-----
 
 iQIcBAABCAAGBQJZsQM7AAoJEFGvii+H/HdhjnEP/2dzeg6nAEWbaMXkUR+pNhF/
 ohZHTjW7mQjt1CUKUS0aF3E8QLWZlXd+e9uvuFfEpysCBaZVNglOEEMlypapKSvu
 qXWmd8fFTfAjSWuV13LYQM+puSOWH8j5iK7wDHXyZyRovyxVCTPony50D4XOTnrN
 FGiwXIDc94yzKZtCnzkzPQmnDMjbFZJ5aA7AHDXkiX3+46A4PbCcpDBCHrO0gXZE
 3T7hoTLRkiWMqmBjghKGl8FB2DIj7WIs1+RS5J1SkYMERjhmUwdP1WPMQNojO/5O
 bLCyeS5cjvNHWG9r/J1FrR5rCE5MNOBqmjA1EMBz4I9TqZ9eZKeLWkvJKLpFOC8v
 tZq7YmHdWs+E0GAoRHwuT5DrMyIp2xchyWcCBph2F8T743TncM7l3c+O6HLmGwo0
 mkX8Z/2GSmFSJ2oZ5IsKGg+5z/+jT+maL+9MaO1FvLNVobnox6qYtGf9uEav8O3t
 z8uuCL1BcoL3UZJyZwh3kF/hPNyibeMtv2mPqDHtPG8cVo/xINS6J6KLmXpXM4k6
 M6ifvu2dvaz/sq8RWwBQGwNgBHgbfeBLY1UatB4E4/uRb/z/FYGh4BvJGEwTVRro
 Vfl49x6w8TkpjZ5FEbGT5lbynR2luSXJRFwpSjNQrHWgasAnz3gR/KKqERXAQyyL
 cZhGdZbAQc4L8R1RD3CZ
 =XUEP
 -----END PGP SIGNATURE-----

Merge tag 'backlight-next-4.14' of git://git.kernel.org/pub/scm/linux/kernel/git/lee/backlight

Pull backlight updates from Lee Jones:
 "Fix-ups:
   - Constification; pwm_bl
   - Use new GPIO API; gpio_backlight
   - Remove unused functionality; gpio_backlight

  Bug Fixes:
   - Fix artificial MAXREG limit; lm3630a_bl"

* tag 'backlight-next-4.14' of git://git.kernel.org/pub/scm/linux/kernel/git/lee/backlight:
  backlight: gpio_backlight: Delete pdata inversion
  backlight: gpio_backlight: Convert to use GPIO descriptor
  backlight: pwm_bl: Make of_device_ids const
  backlight: lm3630a: Bump REG_MAX value to 0x50 instead of 0x1F
This commit is contained in:
Linus Torvalds 2017-09-07 13:55:16 -07:00
commit 75c727155c
4 changed files with 40 additions and 36 deletions

View File

@ -9,7 +9,8 @@
#include <linux/backlight.h>
#include <linux/err.h>
#include <linux/fb.h>
#include <linux/gpio.h>
#include <linux/gpio.h> /* Only for legacy support */
#include <linux/gpio/consumer.h>
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/module.h>
@ -23,8 +24,7 @@ struct gpio_backlight {
struct device *dev;
struct device *fbdev;
int gpio;
int active;
struct gpio_desc *gpiod;
int def_value;
};
@ -38,8 +38,7 @@ static int gpio_backlight_update_status(struct backlight_device *bl)
bl->props.state & (BL_CORE_SUSPENDED | BL_CORE_FBBLANK))
brightness = 0;
gpio_set_value_cansleep(gbl->gpio,
brightness ? gbl->active : !gbl->active);
gpiod_set_value_cansleep(gbl->gpiod, brightness);
return 0;
}
@ -61,22 +60,24 @@ static const struct backlight_ops gpio_backlight_ops = {
static int gpio_backlight_probe_dt(struct platform_device *pdev,
struct gpio_backlight *gbl)
{
struct device_node *np = pdev->dev.of_node;
enum of_gpio_flags gpio_flags;
gbl->gpio = of_get_gpio_flags(np, 0, &gpio_flags);
if (!gpio_is_valid(gbl->gpio)) {
if (gbl->gpio != -EPROBE_DEFER) {
dev_err(&pdev->dev,
"Error: The gpios parameter is missing or invalid.\n");
}
return gbl->gpio;
}
gbl->active = (gpio_flags & OF_GPIO_ACTIVE_LOW) ? 0 : 1;
struct device *dev = &pdev->dev;
struct device_node *np = dev->of_node;
enum gpiod_flags flags;
int ret;
gbl->def_value = of_property_read_bool(np, "default-on");
flags = gbl->def_value ? GPIOD_OUT_HIGH : GPIOD_OUT_LOW;
gbl->gpiod = devm_gpiod_get(dev, NULL, flags);
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;
}
return 0;
}
@ -89,7 +90,6 @@ 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) {
@ -109,22 +109,26 @@ static int gpio_backlight_probe(struct platform_device *pdev)
if (ret)
return ret;
} else {
/*
* Legacy platform data GPIO retrieveal. Do not expand
* the use of this code path, currently only used by one
* SH board.
*/
unsigned long flags = GPIOF_DIR_OUT;
gbl->fbdev = pdata->fbdev;
gbl->gpio = pdata->gpio;
gbl->active = pdata->active_low ? 0 : 1;
gbl->def_value = pdata->def_value;
}
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");
return ret;
ret = devm_gpio_request_one(gbl->dev, pdata->gpio, flags,
pdata ? pdata->name : "backlight");
if (ret < 0) {
dev_err(&pdev->dev, "unable to request GPIO\n");
return ret;
}
gbl->gpiod = gpio_to_desc(pdata->gpio);
if (!gbl->gpiod)
return -EINVAL;
}
memset(&props, 0, sizeof(props));

View File

@ -31,7 +31,8 @@
#define REG_FAULT 0x0B
#define REG_PWM_OUTLOW 0x12
#define REG_PWM_OUTHIGH 0x13
#define REG_MAX 0x1F
#define REG_FILTER_STRENGTH 0x50
#define REG_MAX 0x50
#define INT_DEBOUNCE_MSEC 10
struct lm3630a_chip {
@ -80,7 +81,7 @@ static int lm3630a_chip_init(struct lm3630a_chip *pchip)
usleep_range(1000, 2000);
/* set Filter Strength Register */
rval = lm3630a_write(pchip, 0x50, 0x03);
rval = lm3630a_write(pchip, REG_FILTER_STRENGTH, 0x03);
/* set Cofig. register */
rval |= lm3630a_update(pchip, REG_CONFIG, 0x07, pdata->pwm_ctrl);
/* set boost control */

View File

@ -178,7 +178,7 @@ static int pwm_backlight_parse_dt(struct device *dev,
return 0;
}
static struct of_device_id pwm_backlight_of_match[] = {
static const struct of_device_id pwm_backlight_of_match[] = {
{ .compatible = "pwm-backlight" },
{ }
};

View File

@ -14,7 +14,6 @@ struct gpio_backlight_platform_data {
struct device *fbdev;
int gpio;
int def_value;
bool active_low;
const char *name;
};