Skip to content

Commit b303ab7

Browse files
Uwe Kleine-Königlag-linaro
authored andcommitted
backlight: lp8788: Drop support for platform data
The backlight driver supports getting passed platform data. However this isn't used. This allows to remove quite some dead code from the driver because bl->pdata is always NULL, and so bl->mode is always LP8788_BL_REGISTER_ONLY. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Reviewed-by: Daniel Thompson <daniel.thompson@linaro.org> Link: https://lore.kernel.org/r/20240329133839.550065-2-u.kleine-koenig@pengutronix.de Signed-off-by: Lee Jones <lee@kernel.org>
1 parent 717bbf0 commit b303ab7

File tree

2 files changed

+8
-179
lines changed

2 files changed

+8
-179
lines changed

drivers/video/backlight/lp8788_bl.c

Lines changed: 8 additions & 143 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
#include <linux/mfd/lp8788.h>
1313
#include <linux/module.h>
1414
#include <linux/platform_device.h>
15-
#include <linux/pwm.h>
1615
#include <linux/slab.h>
1716

1817
/* Register address */
@@ -31,149 +30,40 @@
3130
#define MAX_BRIGHTNESS 127
3231
#define DEFAULT_BL_NAME "lcd-backlight"
3332

34-
struct lp8788_bl_config {
35-
enum lp8788_bl_ctrl_mode bl_mode;
36-
enum lp8788_bl_dim_mode dim_mode;
37-
enum lp8788_bl_full_scale_current full_scale;
38-
enum lp8788_bl_ramp_step rise_time;
39-
enum lp8788_bl_ramp_step fall_time;
40-
enum pwm_polarity pwm_pol;
41-
};
42-
4333
struct lp8788_bl {
4434
struct lp8788 *lp;
4535
struct backlight_device *bl_dev;
46-
struct lp8788_backlight_platform_data *pdata;
47-
enum lp8788_bl_ctrl_mode mode;
48-
struct pwm_device *pwm;
49-
};
50-
51-
static struct lp8788_bl_config default_bl_config = {
52-
.bl_mode = LP8788_BL_REGISTER_ONLY,
53-
.dim_mode = LP8788_DIM_EXPONENTIAL,
54-
.full_scale = LP8788_FULLSCALE_1900uA,
55-
.rise_time = LP8788_RAMP_8192us,
56-
.fall_time = LP8788_RAMP_8192us,
57-
.pwm_pol = PWM_POLARITY_NORMAL,
5836
};
5937

60-
static inline bool is_brightness_ctrl_by_pwm(enum lp8788_bl_ctrl_mode mode)
61-
{
62-
return mode == LP8788_BL_COMB_PWM_BASED;
63-
}
64-
65-
static inline bool is_brightness_ctrl_by_register(enum lp8788_bl_ctrl_mode mode)
66-
{
67-
return mode == LP8788_BL_REGISTER_ONLY ||
68-
mode == LP8788_BL_COMB_REGISTER_BASED;
69-
}
70-
7138
static int lp8788_backlight_configure(struct lp8788_bl *bl)
7239
{
73-
struct lp8788_backlight_platform_data *pdata = bl->pdata;
74-
struct lp8788_bl_config *cfg = &default_bl_config;
7540
int ret;
7641
u8 val;
7742

78-
/*
79-
* Update chip configuration if platform data exists,
80-
* otherwise use the default settings.
81-
*/
82-
if (pdata) {
83-
cfg->bl_mode = pdata->bl_mode;
84-
cfg->dim_mode = pdata->dim_mode;
85-
cfg->full_scale = pdata->full_scale;
86-
cfg->rise_time = pdata->rise_time;
87-
cfg->fall_time = pdata->fall_time;
88-
cfg->pwm_pol = pdata->pwm_pol;
89-
}
90-
9143
/* Brightness ramp up/down */
92-
val = (cfg->rise_time << LP8788_BL_RAMP_RISE_SHIFT) | cfg->fall_time;
44+
val = (LP8788_RAMP_8192us << LP8788_BL_RAMP_RISE_SHIFT) | LP8788_RAMP_8192us;
9345
ret = lp8788_write_byte(bl->lp, LP8788_BL_RAMP, val);
9446
if (ret)
9547
return ret;
9648

9749
/* Fullscale current setting */
98-
val = (cfg->full_scale << LP8788_BL_FULLSCALE_SHIFT) |
99-
(cfg->dim_mode << LP8788_BL_DIM_MODE_SHIFT);
50+
val = (LP8788_FULLSCALE_1900uA << LP8788_BL_FULLSCALE_SHIFT) |
51+
(LP8788_DIM_EXPONENTIAL << LP8788_BL_DIM_MODE_SHIFT);
10052

10153
/* Brightness control mode */
102-
switch (cfg->bl_mode) {
103-
case LP8788_BL_REGISTER_ONLY:
104-
val |= LP8788_BL_EN;
105-
break;
106-
case LP8788_BL_COMB_PWM_BASED:
107-
case LP8788_BL_COMB_REGISTER_BASED:
108-
val |= LP8788_BL_EN | LP8788_BL_PWM_INPUT_EN |
109-
(cfg->pwm_pol << LP8788_BL_PWM_POLARITY_SHIFT);
110-
break;
111-
default:
112-
dev_err(bl->lp->dev, "invalid mode: %d\n", cfg->bl_mode);
113-
return -EINVAL;
114-
}
115-
116-
bl->mode = cfg->bl_mode;
54+
val |= LP8788_BL_EN;
11755

11856
return lp8788_write_byte(bl->lp, LP8788_BL_CONFIG, val);
11957
}
12058

