aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/macintosh
diff options
context:
space:
mode:
authorPaul Mackerras <paulus@samba.org>2006-07-31 20:37:25 -0400
committerPaul Mackerras <paulus@samba.org>2006-07-31 20:37:25 -0400
commit57cad8084e0837e0f2c97da789ec9b3f36809be9 (patch)
treee9c790afb4286f78cb08d9664f58baa7e876fe55 /drivers/macintosh
parentcb18bd40030c879cd93fef02fd579f74dbab473d (diff)
parent49b1e3ea19b1c95c2f012b8331ffb3b169e4c042 (diff)
Merge branch 'merge'
Diffstat (limited to 'drivers/macintosh')
-rw-r--r--drivers/macintosh/Kconfig5
-rw-r--r--drivers/macintosh/adbhid.c14
-rw-r--r--drivers/macintosh/macio_asic.c2
-rw-r--r--drivers/macintosh/smu.c53
-rw-r--r--drivers/macintosh/via-pmu-backlight.c68
-rw-r--r--drivers/macintosh/via-pmu.c39
6 files changed, 114 insertions, 67 deletions
diff --git a/drivers/macintosh/Kconfig b/drivers/macintosh/Kconfig
index dc6003859e54..d5d649f5ccdb 100644
--- a/drivers/macintosh/Kconfig
+++ b/drivers/macintosh/Kconfig
@@ -109,7 +109,7 @@ config PMAC_SMU
109 109
110config PMAC_APM_EMU 110config PMAC_APM_EMU
111 tristate "APM emulation" 111 tristate "APM emulation"
112 depends on PPC_PMAC && PPC32 && PM 112 depends on PPC_PMAC && PPC32 && PM && ADB_PMU
113 113
114config PMAC_MEDIABAY 114config PMAC_MEDIABAY
115 bool "Support PowerBook hotswap media bay" 115 bool "Support PowerBook hotswap media bay"
@@ -122,7 +122,8 @@ config PMAC_MEDIABAY
122 122
123config PMAC_BACKLIGHT 123config PMAC_BACKLIGHT
124 bool "Backlight control for LCD screens" 124 bool "Backlight control for LCD screens"
125 depends on ADB_PMU && (BROKEN || !PPC64) 125 depends on ADB_PMU && FB = y && (BROKEN || !PPC64)
126 select FB_BACKLIGHT
126 help 127 help
127 Say Y here to enable Macintosh specific extensions of the generic 128 Say Y here to enable Macintosh specific extensions of the generic
128 backlight code. With this enabled, the brightness keys on older 129 backlight code. With this enabled, the brightness keys on older
diff --git a/drivers/macintosh/adbhid.c b/drivers/macintosh/adbhid.c
index 545be1ed6927..c69d23bb255e 100644
--- a/drivers/macintosh/adbhid.c
+++ b/drivers/macintosh/adbhid.c
@@ -45,14 +45,11 @@
45#include <linux/pmu.h> 45#include <linux/pmu.h>
46 46
47#include <asm/machdep.h> 47#include <asm/machdep.h>
48#include <asm/backlight.h>
48#ifdef CONFIG_PPC_PMAC 49#ifdef CONFIG_PPC_PMAC
49#include <asm/pmac_feature.h> 50#include <asm/pmac_feature.h>
50#endif 51#endif
51 52
52#ifdef CONFIG_PMAC_BACKLIGHT
53#include <asm/backlight.h>
54#endif
55
56MODULE_AUTHOR("Franz Sirl <Franz.Sirl-kernel@lauterbach.com>"); 53MODULE_AUTHOR("Franz Sirl <Franz.Sirl-kernel@lauterbach.com>");
57 54
58#define KEYB_KEYREG 0 /* register # for key up/down data */ 55#define KEYB_KEYREG 0 /* register # for key up/down data */
@@ -237,11 +234,6 @@ static struct adb_ids keyboard_ids;
237static struct adb_ids mouse_ids; 234static struct adb_ids mouse_ids;
238static struct adb_ids buttons_ids; 235static struct adb_ids buttons_ids;
239 236
240#ifdef CONFIG_PMAC_BACKLIGHT
241/* Exported to via-pmu.c */
242int disable_kernel_backlight = 0;
243#endif /* CONFIG_PMAC_BACKLIGHT */
244
245/* Kind of keyboard, see Apple technote 1152 */ 237/* Kind of keyboard, see Apple technote 1152 */
246#define ADB_KEYBOARD_UNKNOWN 0 238#define ADB_KEYBOARD_UNKNOWN 0
247#define ADB_KEYBOARD_ANSI 0x0100 239#define ADB_KEYBOARD_ANSI 0x0100
@@ -527,7 +519,7 @@ adbhid_buttons_input(unsigned char *data, int nb, struct pt_regs *regs, int auto
527 519
528 case 0xa: /* brightness decrease */ 520 case 0xa: /* brightness decrease */
529#ifdef CONFIG_PMAC_BACKLIGHT 521#ifdef CONFIG_PMAC_BACKLIGHT
530 if (!disable_kernel_backlight && down) 522 if (down)
531 pmac_backlight_key_down(); 523 pmac_backlight_key_down();
532#endif 524#endif
533 input_report_key(adbhid[id]->input, KEY_BRIGHTNESSDOWN, down); 525 input_report_key(adbhid[id]->input, KEY_BRIGHTNESSDOWN, down);
@@ -535,7 +527,7 @@ adbhid_buttons_input(unsigned char *data, int nb, struct pt_regs *regs, int auto
535 527
536 case 0x9: /* brightness increase */ 528 case 0x9: /* brightness increase */
537#ifdef CONFIG_PMAC_BACKLIGHT 529#ifdef CONFIG_PMAC_BACKLIGHT
538 if (!disable_kernel_backlight && down) 530 if (down)
539 pmac_backlight_key_up(); 531 pmac_backlight_key_up();
540#endif 532#endif
541 input_report_key(adbhid[id]->input, KEY_BRIGHTNESSUP, down); 533 input_report_key(adbhid[id]->input, KEY_BRIGHTNESSUP, down);
diff --git a/drivers/macintosh/macio_asic.c b/drivers/macintosh/macio_asic.c
index 7817cf286d0c..d56216067549 100644
--- a/drivers/macintosh/macio_asic.c
+++ b/drivers/macintosh/macio_asic.c
@@ -332,7 +332,7 @@ static void macio_create_fixup_irq(struct macio_dev *dev, int index,
332{ 332{
333 unsigned int irq; 333 unsigned int irq;
334 334
335 irq = irq_create_mapping(NULL, line, 0); 335 irq = irq_create_mapping(NULL, line);
336 if (irq != NO_IRQ) { 336 if (irq != NO_IRQ) {
337 dev->interrupt[index].start = irq; 337 dev->interrupt[index].start = irq;
338 dev->interrupt[index].flags = IORESOURCE_IRQ; 338 dev->interrupt[index].flags = IORESOURCE_IRQ;
diff --git a/drivers/macintosh/smu.c b/drivers/macintosh/smu.c
index 6f358600536e..090e40fc5013 100644
--- a/drivers/macintosh/smu.c
+++ b/drivers/macintosh/smu.c
@@ -75,9 +75,11 @@ struct smu_device {
75 struct of_device *of_dev; 75 struct of_device *of_dev;
76 int doorbell; /* doorbell gpio */ 76 int doorbell; /* doorbell gpio */
77 u32 __iomem *db_buf; /* doorbell buffer */ 77 u32 __iomem *db_buf; /* doorbell buffer */
78 int db_irq; 78 struct device_node *db_node;
79 unsigned int db_irq;
79 int msg; 80 int msg;
80 int msg_irq; 81 struct device_node *msg_node;
82 unsigned int msg_irq;
81 struct smu_cmd_buf *cmd_buf; /* command buffer virtual */ 83 struct smu_cmd_buf *cmd_buf; /* command buffer virtual */
82 u32 cmd_buf_abs; /* command buffer absolute */ 84 u32 cmd_buf_abs; /* command buffer absolute */
83 struct list_head cmd_list; 85 struct list_head cmd_list;
@@ -93,6 +95,7 @@ struct smu_device {
93 */ 95 */
94static struct smu_device *smu; 96static struct smu_device *smu;
95static DEFINE_MUTEX(smu_part_access); 97static DEFINE_MUTEX(smu_part_access);
98static int smu_irq_inited;
96 99
97static void smu_i2c_retry(unsigned long data); 100static void smu_i2c_retry(unsigned long data);
98 101
@@ -257,6 +260,10 @@ int smu_queue_cmd(struct smu_cmd *cmd)
257 smu_start_cmd(); 260 smu_start_cmd();
258 spin_unlock_irqrestore(&smu->lock, flags); 261 spin_unlock_irqrestore(&smu->lock, flags);
259 262
263 /* Workaround for early calls when irq isn't available */
264 if (!smu_irq_inited || smu->db_irq == NO_IRQ)
265 smu_spinwait_cmd(cmd);
266
260 return 0; 267 return 0;
261} 268}
262EXPORT_SYMBOL(smu_queue_cmd); 269EXPORT_SYMBOL(smu_queue_cmd);
@@ -478,14 +485,15 @@ int __init smu_init (void)
478 smu->cmd_buf_abs = (u32)smu_cmdbuf_abs; 485 smu->cmd_buf_abs = (u32)smu_cmdbuf_abs;
479 smu->cmd_buf = (struct smu_cmd_buf *)abs_to_virt(smu_cmdbuf_abs); 486 smu->cmd_buf = (struct smu_cmd_buf *)abs_to_virt(smu_cmdbuf_abs);
480 487
481 np = of_find_node_by_name(NULL, "smu-doorbell"); 488 smu->db_node = of_find_node_by_name(NULL, "smu-doorbell");
482 if (np == NULL) { 489 if (smu->db_node == NULL) {
483 printk(KERN_ERR "SMU: Can't find doorbell GPIO !\n"); 490 printk(KERN_ERR "SMU: Can't find doorbell GPIO !\n");
484 goto fail; 491 goto fail;
485 } 492 }
486 data = get_property(np, "reg", NULL); 493 data = get_property(smu->db_node, "reg", NULL);
487 if (data == NULL) { 494 if (data == NULL) {
488 of_node_put(np); 495 of_node_put(smu->db_node);
496 smu->db_node = NULL;
489 printk(KERN_ERR "SMU: Can't find doorbell GPIO address !\n"); 497 printk(KERN_ERR "SMU: Can't find doorbell GPIO address !\n");
490 goto fail; 498 goto fail;
491 } 499 }
@@ -497,25 +505,21 @@ int __init smu_init (void)
497 smu->doorbell = *data; 505 smu->doorbell = *data;
498 if (smu->doorbell < 0x50) 506 if (smu->doorbell < 0x50)
499 smu->doorbell += 0x50; 507 smu->doorbell += 0x50;
500 smu->db_irq = irq_of_parse_and_map(np, 0);
501
502 of_node_put(np);
503 508
504 /* Now look for the smu-interrupt GPIO */ 509 /* Now look for the smu-interrupt GPIO */
505 do { 510 do {
506 np = of_find_node_by_name(NULL, "smu-interrupt"); 511 smu->msg_node = of_find_node_by_name(NULL, "smu-interrupt");
507 if (np == NULL) 512 if (smu->msg_node == NULL)
508 break; 513 break;
509 data = get_property(np, "reg", NULL); 514 data = get_property(smu->msg_node, "reg", NULL);
510 if (data == NULL) { 515 if (data == NULL) {
511 of_node_put(np); 516 of_node_put(smu->msg_node);
517 smu->msg_node = NULL;
512 break; 518 break;
513 } 519 }
514 smu->msg = *data; 520 smu->msg = *data;
515 if (smu->msg < 0x50) 521 if (smu->msg < 0x50)
516 smu->msg += 0x50; 522 smu->msg += 0x50;
517 smu->msg_irq = irq_of_parse_and_map(np, 0);
518 of_node_put(np);
519 } while(0); 523 } while(0);
520 524
521 /* Doorbell buffer is currently hard-coded, I didn't find a proper 525 /* Doorbell buffer is currently hard-coded, I didn't find a proper
@@ -547,6 +551,19 @@ static int smu_late_init(void)
547 smu->i2c_timer.function = smu_i2c_retry; 551 smu->i2c_timer.function = smu_i2c_retry;
548 smu->i2c_timer.data = (unsigned long)smu; 552 smu->i2c_timer.data = (unsigned long)smu;
549 553
554 if (smu->db_node) {
555 smu->db_irq = irq_of_parse_and_map(smu->db_node, 0);
556 if (smu->db_irq == NO_IRQ)
557 printk(KERN_ERR "smu: failed to map irq for node %s\n",
558 smu->db_node->full_name);
559 }
560 if (smu->msg_node) {
561 smu->msg_irq = irq_of_parse_and_map(smu->msg_node, 0);
562 if (smu->msg_irq == NO_IRQ)
563 printk(KERN_ERR "smu: failed to map irq for node %s\n",
564 smu->msg_node->full_name);
565 }
566
550 /* 567 /*
551 * Try to request the interrupts 568 * Try to request the interrupts
552 */ 569 */
@@ -571,6 +588,7 @@ static int smu_late_init(void)
571 } 588 }
572 } 589 }
573 590
591 smu_irq_inited = 1;
574 return 0; 592 return 0;
575} 593}
576/* This has to be before arch_initcall as the low i2c stuff relies on the 594/* This has to be before arch_initcall as the low i2c stuff relies on the
@@ -742,6 +760,11 @@ static void smu_i2c_low_completion(struct smu_cmd *scmd, void *misc)
742 if (fail && --cmd->retries > 0) { 760 if (fail && --cmd->retries > 0) {
743 DPRINTK("SMU: i2c failure, starting timer...\n"); 761 DPRINTK("SMU: i2c failure, starting timer...\n");
744 BUG_ON(cmd != smu->cmd_i2c_cur); 762 BUG_ON(cmd != smu->cmd_i2c_cur);
763 if (!smu_irq_inited) {
764 mdelay(5);
765 smu_i2c_retry(0);
766 return;
767 }
745 mod_timer(&smu->i2c_timer, jiffies + msecs_to_jiffies(5)); 768 mod_timer(&smu->i2c_timer, jiffies + msecs_to_jiffies(5));
746 return; 769 return;
747 } 770 }
diff --git a/drivers/macintosh/via-pmu-backlight.c b/drivers/macintosh/via-pmu-backlight.c
index b42d05f2aaff..d3f8d75bcbb4 100644
--- a/drivers/macintosh/via-pmu-backlight.c
+++ b/drivers/macintosh/via-pmu-backlight.c
@@ -15,8 +15,9 @@
15 15
16#define MAX_PMU_LEVEL 0xFF 16#define MAX_PMU_LEVEL 0xFF
17 17
18static struct device_node *vias;
19static struct backlight_properties pmu_backlight_data; 18static struct backlight_properties pmu_backlight_data;
19static spinlock_t pmu_backlight_lock;
20static int sleeping;
20 21
21static int pmu_backlight_get_level_brightness(struct fb_info *info, 22static int pmu_backlight_get_level_brightness(struct fb_info *info,
22 int level) 23 int level)
@@ -40,23 +41,36 @@ static int pmu_backlight_update_status(struct backlight_device *bd)
40{ 41{
41 struct fb_info *info = class_get_devdata(&bd->class_dev); 42 struct fb_info *info = class_get_devdata(&bd->class_dev);
42 struct adb_request req; 43 struct adb_request req;
43 int pmulevel, level = bd->props->brightness; 44 unsigned long flags;
45 int level = bd->props->brightness;
44 46
45 if (vias == NULL) 47 spin_lock_irqsave(&pmu_backlight_lock, flags);
46 return -ENODEV; 48
49 /* Don't update brightness when sleeping */
50 if (sleeping)
51 goto out;
47 52
48 if (bd->props->power != FB_BLANK_UNBLANK || 53 if (bd->props->power != FB_BLANK_UNBLANK ||
49 bd->props->fb_blank != FB_BLANK_UNBLANK) 54 bd->props->fb_blank != FB_BLANK_UNBLANK)
50 level = 0; 55 level = 0;
51 56
52 pmulevel = pmu_backlight_get_level_brightness(info, level); 57 if (level > 0) {
58 int pmulevel = pmu_backlight_get_level_brightness(info, level);
53 59
54 pmu_request(&req, NULL, 2, PMU_BACKLIGHT_BRIGHT, pmulevel); 60 pmu_request(&req, NULL, 2, PMU_BACKLIGHT_BRIGHT, pmulevel);
55 pmu_wait_complete(&req); 61 pmu_wait_complete(&req);
56 62
57 pmu_request(&req, NULL, 2, PMU_POWER_CTRL, 63 pmu_request(&req, NULL, 2, PMU_POWER_CTRL,
58 PMU_POW_BACKLIGHT | (level > 0 ? PMU_POW_ON : PMU_POW_OFF)); 64 PMU_POW_BACKLIGHT | PMU_POW_ON);
59 pmu_wait_complete(&req); 65 pmu_wait_complete(&req);
66 } else {
67 pmu_request(&req, NULL, 2, PMU_POWER_CTRL,
68 PMU_POW_BACKLIGHT | PMU_POW_OFF);
69 pmu_wait_complete(&req);
70 }
71
72out:
73 spin_unlock_irqrestore(&pmu_backlight_lock, flags);
60 74
61 return 0; 75 return 0;
62} 76}
@@ -73,15 +87,39 @@ static struct backlight_properties pmu_backlight_data = {
73 .max_brightness = (FB_BACKLIGHT_LEVELS - 1), 87 .max_brightness = (FB_BACKLIGHT_LEVELS - 1),
74}; 88};
75 89
76void __init pmu_backlight_init(struct device_node *in_vias) 90#ifdef CONFIG_PM
91static int pmu_backlight_sleep_call(struct pmu_sleep_notifier *self, int when)
92{
93 unsigned long flags;
94
95 spin_lock_irqsave(&pmu_backlight_lock, flags);
96
97 switch (when) {
98 case PBOOK_SLEEP_REQUEST:
99 sleeping = 1;
100 break;
101 case PBOOK_WAKE:
102 sleeping = 0;
103 break;
104 }
105
106 spin_unlock_irqrestore(&pmu_backlight_lock, flags);
107
108 return PBOOK_SLEEP_OK;
109}
110
111static struct pmu_sleep_notifier pmu_backlight_sleep_notif = {
112 .notifier_call = pmu_backlight_sleep_call,
113};
114#endif
115
116void __init pmu_backlight_init()
77{ 117{
78 struct backlight_device *bd; 118 struct backlight_device *bd;
79 struct fb_info *info; 119 struct fb_info *info;
80 char name[10]; 120 char name[10];
81 int level, autosave; 121 int level, autosave;
82 122
83 vias = in_vias;
84
85 /* Special case for the old PowerBook since I can't test on it */ 123 /* Special case for the old PowerBook since I can't test on it */
86 autosave = 124 autosave =
87 machine_is_compatible("AAPL,3400/2400") || 125 machine_is_compatible("AAPL,3400/2400") ||
@@ -141,6 +179,10 @@ void __init pmu_backlight_init(struct device_node *in_vias)
141 pmac_backlight = bd; 179 pmac_backlight = bd;
142 mutex_unlock(&pmac_backlight_mutex); 180 mutex_unlock(&pmac_backlight_mutex);
143 181
182#ifdef CONFIG_PM
183 pmu_register_sleep_notifier(&pmu_backlight_sleep_notif);
184#endif
185
144 printk("pmubl: Backlight initialized (%s)\n", name); 186 printk("pmubl: Backlight initialized (%s)\n", name);
145 187
146 return; 188 return;
diff --git a/drivers/macintosh/via-pmu.c b/drivers/macintosh/via-pmu.c
index 80e88b4a1d07..0df500b9a66b 100644
--- a/drivers/macintosh/via-pmu.c
+++ b/drivers/macintosh/via-pmu.c
@@ -16,7 +16,6 @@
16 * a sleep or a freq. switch 16 * a sleep or a freq. switch
17 * - Move sleep code out of here to pmac_pm, merge into new 17 * - Move sleep code out of here to pmac_pm, merge into new
18 * common PM infrastructure 18 * common PM infrastructure
19 * - Move backlight code out as well
20 * - Save/Restore PCI space properly 19 * - Save/Restore PCI space properly
21 * 20 *
22 */ 21 */
@@ -60,9 +59,7 @@
60#include <asm/mmu_context.h> 59#include <asm/mmu_context.h>
61#include <asm/cputable.h> 60#include <asm/cputable.h>
62#include <asm/time.h> 61#include <asm/time.h>
63#ifdef CONFIG_PMAC_BACKLIGHT
64#include <asm/backlight.h> 62#include <asm/backlight.h>
65#endif
66 63
67#include "via-pmu-event.h" 64#include "via-pmu-event.h"
68 65
@@ -177,10 +174,6 @@ static int query_batt_timer = BATTERY_POLLING_COUNT;
177static struct adb_request batt_req; 174static struct adb_request batt_req;
178static struct proc_dir_entry *proc_pmu_batt[PMU_MAX_BATTERIES]; 175static struct proc_dir_entry *proc_pmu_batt[PMU_MAX_BATTERIES];
179 176
180#if defined(CONFIG_INPUT_ADBHID) && defined(CONFIG_PMAC_BACKLIGHT)
181extern int disable_kernel_backlight;
182#endif /* defined(CONFIG_INPUT_ADBHID) && defined(CONFIG_PMAC_BACKLIGHT) */
183
184int __fake_sleep; 177int __fake_sleep;
185int asleep; 178int asleep;
186BLOCKING_NOTIFIER_HEAD(sleep_notifier_list); 179BLOCKING_NOTIFIER_HEAD(sleep_notifier_list);
@@ -466,7 +459,7 @@ static int __init via_pmu_dev_init(void)
466 459
467#ifdef CONFIG_PMAC_BACKLIGHT 460#ifdef CONFIG_PMAC_BACKLIGHT
468 /* Initialize backlight */ 461 /* Initialize backlight */
469 pmu_backlight_init(vias); 462 pmu_backlight_init();
470#endif 463#endif
471 464
472#ifdef CONFIG_PPC32 465#ifdef CONFIG_PPC32
@@ -1403,11 +1396,8 @@ next:
1403 else if ((1 << pirq) & PMU_INT_SNDBRT) { 1396 else if ((1 << pirq) & PMU_INT_SNDBRT) {
1404#ifdef CONFIG_PMAC_BACKLIGHT 1397#ifdef CONFIG_PMAC_BACKLIGHT
1405 if (len == 3) 1398 if (len == 3)
1406#ifdef CONFIG_INPUT_ADBHID 1399 pmac_backlight_set_legacy_brightness_pmu(data[1] >> 4);
1407 if (!disable_kernel_backlight) 1400#endif
1408#endif /* CONFIG_INPUT_ADBHID */
1409 pmac_backlight_set_legacy_brightness(data[1] >> 4);
1410#endif /* CONFIG_PMAC_BACKLIGHT */
1411 } 1401 }
1412 /* Tick interrupt */ 1402 /* Tick interrupt */
1413 else if ((1 << pirq) & PMU_INT_TICK) { 1403 else if ((1 << pirq) & PMU_INT_TICK) {
@@ -2414,7 +2404,7 @@ struct pmu_private {
2414 spinlock_t lock; 2404 spinlock_t lock;
2415#if defined(CONFIG_INPUT_ADBHID) && defined(CONFIG_PMAC_BACKLIGHT) 2405#if defined(CONFIG_INPUT_ADBHID) && defined(CONFIG_PMAC_BACKLIGHT)
2416 int backlight_locker; 2406 int backlight_locker;
2417#endif /* defined(CONFIG_INPUT_ADBHID) && defined(CONFIG_PMAC_BACKLIGHT) */ 2407#endif
2418}; 2408};
2419 2409
2420static LIST_HEAD(all_pmu_pvt); 2410static LIST_HEAD(all_pmu_pvt);
@@ -2464,7 +2454,7 @@ pmu_open(struct inode *inode, struct file *file)
2464 spin_lock_irqsave(&all_pvt_lock, flags); 2454 spin_lock_irqsave(&all_pvt_lock, flags);
2465#if defined(CONFIG_INPUT_ADBHID) && defined(CONFIG_PMAC_BACKLIGHT) 2455#if defined(CONFIG_INPUT_ADBHID) && defined(CONFIG_PMAC_BACKLIGHT)
2466 pp->backlight_locker = 0; 2456 pp->backlight_locker = 0;
2467#endif /* defined(CONFIG_INPUT_ADBHID) && defined(CONFIG_PMAC_BACKLIGHT) */ 2457#endif
2468 list_add(&pp->list, &all_pmu_pvt); 2458 list_add(&pp->list, &all_pmu_pvt);
2469 spin_unlock_irqrestore(&all_pvt_lock, flags); 2459 spin_unlock_irqrestore(&all_pvt_lock, flags);
2470 file->private_data = pp; 2460 file->private_data = pp;
@@ -2559,13 +2549,12 @@ pmu_release(struct inode *inode, struct file *file)
2559 spin_lock_irqsave(&all_pvt_lock, flags); 2549 spin_lock_irqsave(&all_pvt_lock, flags);
2560 list_del(&pp->list); 2550 list_del(&pp->list);
2561 spin_unlock_irqrestore(&all_pvt_lock, flags); 2551 spin_unlock_irqrestore(&all_pvt_lock, flags);
2552
2562#if defined(CONFIG_INPUT_ADBHID) && defined(CONFIG_PMAC_BACKLIGHT) 2553#if defined(CONFIG_INPUT_ADBHID) && defined(CONFIG_PMAC_BACKLIGHT)
2563 if (pp->backlight_locker) { 2554 if (pp->backlight_locker)
2564 spin_lock_irqsave(&pmu_lock, flags); 2555 pmac_backlight_enable();
2565 disable_kernel_backlight--; 2556#endif
2566 spin_unlock_irqrestore(&pmu_lock, flags); 2557
2567 }
2568#endif /* defined(CONFIG_INPUT_ADBHID) && defined(CONFIG_PMAC_BACKLIGHT) */
2569 kfree(pp); 2558 kfree(pp);
2570 } 2559 }
2571 unlock_kernel(); 2560 unlock_kernel();
@@ -2642,18 +2631,18 @@ pmu_ioctl(struct inode * inode, struct file *filp,
2642#ifdef CONFIG_INPUT_ADBHID 2631#ifdef CONFIG_INPUT_ADBHID
2643 case PMU_IOC_GRAB_BACKLIGHT: { 2632 case PMU_IOC_GRAB_BACKLIGHT: {
2644 struct pmu_private *pp = filp->private_data; 2633 struct pmu_private *pp = filp->private_data;
2645 unsigned long flags;
2646 2634
2647 if (pp->backlight_locker) 2635 if (pp->backlight_locker)
2648 return 0; 2636 return 0;
2637
2649 pp->backlight_locker = 1; 2638 pp->backlight_locker = 1;
2650 spin_lock_irqsave(&pmu_lock, flags); 2639 pmac_backlight_disable();
2651 disable_kernel_backlight++; 2640
2652 spin_unlock_irqrestore(&pmu_lock, flags);
2653 return 0; 2641 return 0;
2654 } 2642 }
2655#endif /* CONFIG_INPUT_ADBHID */ 2643#endif /* CONFIG_INPUT_ADBHID */
2656#endif /* CONFIG_PMAC_BACKLIGHT_LEGACY */ 2644#endif /* CONFIG_PMAC_BACKLIGHT_LEGACY */
2645
2657 case PMU_IOC_GET_MODEL: 2646 case PMU_IOC_GET_MODEL:
2658 return put_user(pmu_kind, argp); 2647 return put_user(pmu_kind, argp);
2659 case PMU_IOC_HAS_ADB: 2648 case PMU_IOC_HAS_ADB: