drm/tinydrm: drm_of_find_backlight helper
Subsystems (2)
v2 cover drm/tinydrm: drm_of_find_backlight helper
This patchset introduces some changes such as move tinydrm_of_find_backlight to drm_of.c and rename it to drm_of_find_backlight for better organizational structure.
Changes in v2:
-Broke the patch into a patchset of 3 patches -Added devres versions of drm_of_find_backlight -Added a note about caller having to call put_device
Meghana Madhyastha (3):
drm/tinydrm: Move tinydrm_of_find_backlight into drm_of.c drm/tinydrm: Call drm_of_find_backlight instead of
tinydrm_of_find_backlight
drm/tinydrm: Add devres versions of drm_of_find_backlight
drivers/gpu/drm/drm_of.c | 44 ++++++++++++++++++++++++++ drivers/gpu/drm/tinydrm/core/tinydrm-helpers.c | 40 ----------------------- drivers/gpu/drm/tinydrm/mi0283qt.c | 3 +- include/drm/drm_of.h | 3 ++ include/drm/tinydrm/tinydrm-helpers.h | 1 - 5 files changed, 49 insertions(+), 42 deletions(-)
Signature · 6 lines
2.7.4 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v2 1/3 drm/tinydrm: Move tinydrm_of_find_backlight into drm_of.c
Rename tinydrm_of_find_backlight to drm_of_find_backlight and move it into drm_of.c from tinydrm-helpers.c. This is because other drivers in the drm subsystem might need to call this function. In that case and otherwise, it is better from an organizational point of view to move it into drm_of.c along with the other _of.c functions.
---
Changes in v2:
-Added note about it being the callers responsibility to call put_device.
drivers/gpu/drm/drm_of.c | 44 ++++++++++++++++++++++++++ drivers/gpu/drm/tinydrm/core/tinydrm-helpers.c | 40 ----------------------- include/drm/drm_of.h | 1 + include/drm/tinydrm/tinydrm-helpers.h | 1 - 4 files changed, 45 insertions(+), 41 deletions(-)
drivers/gpu/drm/drm_of.c +44 -0
@@ -1,6 +1,7 @@#include <linux/component.h> #include <linux/export.h> #include <linux/list.h> +#include <linux/backlight.h> #include <linux/of_graph.h> #include <drm/drmP.h> #include <drm/drm_bridge.h>
@@ -260,3 +261,46 @@ int drm_of_find_panel_or_bridge(const struct device_node *np,return ret; }EXPORT_SYMBOL_GPL (drm_of_find_panel_or_bridge); + +/** +* drm_of_find_backlight - Find backlight device in device-tree +* @dev: Device +* +* This function looks for a DT node pointed to by a property named 'backlight' +* and uses of_find_backlight_by_node() to get the backlight device. +* Additionally if the brightness property is zero, it is set to +* max_brightness. +* +* Note: It is the responsibility of the caller to call put_device() when +* releasing the resource. +* +* Returns: +* NULL if there's no backlight property. +* Error pointer -EPROBE_DEFER if the DT node is found, but no backlight device +* is found. +* If the backlight device is found, a pointer to the structure is returned. +*/ +struct backlight_device *drm_of_find_backlight (struct device *dev) +{ +struct backlight_device *backlight; +struct device_node *np; + + np =of_parse_phandle (dev->of_node,"backlight" ,0 ); +if (!np) +return NULL ; + + backlight =of_find_backlight_by_node (np); +of_node_put (np); + +if (!backlight) +return ERR_PTR (-EPROBE_DEFER ); + +if (!backlight->props.brightness) { + backlight->props.brightness = backlight->props.max_brightness; +DRM_DEBUG_KMS ("Backlight brightness set to %d\n" , + backlight->props.brightness); + } + +return backlight; +} +EXPORT_SYMBOL (drm_of_find_backlight);
drivers/gpu/drm/tinydrm/core/tinydrm-helpers.c +0 -40
@@ -237,46 +237,6 @@ void tinydrm_xrgb8888_to_gray8(u8 *dst, void *vaddr, struct drm_framebuffer *fb,EXPORT_SYMBOL (tinydrm_xrgb8888_to_gray8);/** -* tinydrm_of_find_backlight - Find backlight device in device-tree -* @dev: Device -* -* This function looks for a DT node pointed to by a property named 'backlight' -* and uses of_find_backlight_by_node() to get the backlight device. -* Additionally if the brightness property is zero, it is set to -* max_brightness. -* -* Returns: -* NULL if there's no backlight property. -* Error pointer -EPROBE_DEFER if the DT node is found, but no backlight device -* is found. -* If the backlight device is found, a pointer to the structure is returned. -*/ -struct backlight_device *tinydrm_of_find_backlight (struct device *dev) -{ -struct backlight_device *backlight; -struct device_node *np; - - np =of_parse_phandle (dev->of_node,"backlight" ,0 ); -if (!np) -return NULL ; - - backlight =of_find_backlight_by_node (np); -of_node_put (np); - -if (!backlight) -return ERR_PTR (-EPROBE_DEFER ); - -if (!backlight->props.brightness) { - backlight->props.brightness = backlight->props.max_brightness; -DRM_DEBUG_KMS ("Backlight brightness set to %d\n" , - backlight->props.brightness); - } - -return backlight; -} -EXPORT_SYMBOL (tinydrm_of_find_backlight); - -/** * tinydrm_enable_backlight - Enable backlight helper * @backlight: Backlight device *
include/drm/drm_of.h +1 -0
@@ -29,6 +29,7 @@ int drm_of_find_panel_or_bridge(const struct device_node *np, int port, int endpoint, struct drm_panel **panel, struct drm_bridge **bridge); +struct backlight_device *drm_of_find_backlight (struct device *dev);#else static inline uint32_t drm_of_find_possible_crtcs (struct drm_device *dev,struct device_node *port)
include/drm/tinydrm/tinydrm-helpers.h +0 -1
@@ -46,7 +46,6 @@ void tinydrm_xrgb8888_to_rgb565(u16 *dst, void *vaddr,void tinydrm_xrgb8888_to_gray8 (u8 *dst,void *vaddr,struct drm_framebuffer *fb,struct drm_clip_rect *clip); -struct backlight_device *tinydrm_of_find_backlight (struct device *dev);int tinydrm_enable_backlight (struct backlight_device *backlight);int tinydrm_disable_backlight (struct backlight_device *backlight);
Signature · 6 lines
2.7.4 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v2 2/3 drm/tinydrm: Call drm_of_find_backlight instead of tinydrm_of_find_backlight
In reply to Meghana MadhyasthaCall drm_of_find_backlight from of_drm.c as the function has been renamed and moved.
---
Changes in v2:
-Introduce this as a separate patch in a patchset instead of combining it with the previous changes.
drivers/gpu/drm/tinydrm/mi0283qt.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/tinydrm/mi0283qt.c +2 -1
@@ -12,6 +12,7 @@#include <drm/tinydrm/ili9341.h> #include <drm/tinydrm/mipi-dbi.h> #include <drm/tinydrm/tinydrm-helpers.h> +#include <drm/drm_of.h> #include <linux/delay.h> #include <linux/gpio/consumer.h> #include <linux/module.h>
@@ -189,7 +190,7 @@ static int mi0283qt_probe(struct spi_device *spi)if (IS_ERR (mipi->regulator))return PTR_ERR (mipi->regulator); - mipi->backlight =tinydrm_of_find_backlight (dev); + mipi->backlight =drm_of_find_backlight (dev);if (IS_ERR (mipi->backlight))return PTR_ERR (mipi->backlight);
Signature · 6 lines
2.7.4 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Review
Quoted 8 lines · Meghana Madhyastha
This patchset introduces some changes such as move
tinydrm_of_find_backlighttodrm_of.cand rename it todrm_of_find_backlightfor better organizational structure.Changes in v2:
(quoted diff) +0
-3-Broke the patch into a patchset of 3 patches -Added devres versions of drm_of_find_backlight -Added a note about caller having to call put_device
Sorry for making you respin this once more, but the split-up here doesn't make sense. After patch 1 tinydrm doesn't compile anymore (since it still uses tinydrm_of_find_backlight, but that's removed already). I've also made a few other comments on v1 of your series.
-Daniel
Quoted 17 lines
Meghana Madhyastha (3):
drm/tinydrm: Movetinydrm_of_find_backlightintodrm_of.cdrm/tinydrm: Calldrm_of_find_backlightinstead of
tinydrm_of_find_backlight
drm/tinydrm: Add devres versions ofdrm_of_find_backlightdrivers/gpu/drm/drm_of.c | 44 ++++++++++++++++++++++++++ drivers/gpu/drm/tinydrm/core/tinydrm-helpers.c | 40 ----------------------- drivers/gpu/drm/tinydrm/mi0283qt.c | 3 +- include/drm/drm_of.h | 3 ++ include/drm/tinydrm/tinydrm-helpers.h | 1 - 5 files changed, 49 insertions(+), 42 deletions(-)Signature · 1 line
2.7.4
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch