Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[PATCH] backlight: corgi_bl: Generalise to support other Sharp SL hardware

Generalise the Corgi backlight driver by moving the default intensity and
limit mask settings into the platform specific data structure. This enables
the driver to support other Zaurus hardware, specifically the SL-6000x (Tosa)
model.

Also change the spinlock to a mutex (the spinlock is overkill).

Signed-off-by: Richard Purdie <rpurdie@rpsys.net>
Signed-off-by: Antonino Daplas <adaplas@pol.net>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>

authored by

Richard Purdie and committed by
Linus Torvalds
2c0f5fb0 5f27a27b

+21 -20
+2
arch/arm/mach-pxa/corgi.c
··· 141 141 */ 142 142 static struct corgibl_machinfo corgi_bl_machinfo = { 143 143 .max_intensity = 0x2f, 144 + .default_intensity = 0x1f, 145 + .limit_mask = 0x0b, 144 146 .set_bl_intensity = corgi_bl_set_intensity, 145 147 }; 146 148
+2
arch/arm/mach-pxa/spitz.c
··· 220 220 * Spitz Backlight Device 221 221 */ 222 222 static struct corgibl_machinfo spitz_bl_machinfo = { 223 + .default_intensity = 0x1f, 224 + .limit_mask = 0x0b, 223 225 .max_intensity = 0x2f, 224 226 }; 225 227
+2 -2
drivers/video/backlight/Kconfig
··· 43 43 default y 44 44 45 45 config BACKLIGHT_CORGI 46 - tristate "Sharp Corgi Backlight Driver (SL-C7xx Series)" 46 + tristate "Sharp Corgi Backlight Driver (SL Series)" 47 47 depends on BACKLIGHT_DEVICE && PXA_SHARPSL 48 48 default y 49 49 help 50 - If you have a Sharp Zaurus SL-C7xx, say y to enable the 50 + If you have a Sharp Zaurus SL-C7xx, SL-Cxx00 or SL-6000x say y to enable the 51 51 backlight driver. 52 52 53 53 config BACKLIGHT_HP680
+13 -18
drivers/video/backlight/corgi_bl.c
··· 1 1 /* 2 - * Backlight Driver for Sharp Corgi 2 + * Backlight Driver for Sharp Zaurus Handhelds (various models) 3 3 * 4 - * Copyright (c) 2004-2005 Richard Purdie 4 + * Copyright (c) 2004-2006 Richard Purdie 5 5 * 6 6 * Based on Sharp's 2.4 Backlight Driver 7 7 * ··· 15 15 #include <linux/kernel.h> 16 16 #include <linux/init.h> 17 17 #include <linux/platform_device.h> 18 - #include <linux/spinlock.h> 18 + #include <linux/mutex.h> 19 19 #include <linux/fb.h> 20 20 #include <linux/backlight.h> 21 - 22 21 #include <asm/arch/sharpsl.h> 23 22 #include <asm/hardware/sharpsl_pm.h> 24 23 25 - #define CORGI_DEFAULT_INTENSITY 0x1f 26 - #define CORGI_LIMIT_MASK 0x0b 27 - 28 24 static int corgibl_intensity; 29 - static void (*corgibl_mach_set_intensity)(int intensity); 30 - static spinlock_t bl_lock = SPIN_LOCK_UNLOCKED; 25 + static DEFINE_MUTEX(bl_mutex); 31 26 static struct backlight_properties corgibl_data; 32 27 static struct backlight_device *corgi_backlight_device; 28 + static struct corgibl_machinfo *bl_machinfo; 33 29 34 30 static unsigned long corgibl_flags; 35 31 #define CORGIBL_SUSPENDED 0x01 ··· 33 37 34 38 static int corgibl_send_intensity(struct backlight_device *bd) 35 39 { 36 - unsigned long flags; 37 40 void (*corgi_kick_batt)(void); 38 41 int intensity = bd->props->brightness; 39 42 ··· 43 48 if (corgibl_flags & CORGIBL_SUSPENDED) 44 49 intensity = 0; 45 50 if (corgibl_flags & CORGIBL_BATTLOW) 46 - intensity &= CORGI_LIMIT_MASK; 51 + intensity &= bl_machinfo->limit_mask; 47 52 48 - spin_lock_irqsave(&bl_lock, flags); 49 - 50 - corgibl_mach_set_intensity(intensity); 51 - 52 - spin_unlock_irqrestore(&bl_lock, flags); 53 + mutex_lock(&bl_mutex); 54 + bl_machinfo->set_bl_intensity(intensity); 55 + mutex_unlock(&bl_mutex); 53 56 54 57 corgibl_intensity = intensity; 55 58 ··· 115 122 { 116 123 struct corgibl_machinfo *machinfo = pdev->dev.platform_data; 117 124 125 + bl_machinfo = machinfo; 118 126 corgibl_data.max_brightness = machinfo->max_intensity; 119 - corgibl_mach_set_intensity = machinfo->set_bl_intensity; 127 + if (!machinfo->limit_mask) 128 + machinfo->limit_mask = -1; 120 129 121 130 corgi_backlight_device = backlight_device_register ("corgi-bl", 122 131 NULL, &corgibl_data); ··· 126 131 return PTR_ERR (corgi_backlight_device); 127 132 128 133 corgibl_data.power = FB_BLANK_UNBLANK; 129 - corgibl_data.brightness = CORGI_DEFAULT_INTENSITY; 134 + corgibl_data.brightness = machinfo->default_intensity; 130 135 corgibl_send_intensity(corgi_backlight_device); 131 136 132 137 printk("Corgi Backlight Driver Initialized.\n");
+2
include/asm-arm/arch-pxa/sharpsl.h
··· 27 27 */ 28 28 struct corgibl_machinfo { 29 29 int max_intensity; 30 + int default_intensity; 31 + int limit_mask; 30 32 void (*set_bl_intensity)(int intensity); 31 33 }; 32 34 extern void corgibl_limit_intensity(int limit);