diff mbox

lcd: Provide dummy functions if CONFIG_LCD_CLASS_DEVICE is not set

Message ID 1394695879-22845-1-git-send-email-shc_work@mail.ru (mailing list archive)
State New, archived
Headers show

Commit Message

Alexander Shiyan March 13, 2014, 7:31 a.m. UTC
Provide dummy functions for LCD register()/unregister() if
CONFIG_LCD_CLASS_DEVICE is not set.

Signed-off-by: Alexander Shiyan <shc_work@mail.ru>
---
 include/linux/lcd.h | 37 ++++++++++++++++++++++++++++++-------
 1 file changed, 30 insertions(+), 7 deletions(-)

Comments

Tomi Valkeinen March 13, 2014, 8:23 a.m. UTC | #1
On 13/03/14 09:31, Alexander Shiyan wrote:
> Provide dummy functions for LCD register()/unregister() if
> CONFIG_LCD_CLASS_DEVICE is not set.

Hmm, why do you want to do that? If a driver needs the LCD class, it
should depend on or select it.

 Tomi
Alexander Shiyan March 13, 2014, 8:48 a.m. UTC | #2
???????, 13 ????? 2014, 10:23 +02:00 ?? Tomi Valkeinen <tomi.valkeinen@ti.com>:
> On 13/03/14 09:31, Alexander Shiyan wrote:
> > Provide dummy functions for LCD register()/unregister() if
> > CONFIG_LCD_CLASS_DEVICE is not set.
> 
> Hmm, why do you want to do that? If a driver needs the LCD class, it
> should depend on or select it.

I inspect my recent changes for the imxfb driver.
I use the LCD class for power management and contrast, nevertheless,
if it lack in the kernel this leads to an error.
Yes, we can choose the LCD_CLASS_DEVICE symbol for the imxfb driver,
but at the same time we must choose BACKLIGHT_LCD_SUPPORT.
I do not think it's a good way.
In any case, I would like to revise the patch to use NULL as a result
if there is no support LCD_CLASS_DEVICE in the kernel.
Additionally, I have a plan to convert "menuconfig" entry for
BACKLIGHT_LCD_SUPPORT to the "menu".
OK?

---
Tomi Valkeinen March 13, 2014, 9:04 a.m. UTC | #3
On 13/03/14 10:48, Alexander Shiyan wrote:
> ???????, 13 ????? 2014, 10:23 +02:00 ?? Tomi Valkeinen <tomi.valkeinen@ti.com>:
>> On 13/03/14 09:31, Alexander Shiyan wrote:
>>> Provide dummy functions for LCD register()/unregister() if
>>> CONFIG_LCD_CLASS_DEVICE is not set.
>>
>> Hmm, why do you want to do that? If a driver needs the LCD class, it
>> should depend on or select it.
> 
> I inspect my recent changes for the imxfb driver.
> I use the LCD class for power management and contrast, nevertheless,
> if it lack in the kernel this leads to an error.

So is the CONFIG_LCD_CLASS_DEVICE optional for imxfb? It works fine with
or without the LCD class support? Is there some reason to run it without
LCD class support?

> Yes, we can choose the LCD_CLASS_DEVICE symbol for the imxfb driver,
> but at the same time we must choose BACKLIGHT_LCD_SUPPORT.
> I do not think it's a good way.

Why not?

> In any case, I would like to revise the patch to use NULL as a result
> if there is no support LCD_CLASS_DEVICE in the kernel.

Why do you want to run imxfb without LCD_CLASS_DEVICE? Isn't it simpler
to just depend on it?

> Additionally, I have a plan to convert "menuconfig" entry for
> BACKLIGHT_LCD_SUPPORT to the "menu".

Hmm. That does make sense, as I don't see BACKLIGHT_LCD_SUPPORT
affecting anything, except enabling the BL & LCD Kconfig menu.

However, many of the items in BL & LCD menu have, for some reason,
"default y" or "default m". So if you make BACKLIGHT_LCD_SUPPORT a menu,
it means all those subitems are always enabled. So there definitely will
be a side effect to that change.

I guess there's legacy reasons why many of the items are enabled by
default. It would make sense to me to have BACKLIGHT_LCD_SUPPORT as a
menu, as you suggest, and having all the subitems disabled by default.
But again, that would change the current behavior, which may or may not
cause issues.

 Tomi
diff mbox

Patch

diff --git a/include/linux/lcd.h b/include/linux/lcd.h
index 504f624..f1c94fd 100644
--- a/include/linux/lcd.h
+++ b/include/linux/lcd.h
@@ -110,14 +110,37 @@  static inline void lcd_set_power(struct lcd_device *ld, int power)
 	mutex_unlock(&ld->update_lock);
 }
 
-extern struct lcd_device *lcd_device_register(const char *name,
-	struct device *parent, void *devdata, struct lcd_ops *ops);
-extern struct lcd_device *devm_lcd_device_register(struct device *dev,
-	const char *name, struct device *parent,
+#if defined(CONFIG_LCD_CLASS_DEVICE) || defined(CONFIG_LCD_CLASS_DEVICE_MODULE)
+struct lcd_device *lcd_device_register(const char *name, struct device *parent,
 	void *devdata, struct lcd_ops *ops);
-extern void lcd_device_unregister(struct lcd_device *ld);
-extern void devm_lcd_device_unregister(struct device *dev,
-	struct lcd_device *ld);
+struct lcd_device *devm_lcd_device_register(struct device *dev,
+	const char *name, struct device *parent, void *devdata,
+	struct lcd_ops *ops);
+void lcd_device_unregister(struct lcd_device *ld);
+void devm_lcd_device_unregister(struct device *dev, struct lcd_device *ld);
+#else
+static inline struct lcd_device *lcd_device_register(const char *name,
+	struct device *parent, void *devdata, struct lcd_ops *ops)
+{
+	return ERR_PTR(-ENOSYS);
+}
+
+static inline struct lcd_device *devm_lcd_device_register(struct device *dev,
+	const char *name, struct device *parent, void *devdata,
+	struct lcd_ops *ops)
+{
+	return ERR_PTR(-ENOSYS);
+}
+
+static inline void lcd_device_unregister(struct lcd_device *ld)
+{
+}
+
+static inline void devm_lcd_device_unregister(struct device *dev,
+	struct lcd_device *ld)
+{
+}
+#endif
 
 #define to_lcd_device(obj) container_of(obj, struct lcd_device, dev)