[PATCH] Consolidate the backlight into the gxfb_dcon driver

Jordan Crouse jordan.crouse at amd.unroutablecom
Sat Nov 11 19:01:52 EST 2006


Commit:     ce3ed73c4c28ce2e0b1c8414e7dfe9ce0e1ecbaf
Parent:     2b920acee7f5fb52553911e19ec85fbf26741ae2
commit ce3ed73c4c28ce2e0b1c8414e7dfe9ce0e1ecbaf
Author:     Jordan Crouse <jordan.crouse at amd.com>
AuthorDate: Sat Nov 11 19:05:39 2006 -0500
Commit:     Andres Salomon <dilinger at debian.org>
CommitDate: Sat Nov 11 19:05:39 2006 -0500

    [PATCH] Consolidate the backlight into the gxfb_dcon driver
    
    There is no need to have a seperate file with the dcon backlight code -
    we can put it all together and save ourselves some external symbols
    
    Signed-off-by: Andres Salomon <dilinger at debian.org>
    Signed-off-by: Jordan Crouse <jordan.crouse at amd.com>
---
 drivers/video/backlight/Kconfig   |    8 ---
 drivers/video/backlight/Makefile  |    1 
 drivers/video/backlight/dcon_bl.c |   88 -------------------------------------
 drivers/video/geode/gxfb_dcon.c   |   78 ++++++++++++++++++++-------------
 drivers/video/geode/gxfb_dcon.h   |    4 --
 5 files changed, 47 insertions(+), 132 deletions(-)

diff --git a/drivers/video/backlight/Kconfig b/drivers/video/backlight/Kconfig
index 7872f1f..8cb7443 100644
--- a/drivers/video/backlight/Kconfig
+++ b/drivers/video/backlight/Kconfig
@@ -65,11 +65,3 @@ config BACKLIGHT_HP680
 	help
 	  If you have a HP Jornada 680, say y to enable the
 	  backlight driver.
-
-config BACKLIGHT_DCON
-	tristate "OLPC DCON Backlight Driver"
-	depends on BACKLIGHT_DEVICE && FB_GEODE_GX_DCON
-	default y
-	help
-	  Enable the backlight driver for the OLPC Display CONtroller
-
diff --git a/drivers/video/backlight/Makefile b/drivers/video/backlight/Makefile
index c39f221..65e5553 100644
--- a/drivers/video/backlight/Makefile
+++ b/drivers/video/backlight/Makefile
@@ -5,4 +5,3 @@ obj-$(CONFIG_BACKLIGHT_CLASS_DEVICE) += 
 obj-$(CONFIG_BACKLIGHT_CORGI)	+= corgi_bl.o
 obj-$(CONFIG_BACKLIGHT_HP680)	+= hp680_bl.o
 obj-$(CONFIG_BACKLIGHT_LOCOMO)	+= locomolcd.o
-obj-$(CONFIG_BACKLIGHT_DCON) += dcon_bl.o
diff --git a/drivers/video/backlight/dcon_bl.c b/drivers/video/backlight/dcon_bl.c
deleted file mode 100644
index 78403da..0000000
--- a/drivers/video/backlight/dcon_bl.c
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Copyright (C) 2006 Advanced Micro Devices, Inc.
- *
- * This program is free software.  You can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation: either version 1 or
- * (at your option) any later version.
- */
-
-#include <linux/module.h>
-#include <linux/kernel.h>
-#include <linux/err.h>
-#include <linux/fb.h>
-#include <linux/platform_device.h>
-#include <linux/backlight.h>
-#include "../geode/gxfb_dcon.h"
-
-static struct backlight_device *dconbl_dev;
-
-static int dconbl_set(struct backlight_device *dev) {
-
-	int level = dev->props->brightness;
-	int power = dev->props->power;
-
-	/* If we are blanking, then just turn off the backlight all together */
-
-	if (power != FB_BLANK_UNBLANK)
-	  level = 0;
-
-	dcon_set_backlight(level);
-	return 0;
-}
-
-static int dconbl_get(struct backlight_device *dev) {
-	return dcon_get_backlight();
-}
-
-static struct backlight_properties dcon_data = {
-	.owner = THIS_MODULE,
-	.get_brightness = dconbl_get,
-	.update_status = dconbl_set,
-	.max_brightness = 15
-};
-
-static int dconbl_probe(struct platform_device *dev) 
-{
-	dconbl_dev = backlight_device_register("dcon-bl", NULL, &dcon_data);
-	
-	if (IS_ERR(dconbl_dev))
-		return PTR_ERR(dconbl_dev);
-	
-	dcon_data.brightness = dcon_get_backlight();
-	return 0;
-}
-
-static int dconbl_remove(struct platform_device *dev) 
-{
-	backlight_device_unregister(dconbl_dev);
-	return 0;
-}
-
-/* Note:  We dont define suspend and resume functions here - 
-   we cannot assume the user wanted the backlight to be changed
-   while in the suspended mode
-*/
-
-static struct platform_driver dconbl_driver = {
-	.probe = dconbl_probe,
-	.remove = dconbl_remove,
-	.driver = { 
-		.name = "dcon-bl"
-	}
-};
-
-static int __init dconbl_init(void) {
-	return platform_driver_register(&dconbl_driver);
-}
-
-static void __exit dconbl_exit(void) {
-	platform_driver_unregister(&dconbl_driver);
-}
-
-module_init(dconbl_init);
-module_exit(dconbl_exit);
-
-MODULE_AUTHOR("Advanced Micro Devices, Inc.");
-MODULE_DESCRIPTION("OLPC DCON backlight Driver");
-MODULE_LICENSE("GPL");
diff --git a/drivers/video/geode/gxfb_dcon.c b/drivers/video/geode/gxfb_dcon.c
index fb32dcb..ae0e287 100644
--- a/drivers/video/geode/gxfb_dcon.c
+++ b/drivers/video/geode/gxfb_dcon.c
@@ -12,7 +12,6 @@
 
 #include <linux/kernel.h>
 #include <linux/fb.h>
-#include "geodefb.h"
 #include <linux/i2c.h>
 #include <linux/platform_device.h>
 #include <linux/i2c-id.h>
@@ -20,12 +19,14 @@ #include <linux/pci.h>
 #include <linux/pci_ids.h>
 #include <linux/interrupt.h>
 #include <linux/delay.h>
+#include <linux/backlight.h>
 #include <linux/device.h>
 #include <asm/uaccess.h>
 #include <linux/ctype.h>
 #include <linux/reboot.h>
 #include <asm/tsc.h>
 
+#include "geodefb.h"
 #include "gxfb_dcon.h"
 
 /* Module definitions */
@@ -57,7 +58,9 @@ static struct i2c_client *dcon_client;
 
 /* Platform devices */
 static struct platform_device *dcon_device;
-static struct platform_device *dconbl_device;
+
+/* Backlight device */
+static struct backlight_device *dcon_bl_dev;
 
 /* Base address of the GPIO registers */
 static unsigned long gpio_base;
@@ -94,18 +97,17 @@ I2C_CLIENT_INSMOD;
 #define dcon_write(reg,val) i2c_smbus_write_word_data(dcon_client,reg,val)
 #define dcon_read(reg) i2c_smbus_read_word_data(dcon_client,reg)
 
-
-/* ===== API functions - these are called by a variety of users ==== */
-
 /* The current backlight value - this saves us some smbus traffic */
 static int gxfb_bl_val = -1;
 
+/* ===== API functions - these are called by a variety of users ==== */
+
 /* Backlight notes - turning off the backlight enable bit in the DCON
  * doesn't save us any power over just pushing the BL to zero, so we
  * don't use that bit in this code.
  */
 
-int dcon_get_backlight(void)
+static int dcon_get_backlight(void)
 {
 	if (dcon_client == NULL)
 		return 0;
@@ -116,7 +118,7 @@ int dcon_get_backlight(void)
 	return gxfb_bl_val;
 }
 
-void dcon_set_backlight(int level)
+static void dcon_set_backlight(int level)
 {
 	if (dcon_client == NULL)
 		return;
@@ -152,20 +154,17 @@ static int dcon_set_output(int arg)
 	return 0;
 }
 
-EXPORT_SYMBOL(dcon_get_backlight);
-EXPORT_SYMBOL(dcon_set_backlight);
-
 /* Set the source of the display (CPU or DCON) */
 
 static int dcon_set_source(int arg)
 {
+	DECLARE_WAITQUEUE(wait, current);
+
 	if (dcon_source == arg)
 		return 0;
 
 	dcon_source = arg;
 
-	DECLARE_WAITQUEUE(wait, current);
-
 	dcon_switched = 0;
 
 	if (arg == DCON_SOURCE_CPU) {
@@ -322,6 +321,22 @@ static int gxfb_dcon_ioctl(struct fb_inf
 	return ret;
 }
 
+static int dconbl_set(struct backlight_device *dev) {
+
+	int level = dev->props->brightness;
+	int power = dev->props->power;
+
+	if (power != FB_BLANK_UNBLANK)
+	  level = 0;
+
+	dcon_set_backlight(level);
+	return 0;
+}
+
+static int dconbl_get(struct backlight_device *dev) {
+	return dcon_get_backlight();
+}
+
 static ssize_t dcon_mode_show(struct device *dev,
 	struct device_attribute *attr, char *buf)
 {
@@ -421,6 +436,13 @@ static struct device_attribute dcon_devi
 	__ATTR(output, 0644, dcon_output_show, dcon_output_store),
 };
 
+static struct backlight_properties dcon_data = {
+	.owner = THIS_MODULE,
+	.get_brightness = dconbl_get,
+	.update_status = dconbl_set,
+	.max_brightness = 15
+};
+
 static int dcon_probe(struct i2c_adapter *adap, int addr, int kind)
 {
 	struct i2c_client *client;
@@ -514,31 +536,25 @@ static int dcon_probe(struct i2c_adapter
 	for(i = 0; i < ARRAY_SIZE(dcon_device_files); i++)
 		device_create_file(&dcon_device->dev, &dcon_device_files[i]);
 
-	/* Add the DCON backlight device (for use by the backlight engine) */
+	/* Add the backlight device for the DCON */
+
+	dcon_client = client;
+	gxfb_ioctl_func = gxfb_dcon_ioctl;
 
-	dconbl_device = platform_device_alloc("dcon-bl", -1);
+	dcon_data.brightness = dcon_get_backlight();
+	dcon_bl_dev = backlight_device_register("dcon-bl", NULL, &dcon_data);
 
-	if (dconbl_device == NULL) {
-		printk(KERN_ERR "dcon:  Unable to create the DCON backlight device\n");
-		rc = -ENOMEM;
-		goto edev;
-	}
+	/* FIXME:  Should this be a fatal error? */
 
-	if ((rc = platform_device_add(dconbl_device))) {
-		printk(KERN_ERR "dcon:  Unable to add the DCON backlight device\n");
-		goto ebldev;
+	if (IS_ERR(dcon_bl_dev)) {
+		printk(KERN_INFO "Could not register the backlight device for the DCON (%ld)\n", PTR_ERR(dcon_bl_dev));
+		dcon_bl_dev = NULL;
 	}
 
-	dcon_client = client;
-	gxfb_ioctl_func = gxfb_dcon_ioctl;
-
 	printk(KERN_INFO "gxfb-dcon: Discovered DCON version %x\n", ver & 0xFF);
 
 	return 0;
 
- ebldev:
-	platform_device_unregister(dconbl_device);
-	dconbl_device = NULL;
  edev:
 	platform_device_unregister(dcon_device);
 	dcon_device = NULL;
@@ -571,8 +587,8 @@ static int dcon_detach(struct i2c_client
 	if ((rc = i2c_detach_client(client)) == 0)
 		kfree(i2c_get_clientdata(client));
 
-	if (dconbl_device != NULL)
-		platform_device_unregister(dconbl_device);
+	if (dcon_bl_dev != NULL)
+		backlight_device_unregister(dcon_bl_dev);
 
 	if (dcon_device != NULL)
 		platform_device_unregister(dcon_device);
@@ -590,7 +606,7 @@ static struct i2c_driver dcon_driver = {
 };
 
 
-static int dcon_interrupt(int irq, void *id, struct pt_regs *regs)
+static irqreturn_t dcon_interrupt(int irq, void *id)
 {
 	unsigned long gin = inl(gpio_base + GPIOx_READ_BACK);
 	int dconstat = (gin >> 5) & 3;
diff --git a/drivers/video/geode/gxfb_dcon.h b/drivers/video/geode/gxfb_dcon.h
index 522bd7a..835fd7a 100644
--- a/drivers/video/geode/gxfb_dcon.h
+++ b/drivers/video/geode/gxfb_dcon.h
@@ -72,8 +72,4 @@ #define DCON_SLEEPING           1
 /* Interrupt */
 #define DCON_IRQ                6
 
-
-void dcon_set_backlight(int);
-int dcon_get_backlight(void);
-
 #endif


More information about the Commits-kernel mailing list