Re: [PATCH v12 3/3] drm/tinydrm: Add devres versions of backlight_get

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




Den 12.10.2017 17.57, skrev Meghana Madhyastha:
Add devm_backlight_get and the corresponding release
function because some drivers use devres versions of functions
for requiring device resources.

Signed-off-by: Meghana Madhyastha <meghana.madhyastha@xxxxxxxxx>
---
Changes in v12:
  -Move backlight_put() to the patch 2/3 from patch 3/3.

  drivers/gpu/drm/tinydrm/mi0283qt.c  |  2 +-
  drivers/video/backlight/backlight.c | 25 +++++++++++++++++++++++++
  include/linux/backlight.h           | 16 ++++++++++++++++
  3 files changed, 42 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/tinydrm/mi0283qt.c b/drivers/gpu/drm/tinydrm/mi0283qt.c
index edf9502..03fec36 100644
--- a/drivers/gpu/drm/tinydrm/mi0283qt.c
+++ b/drivers/gpu/drm/tinydrm/mi0283qt.c
@@ -190,7 +190,7 @@ static int mi0283qt_probe(struct spi_device *spi)
  	if (IS_ERR(mipi->regulator))
  		return PTR_ERR(mipi->regulator);
- mipi->backlight = backlight_get(dev);
+	mipi->backlight = devm_backlight_get(dev);
  	if (IS_ERR(mipi->backlight))
  		return PTR_ERR(mipi->backlight);
diff --git a/drivers/video/backlight/backlight.c b/drivers/video/backlight/backlight.c
index f3e95b3..3663f26 100644
--- a/drivers/video/backlight/backlight.c
+++ b/drivers/video/backlight/backlight.c
@@ -623,6 +623,31 @@ static inline void backlight_put(struct backlight_device *bd)
  		put_device(&bd->dev);
  }
+/**
+ ** devm_backlight_get - Resource-managed backlight_get()
+ ** @dev: Device
+ **
+ ** Device managed version of backlight_get(). The reference on the backlight
+ ** device is automatically dropped on driver detach.
+ **/
+struct backlight_device *devm_backlight_get(struct device *dev)
+{
+	struct backlight_device *bd;
+	int ret;
+
+	bd = backlight_get(dev);
+	if (!bd)
+		return NULL;
+	ret = devm_add_action(dev, devm_backlight_get_release, bd);

How can this even compile? Where is devm_backlight_get_release?
Or didn't it change name to devm_backlight_put or something?

+	if (ret) {
+		backlight_put(bd);
+		return ERR_PTR(ret);
+	}
+
+	return bd;
+}
+EXPORT_SYMBOL(devm_backlight_get);
+
  static void __exit backlight_class_exit(void)
  {
  	class_destroy(backlight_class);
diff --git a/include/linux/backlight.h b/include/linux/backlight.h
index 1d713b3..0bfadb6 100644
--- a/include/linux/backlight.h
+++ b/include/linux/backlight.h
@@ -183,6 +183,16 @@ static inline int backlight_disable(struct backlight_device *bd)
  	return backlight_update_status(bd);
  }
+/**
+ ** backlight_put - Drop backlight reference
+ ** @bd: the backlight device to put
+ **/
+static inline void backlight_put(struct backlight_device *bd)
+{
+	if (bd)
+		put_device(&bd->dev);
+}
+

This is the one that should be moved to to previous patch.

  struct generic_bl_info {
  	const char *name;
  	int max_intensity;
@@ -204,11 +214,17 @@ of_find_backlight_by_node(struct device_node *node)
#if IS_ENABLED(CONFIG_BACKLIGHT_CLASS_DEVICE)
  struct backlight_device *backlight_get(struct device *dev);
+struct backlight_device *devm_backlight_get(struct device *dev);
  #else
  static inline struct backlight_device *backlight_get(struct device *dev)
  {
  	return NULL;
  }
+
+static inline struct backlight_device *devm_backlight_get(struct device *dev)
+{
+	return NULL;
+}
  #endif
#endif

_______________________________________________
dri-devel mailing list
dri-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/dri-devel




[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux