drm/tinydrm: drm_of_find_backlight helper
Subsystems (2)
v4 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 v4:
- Remove "devices like tinydrm" from the function comments.
- Made devm_drm_of_find_backlight_release an internal function.
- Add dummy versions of drm_of_backlight functions.
Meghana Madhyastha (3):
drm/tinydrm: Move tinydrm_of_find_backlight into drm_of.c drm/tinydrm: Add devres versions of drm_of_find_backlight drm/tinydrm: Add the dummy versions of drm_of_find_backlight functions
drivers/gpu/drm/drm_of.c | 91 ++++++++++++++++++++++++++ drivers/gpu/drm/tinydrm/core/tinydrm-helpers.c | 40 ----------- drivers/gpu/drm/tinydrm/mi0283qt.c | 3 +- include/drm/drm_of.h | 15 +++++ include/drm/tinydrm/tinydrm-helpers.h | 1 - 5 files changed, 108 insertions(+), 42 deletions(-)
Signature · 6 lines
2.7.4 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v4 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 v4:
-None
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 | 1 + include/drm/tinydrm/tinydrm-helpers.h | 1 - 5 files changed, 47 insertions(+), 42 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 *
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);
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 v4 2/3 drm/tinydrm: Add devres versions of drm_of_find_backlight
In reply to Meghana MadhyasthaAdd devm_drm_of_find_backlight and the corresponding release function because some drivers such as tinydrm use devres versions of functions for requiring device resources.
---
Changes in v4:
-Made the release function an internal static function. -Removed specific reference to tinydrm in the function comments.
drivers/gpu/drm/drm_of.c | 47 ++++++++++++++++++++++++++++++++++++++ drivers/gpu/drm/tinydrm/mi0283qt.c | 2 +- include/drm/drm_of.h | 1 + 3 files changed, 49 insertions(+), 1 deletion(-)
drivers/gpu/drm/drm_of.c +47 -0
@@ -304,3 +304,50 @@ struct backlight_device *drm_of_find_backlight(struct device *dev)return backlight; }EXPORT_SYMBOL (drm_of_find_backlight); + +/** +* devm_drm_of_find_backlight_release - Release backlight device +* @dev: Device +* +* This is the release function corresponding to the devm_drm_of_find_backlight. +* Each devres entry is associated with a release function. +*/ +static void devm_drm_of_find_backlight_release (void *data) +{ +put_device (data); +} + +/** +* devm_drm_of_find_backlight - Find backlight device in device-tree +* devres version of the function +* @dev: Device +* +* This is the devres version of the function drm_of_find_backlight. +* Some drivers use devres versions of functions for +* requiring device resources. +* +* 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 *devm_drm_of_find_backlight (struct device *dev) +{ +struct backlight_device *backlight; +int ret; + + backlight =drm_of_find_backlight (dev); +if (IS_ERR_OR_NULL (backlight)) +return backlight; + + ret =devm_add_action (dev, devm_drm_of_find_backlight_release, + &backlight->dev); +if (ret) { +put_device (&backlight->dev); +return ERR_PTR (ret); + } + +return backlight; +} +EXPORT_SYMBOL (devm_drm_of_find_backlight);
drivers/gpu/drm/tinydrm/mi0283qt.c +1 -1
@@ -190,7 +190,7 @@ static int mi0283qt_probe(struct spi_device *spi)if (IS_ERR (mipi->regulator))return PTR_ERR (mipi->regulator); - mipi->backlight =drm_of_find_backlight (dev); + mipi->backlight =devm_drm_of_find_backlight (dev);if (IS_ERR (mipi->backlight))return PTR_ERR (mipi->backlight);
include/drm/drm_of.h +1 -0
@@ -30,6 +30,7 @@ int drm_of_find_panel_or_bridge(const struct device_node *np,struct drm_panel **panel, struct drm_bridge **bridge);struct backlight_device *drm_of_find_backlight (struct device *dev); +struct backlight_device *devm_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)
Signature · 6 lines
2.7.4 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v4 3/3 drm/tinydrm: Add the dummy versions of drm_of_find_backlight functions
In reply to Meghana MadhyasthaAdd the dummy versions (function definition returning -EINVAL) of drm_of_find_backlight and devm_drm_of_find_backlight in the #else part of the conditional directive in drm_of.h. This is needed for drivers where CONFIG_OF is optional.
---
Changes in v4:
-This commit was not present in the previous versions.
include/drm/drm_of.h | 13 +++++++++++++ 1 file changed, 13 insertions(+)
include/drm/drm_of.h +13 -0
@@ -60,6 +60,7 @@ static inline int drm_of_encoder_active_endpoint(struct device_node *node, {return -EINVAL ; } + static inline int drm_of_find_panel_or_bridge(const struct device_node *np, int port, int endpoint, struct drm_panel **panel,
@@ -67,6 +68,18 @@ static inline int drm_of_find_panel_or_bridge(const struct device_node *np, {return -EINVAL ; } + +static inline struct backlight_device *drm_of_find_backlight ( +struct device *dev); +{ +return -EINVAL ; +} + +static inline struct backlight_device *devm_drm_of_find_backlight ( +struct device *dev); +{ +return -EINVAL ; +}#endif static inline int drm_of_encoder_active_endpoint_id(struct device_node *node,
Signature · 1 line
2.7.4
kbuild test robot
build botRe: [PATCH v4 2/3] drm/tinydrm: Add devres versions of drm_of_find_backlight
In reply to Meghana Madhyasthareproduce:
Hi Meghana,
[auto build test ERROR on drm/drm-next]
[also build test ERROR on v4.14-rc2 next-20170929]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Meghana-Madhyastha/drm-tinydrm-drm_of_find_backlight-helper/20170930-122931 base: git://people.freedesktop.org/~airlied/linux.git drm-next config: x86_64-randconfig-x017-201739 (attached as .config) compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901 reproduce: # save the attached .config to linux build tree make ARCH=x86_64
Note: the linux-review/Meghana-Madhyastha/drm-tinydrm-drm_of_find_backlight-helper/20170930-122931 HEAD 4dc8fd20ad41e923832dc78cf4d8e7f98c0fedb9 builds fine.
It only hurts bisectibility.
All errors (new ones prefixed by >>):
drivers/gpu/drm/tinydrm/mi0283qt.c: In function 'mi0283qt_probe':
>> drivers/gpu/drm/tinydrm/mi0283qt.c:192:20: error: implicit declaration of function 'devm_drm_of_find_backlight' [-Werror=implicit-function-declaration]
mipi->backlight = devm_drm_of_find_backlight(dev);
^~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/gpu/drm/tinydrm/mi0283qt.c:192:18: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
mipi->backlight = devm_drm_of_find_backlight(dev);
^cc1: some warnings being treated as errors
vim +/devm_drm_of_find_backlight +192 drivers/gpu/drm/tinydrm/mi0283qt.c
163
164 static int mi0283qt_probe(struct spi_device *spi)
165 {
166 struct device *dev = &spi->dev;
167 struct mipi_dbi *mipi;
168 struct gpio_desc *dc;
169 u32 rotation = 0;
170 int ret;
171
172 mipi = devm_kzalloc(dev, sizeof(*mipi), GFP_KERNEL);
173 if (!mipi)
174 return -ENOMEM;
175
176 mipi->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH);
177 if (IS_ERR(mipi->reset)) {
178 dev_err(dev, "Failed to get gpio 'reset'\n");
179 return PTR_ERR(mipi->reset);
180 }
181
182 dc = devm_gpiod_get_optional(dev, "dc", GPIOD_OUT_LOW);
183 if (IS_ERR(dc)) {
184 dev_err(dev, "Failed to get gpio 'dc'\n");
185 return PTR_ERR(dc);
186 }
187
188 mipi->regulator = devm_regulator_get(dev, "power");
189 if (IS_ERR(mipi->regulator))
190 return PTR_ERR(mipi->regulator);
191
> 192 mipi->backlight = devm_drm_of_find_backlight(dev);
193 if (IS_ERR(mipi->backlight))
194 return PTR_ERR(mipi->backlight);
195
196 device_property_read_u32(dev, "rotation", &rotation);
197
198 ret = mipi_dbi_spi_init(spi, mipi, dc);
199 if (ret)
200 return ret;
201
202 ret = mipi_dbi_init(&spi->dev, mipi, &mi0283qt_pipe_funcs,
203 &mi0283qt_driver, &mi0283qt_mode, rotation);
204 if (ret)
205 return ret;
206
207 ret = mi0283qt_init(mipi);
208 if (ret)
209 return ret;
210
211 /* use devres to fini after drm unregister (drv->remove is before) */
212 ret = devm_add_action(dev, mi0283qt_fini, mipi);
213 if (ret) {
214 mi0283qt_fini(mipi);
215 return ret;
216 }
217
218 spi_set_drvdata(spi, mipi);
219
220 return devm_tinydrm_register(&mipi->tinydrm);
221 }
222
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
kbuild test robot
build botRe: [PATCH v4 3/3] drm/tinydrm: Add the dummy versions of drm_of_find_backlight functions
In reply to Meghana Madhyasthareproduce:
Hi Meghana,
[auto build test WARNING on drm/drm-next]
[also build test WARNING on v4.14-rc2 next-20170929]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Meghana-Madhyastha/drm-tinydrm-drm_of_find_backlight-helper/20170930-122931 base: git://people.freedesktop.org/~airlied/linux.git drm-next config: x86_64-randconfig-x017-201739 (attached as .config) compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901 reproduce: # save the attached .config to linux build tree make ARCH=x86_64
All warnings (new ones prefixed by >>):
In file included from drivers/gpu//drm/tinydrm/mi0283qt.c:15:0:
include/drm/drm_of.h:74:1: error: expected identifier or '(' before '{' token
{
^
include/drm/drm_of.h:80:1: error: expected identifier or '(' before '{' token
{
^
include/drm/drm_of.h:72:40: warning: 'drm_of_find_backlight' declared 'static' but never defined [-Wunused-function]
static inline struct backlight_device *drm_of_find_backlight(
^~~~~~~~~~~~~~~~~~~~~
>> include/drm/drm_of.h:78:40: warning: 'devm_drm_of_find_backlight' used but never defined
static inline struct backlight_device *devm_drm_of_find_backlight(
^~~~~~~~~~~~~~~~~~~~~~~~~~vim +/devm_drm_of_find_backlight +78 include/drm/drm_of.h
71
72 static inline struct backlight_device *drm_of_find_backlight(
73 struct device *dev);
> 74 {
75 return -EINVAL;
76 }
77
> 78 static inline struct backlight_device *devm_drm_of_find_backlight(
79 struct device *dev);
80 {
81 return -EINVAL;
82 }
83 #endif
84 ---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v4 3/3] drm/tinydrm: Add the dummy versions of drm_of_find_backlight functions
Quoted 26 lines · kbuild test robot
Hi Meghana,
[auto build test WARNING on drm/drm-next]
[also build test WARNING on v4.14-rc2 next-20170929]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]url: https://github.com/0day-ci/linux/commits/Meghana-Madhyastha/drm-tinydrm-drm_of_find_backlight-helper/20170930-122931 base: git://people.freedesktop.org/~airlied/linux.git drm-next config: x86_64-randconfig-x017-201739 (attached as .config) compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901 reproduce: # save the attached .config to linux build tree make ARCH=x86_64All warnings (new ones prefixed by >>):
In file included from drivers/gpu//drm/tinydrm/mi0283qt.c:15:0: include/drm/drm_of.h:74:1: error: expected identifier or '(' before '{' token { ^ include/drm/drm_of.h:80:1: error: expected identifier or '(' before '{' token { ^ include/drm/drm_of.h:72:40: warning: 'drm_of_find_backlight' declared 'static' but never defined [-Wunused-function] static inline struct backlight_device *drm_of_find_backlight( ^~~~~~~~~~~~~~~~~~~~~
Quoted 2 lines
Quoted 1 line
Quoted 1 line
include/drm/drm_of.h:78:40: warning: 'devm_drm_of_find_backlight' used but never definedstatic inline struct backlight_device *devm_drm_of_find_backlight(
You need to squash the dummy version into the patch that introduces the first usage, otherwise compilation can fail and break bisecting. And looks liek this doesn't compile. It takes a bit of playing around until you have a Kconfig that hits this. Luckily 0day has constructed one for you already.
-Daniel
Quoted 22 lines
^~~~~~~~~~~~~~~~~~~~~~~~~~vim +/devm_drm_of_find_backlight +78
include/drm/drm_of.h71 72 static inline struct backlight_device *drm_of_find_backlight( 73 struct device *dev);Quoted 1 line
74 {
75 return -EINVAL; 76 } 77Quoted 1 line
78 static inline struct
backlight_device*devm_drm_of_find_backlight(79 struct device *dev); 80 { 81 return -EINVAL; 82 } 83 #endif 84---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch