diff options
author | Meghana Madhyastha <meghana.madhyastha@gmail.com> | 2018-01-24 11:40:51 -0500 |
---|---|---|
committer | Sean Paul <seanpaul@chromium.org> | 2018-02-20 11:07:22 -0500 |
commit | c69f94570d7ab4c8cbc5ba14729cc73a7dbdbfec (patch) | |
tree | 30e48a526fb8d7c68da4ee9e4a488ff680e6401b | |
parent | f4ccc2b5767c3246826f40fdf166112aa376af8c (diff) |
drm/panel: Use of_find_backlight helper
Replace of_find_backlight_by_node and of the code around it
with of_find_backlight helper to avoid repetition of code.
Reviewed-by: Noralf Trønnes <noralf@tronnes.org>
Reviewed-by: Sean Paul <seanpaul@chromium.org>
Acked-by: Thierry Reding <treding@nvidia.com>
Signed-off-by: Meghana Madhyastha <meghana.madhyastha@gmail.com>
Signed-off-by: Sean Paul <seanpaul@chromium.org>
Link: https://patchwork.freedesktop.org/patch/msgid/140d01afb138d687680b2d1776a4c101c9fa9a0a.1516810725.git.meghana.madhyastha@gmail.com
-rw-r--r-- | drivers/gpu/drm/panel/panel-innolux-p079zca.c | 24 | ||||
-rw-r--r-- | drivers/gpu/drm/panel/panel-sharp-lq101r1sx01.c | 28 | ||||
-rw-r--r-- | drivers/gpu/drm/panel/panel-sharp-ls043t1le01.c | 27 |
3 files changed, 13 insertions, 66 deletions
diff --git a/drivers/gpu/drm/panel/panel-innolux-p079zca.c b/drivers/gpu/drm/panel/panel-innolux-p079zca.c index 4c1b29eec2a5..57df39b5c589 100644 --- a/drivers/gpu/drm/panel/panel-innolux-p079zca.c +++ b/drivers/gpu/drm/panel/panel-innolux-p079zca.c | |||
@@ -215,7 +215,6 @@ MODULE_DEVICE_TABLE(of, innolux_of_match); | |||
215 | static int innolux_panel_add(struct innolux_panel *innolux) | 215 | static int innolux_panel_add(struct innolux_panel *innolux) |
216 | { | 216 | { |
217 | struct device *dev = &innolux->link->dev; | 217 | struct device *dev = &innolux->link->dev; |
218 | struct device_node *np; | ||
219 | int err; | 218 | int err; |
220 | 219 | ||
221 | innolux->supply = devm_regulator_get(dev, "power"); | 220 | innolux->supply = devm_regulator_get(dev, "power"); |
@@ -230,37 +229,22 @@ static int innolux_panel_add(struct innolux_panel *innolux) | |||
230 | innolux->enable_gpio = NULL; | 229 | innolux->enable_gpio = NULL; |
231 | } | 230 | } |
232 | 231 | ||
233 | np = of_parse_phandle(dev->of_node, "backlight", 0); | 232 | innolux->backlight = devm_of_find_backlight(dev); |
234 | if (np) { | ||
235 | innolux->backlight = of_find_backlight_by_node(np); | ||
236 | of_node_put(np); | ||
237 | 233 | ||
238 | if (!innolux->backlight) | 234 | if (IS_ERR(innolux->backlight)) |
239 | return -EPROBE_DEFER; | 235 | return PTR_ERR(innolux->backlight); |
240 | } | ||
241 | 236 | ||
242 | drm_panel_init(&innolux->base); | 237 | drm_panel_init(&innolux->base); |
243 | innolux->base.funcs = &innolux_panel_funcs; | 238 | innolux->base.funcs = &innolux_panel_funcs; |
244 | innolux->base.dev = &innolux->link->dev; | 239 | innolux->base.dev = &innolux->link->dev; |
245 | 240 | ||
246 | err = drm_panel_add(&innolux->base); | 241 | return drm_panel_add(&innolux->base); |
247 | if (err < 0) | ||
248 | goto put_backlight; | ||
249 | |||
250 | return 0; | ||
251 | |||
252 | put_backlight: | ||
253 | put_device(&innolux->backlight->dev); | ||
254 | |||
255 | return err; | ||
256 | } | 242 | } |
257 | 243 | ||
258 | static void innolux_panel_del(struct innolux_panel *innolux) | 244 | static void innolux_panel_del(struct innolux_panel *innolux) |
259 | { | 245 | { |
260 | if (innolux->base.dev) | 246 | if (innolux->base.dev) |
261 | drm_panel_remove(&innolux->base); | 247 | drm_panel_remove(&innolux->base); |
262 | |||
263 | put_device(&innolux->backlight->dev); | ||
264 | } | 248 | } |
265 | 249 | ||
266 | static int innolux_panel_probe(struct mipi_dsi_device *dsi) | 250 | static int innolux_panel_probe(struct mipi_dsi_device *dsi) |
diff --git a/drivers/gpu/drm/panel/panel-sharp-lq101r1sx01.c b/drivers/gpu/drm/panel/panel-sharp-lq101r1sx01.c index 072c0fc794d6..6bf8730f1a21 100644 --- a/drivers/gpu/drm/panel/panel-sharp-lq101r1sx01.c +++ b/drivers/gpu/drm/panel/panel-sharp-lq101r1sx01.c | |||
@@ -318,8 +318,7 @@ MODULE_DEVICE_TABLE(of, sharp_of_match); | |||
318 | 318 | ||
319 | static int sharp_panel_add(struct sharp_panel *sharp) | 319 | static int sharp_panel_add(struct sharp_panel *sharp) |
320 | { | 320 | { |
321 | struct device_node *np; | 321 | struct device *dev = &sharp->link1->dev; |
322 | int err; | ||
323 | 322 | ||
324 | sharp->mode = &default_mode; | 323 | sharp->mode = &default_mode; |
325 | 324 | ||
@@ -327,30 +326,16 @@ static int sharp_panel_add(struct sharp_panel *sharp) | |||
327 | if (IS_ERR(sharp->supply)) | 326 | if (IS_ERR(sharp->supply)) |
328 | return PTR_ERR(sharp->supply); | 327 | return PTR_ERR(sharp->supply); |
329 | 328 | ||
330 | np = of_parse_phandle(sharp->link1->dev.of_node, "backlight", 0); | 329 | sharp->backlight = devm_of_find_backlight(dev); |
331 | if (np) { | ||
332 | sharp->backlight = of_find_backlight_by_node(np); | ||
333 | of_node_put(np); | ||
334 | 330 | ||
335 | if (!sharp->backlight) | 331 | if (IS_ERR(sharp->backlight)) |
336 | return -EPROBE_DEFER; | 332 | return PTR_ERR(sharp->backlight); |
337 | } | ||
338 | 333 | ||
339 | drm_panel_init(&sharp->base); | 334 | drm_panel_init(&sharp->base); |
340 | sharp->base.funcs = &sharp_panel_funcs; | 335 | sharp->base.funcs = &sharp_panel_funcs; |
341 | sharp->base.dev = &sharp->link1->dev; | 336 | sharp->base.dev = &sharp->link1->dev; |
342 | 337 | ||
343 | err = drm_panel_add(&sharp->base); | 338 | return drm_panel_add(&sharp->base); |
344 | if (err < 0) | ||
345 | goto put_backlight; | ||
346 | |||
347 | return 0; | ||
348 | |||
349 | put_backlight: | ||
350 | if (sharp->backlight) | ||
351 | put_device(&sharp->backlight->dev); | ||
352 | |||
353 | return err; | ||
354 | } | 339 | } |
355 | 340 | ||
356 | static void sharp_panel_del(struct sharp_panel *sharp) | 341 | static void sharp_panel_del(struct sharp_panel *sharp) |
@@ -358,9 +343,6 @@ static void sharp_panel_del(struct sharp_panel *sharp) | |||
358 | if (sharp->base.dev) | 343 | if (sharp->base.dev) |
359 | drm_panel_remove(&sharp->base); | 344 | drm_panel_remove(&sharp->base); |
360 | 345 | ||
361 | if (sharp->backlight) | ||
362 | put_device(&sharp->backlight->dev); | ||
363 | |||
364 | if (sharp->link2) | 346 | if (sharp->link2) |
365 | put_device(&sharp->link2->dev); | 347 | put_device(&sharp->link2->dev); |
366 | } | 348 | } |
diff --git a/drivers/gpu/drm/panel/panel-sharp-ls043t1le01.c b/drivers/gpu/drm/panel/panel-sharp-ls043t1le01.c index 8a5137963c7d..494aa9b1628a 100644 --- a/drivers/gpu/drm/panel/panel-sharp-ls043t1le01.c +++ b/drivers/gpu/drm/panel/panel-sharp-ls043t1le01.c | |||
@@ -253,8 +253,6 @@ static const struct drm_panel_funcs sharp_nt_panel_funcs = { | |||
253 | static int sharp_nt_panel_add(struct sharp_nt_panel *sharp_nt) | 253 | static int sharp_nt_panel_add(struct sharp_nt_panel *sharp_nt) |
254 | { | 254 | { |
255 | struct device *dev = &sharp_nt->dsi->dev; | 255 | struct device *dev = &sharp_nt->dsi->dev; |
256 | struct device_node *np; | ||
257 | int ret; | ||
258 | 256 | ||
259 | sharp_nt->mode = &default_mode; | 257 | sharp_nt->mode = &default_mode; |
260 | 258 | ||
@@ -271,39 +269,22 @@ static int sharp_nt_panel_add(struct sharp_nt_panel *sharp_nt) | |||
271 | gpiod_set_value(sharp_nt->reset_gpio, 0); | 269 | gpiod_set_value(sharp_nt->reset_gpio, 0); |
272 | } | 270 | } |
273 | 271 | ||
274 | np = of_parse_phandle(dev->of_node, "backlight", 0); | 272 | sharp_nt->backlight = devm_of_find_backlight(dev); |
275 | if (np) { | ||
276 | sharp_nt->backlight = of_find_backlight_by_node(np); | ||
277 | of_node_put(np); | ||
278 | 273 | ||
279 | if (!sharp_nt->backlight) | 274 | if (IS_ERR(sharp_nt->backlight)) |
280 | return -EPROBE_DEFER; | 275 | return PTR_ERR(sharp_nt->backlight); |
281 | } | ||
282 | 276 | ||
283 | drm_panel_init(&sharp_nt->base); | 277 | drm_panel_init(&sharp_nt->base); |
284 | sharp_nt->base.funcs = &sharp_nt_panel_funcs; | 278 | sharp_nt->base.funcs = &sharp_nt_panel_funcs; |
285 | sharp_nt->base.dev = &sharp_nt->dsi->dev; | 279 | sharp_nt->base.dev = &sharp_nt->dsi->dev; |
286 | 280 | ||
287 | ret = drm_panel_add(&sharp_nt->base); | 281 | return drm_panel_add(&sharp_nt->base); |
288 | if (ret < 0) | ||
289 | goto put_backlight; | ||
290 | |||
291 | return 0; | ||
292 | |||
293 | put_backlight: | ||
294 | if (sharp_nt->backlight) | ||
295 | put_device(&sharp_nt->backlight->dev); | ||
296 | |||
297 | return ret; | ||
298 | } | 282 | } |
299 | 283 | ||
300 | static void sharp_nt_panel_del(struct sharp_nt_panel *sharp_nt) | 284 | static void sharp_nt_panel_del(struct sharp_nt_panel *sharp_nt) |
301 | { | 285 | { |
302 | if (sharp_nt->base.dev) | 286 | if (sharp_nt->base.dev) |
303 | drm_panel_remove(&sharp_nt->base); | 287 | drm_panel_remove(&sharp_nt->base); |
304 | |||
305 | if (sharp_nt->backlight) | ||
306 | put_device(&sharp_nt->backlight->dev); | ||
307 | } | 288 | } |
308 | 289 | ||
309 | static int sharp_nt_panel_probe(struct mipi_dsi_device *dsi) | 290 | static int sharp_nt_panel_probe(struct mipi_dsi_device *dsi) |