121-
static void lp8788_pwm_ctrl(struct lp8788_bl *bl, int br, int max_br)
122-
{
123-
unsigned int period;
124-
unsigned int duty;
125-
struct device *dev;
126-
struct pwm_device *pwm;
127-
128-
if (!bl->pdata)
129-
return;
130-
131-
period = bl->pdata->period_ns;
132-
duty = br * period / max_br;
133-
dev = bl->lp->dev;
134-
135-
/* request PWM device with the consumer name */
136-
if (!bl->pwm) {
137-
pwm = devm_pwm_get(dev, LP8788_DEV_BACKLIGHT);
138-
if (IS_ERR(pwm)) {
139-
dev_err(dev, "can not get PWM device\n");
140-
return;
141-
}
142-
143-
bl->pwm = pwm;
144-
145-
/*
146-
* FIXME: pwm_apply_args() should be removed when switching to
147-
* the atomic PWM API.
148-
*/
149-
pwm_apply_args(pwm);
150-
}
151-
152-
pwm_config(bl->pwm, duty, period);
153-
if (duty)
154-
pwm_enable(bl->pwm);
155-
else
156-
pwm_disable(bl->pwm);
157-
}
158-
15959
static int lp8788_bl_update_status(struct backlight_device *bl_dev)
16060
{
16161
struct lp8788_bl *bl = bl_get_data(bl_dev);
162-
enum lp8788_bl_ctrl_mode mode = bl->mode;
16362

16463
if (bl_dev->props.state & BL_CORE_SUSPENDED)
16564
bl_dev->props.brightness = 0;
16665

167-
if (is_brightness_ctrl_by_pwm(mode)) {
168-
int brt = bl_dev->props.brightness;
169-
int max = bl_dev->props.max_brightness;
170-
171-
lp8788_pwm_ctrl(bl, brt, max);
172-
} else if (is_brightness_ctrl_by_register(mode)) {
173-
u8 brt = bl_dev->props.brightness;
174-
175-
lp8788_write_byte(bl->lp, LP8788_BL_BRIGHTNESS, brt);
176-
}
66+
lp8788_write_byte(bl->lp, LP8788_BL_BRIGHTNESS, bl_dev->props.brightness);
17767

17868
return 0;
17969
}
@@ -187,30 +77,16 @@ static int lp8788_backlight_register(struct lp8788_bl *bl)
18777
{
18878
struct backlight_device *bl_dev;
18979
struct backlight_properties props;
190-
struct lp8788_backlight_platform_data *pdata = bl->pdata;
191-
int init_brt;
192-
char *name;
19380

19481
memset(&props, 0, sizeof(struct backlight_properties));
19582
props.type = BACKLIGHT_PLATFORM;
19683
props.max_brightness = MAX_BRIGHTNESS;
19784

19885
/* Initial brightness */
199-
if (pdata)
200-
init_brt = min_t(int, pdata->initial_brightness,
201-
props.max_brightness);
202-
else
203-
init_brt = 0;
204-
205-
props.brightness = init_brt;
86+
props.brightness = 0;
20687

20788
/* Backlight device name */
208-
if (!pdata || !pdata->name)
209-
name = DEFAULT_BL_NAME;
210-
else
211-
name = pdata->name;
212-
213-
bl_dev = backlight_device_register(name, bl->lp->dev, bl,
89+
bl_dev = backlight_device_register(DEFAULT_BL_NAME, bl->lp->dev, bl,
21490
&lp8788_bl_ops, &props);
21591
if (IS_ERR(bl_dev))
21692
return PTR_ERR(bl_dev);
@@ -230,16 +106,7 @@ static void lp8788_backlight_unregister(struct lp8788_bl *bl)
230106
static ssize_t lp8788_get_bl_ctl_mode(struct device *dev,
231107
struct device_attribute *attr, char *buf)
232108
{
233-
struct lp8788_bl *bl = dev_get_drvdata(dev);
234-
enum lp8788_bl_ctrl_mode mode = bl->mode;
235-
char *strmode;
236-
237-
if (is_brightness_ctrl_by_pwm(mode))
238-
strmode = "PWM based";
239-
else if (is_brightness_ctrl_by_register(mode))
240-
strmode = "Register based";
241-
else
242-
strmode = "Invalid mode";
109+
const char *strmode = "Register based";
243110

244111
return scnprintf(buf, PAGE_SIZE, "%s\n", strmode);
245112
}
@@ -266,8 +133,6 @@ static int lp8788_backlight_probe(struct platform_device *pdev)
266133
return -ENOMEM;
267134

268135
bl->lp = lp;
269-
if (lp->pdata)
270-
bl->pdata = lp->pdata->bl_pdata;
271136

272137
platform_set_drvdata(pdev, bl);
273138

include/linux/mfd/lp8788.h

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
#define __MFD_LP8788_H__
1212

1313
#include <linux/irqdomain.h>
14-
#include <linux/pwm.h>
1514
#include <linux/regmap.h>
1615

1716
#define LP8788_DEV_BUCK "lp8788-buck"
@@ -87,12 +86,6 @@ enum lp8788_charger_event {
8786
CHARGER_DETECTED,
8887
};
8988

90-
enum lp8788_bl_ctrl_mode {
91-
LP8788_BL_REGISTER_ONLY,
92-
LP8788_BL_COMB_PWM_BASED, /* PWM + I2C, changed by PWM input */
93-
LP8788_BL_COMB_REGISTER_BASED, /* PWM + I2C, changed by I2C */
94-
};
95-
9689
enum lp8788_bl_dim_mode {
9790
LP8788_DIM_EXPONENTIAL,
9891
LP8788_DIM_LINEAR,
@@ -201,31 +194,6 @@ struct lp8788_charger_platform_data {
201194
enum lp8788_charger_event event);
202195
};
203196

204-
/*
205-
* struct lp8788_backlight_platform_data
206-
* @name : backlight driver name. (default: "lcd-backlight")
207-
* @initial_brightness : initial value of backlight brightness
208-
* @bl_mode : brightness control by pwm or lp8788 register
209-
* @dim_mode : dimming mode selection
210-
* @full_scale : full scale current setting
211-
* @rise_time : brightness ramp up step time
212-
* @fall_time : brightness ramp down step time
213-
* @pwm_pol : pwm polarity setting when bl_mode is pwm based
214-
* @period_ns : platform specific pwm period value. unit is nano.
215-
Only valid when bl_mode is LP8788_BL_COMB_PWM_BASED
216-
*/
217-
struct lp8788_backlight_platform_data {
218-
char *name;
219-
int initial_brightness;
220-
enum lp8788_bl_ctrl_mode bl_mode;
221-
enum lp8788_bl_dim_mode dim_mode;
222-
enum lp8788_bl_full_scale_current full_scale;
223-
enum lp8788_bl_ramp_step rise_time;
224-
enum lp8788_bl_ramp_step fall_time;
225-
enum pwm_polarity pwm_pol;
226-
unsigned int period_ns;
227-
};
228-
229197
/*
230198
* struct lp8788_led_platform_data
231199
* @name : led driver name. (default: "keyboard-backlight")
@@ -267,7 +235,6 @@ struct lp8788_vib_platform_data {
267235
* @buck2_dvs : configurations for buck2 dvs
268236
* @chg_pdata : platform data for charger driver
269237
* @alarm_sel : rtc alarm selection (1 or 2)
270-
* @bl_pdata : configurable data for backlight driver
271238
* @led_pdata : configurable data for led driver
272239
* @vib_pdata : configurable data for vibrator driver
273240
* @adc_pdata : iio map data for adc driver
@@ -289,9 +256,6 @@ struct lp8788_platform_data {
289256
/* rtc alarm */
290257
enum lp8788_alarm_sel alarm_sel;
291258

292-
/* backlight */
293-
struct lp8788_backlight_platform_data *bl_pdata;
294-
295259
/* current sinks */
296260
struct lp8788_led_platform_data *led_pdata;
297261
struct lp8788_vib_platform_data *vib_pdata;

0 commit comments

Comments
 (0)