From 140b932f8cb6cced10b96860651a198b1b89cbb9 Mon Sep 17 00:00:00 2001 From: Olaf Hering Date: Thu, 24 Apr 2008 23:16:00 +1000 Subject: [POWERPC] Create modalias file in sysfs for of_platform bus Create /sys/bus/of_platform/devices/*/modalias file to allow autoloading of modules. Modalias files are already present for many other bus types. This adds also a newline to the devspec files. Also create a devspec file for mac-io devices. They were created as a side effect. Use correct buffer size for mac-io modalias buffer. Tested on iBook1 and Efika. Signed-off-by: Olaf Hering Signed-off-by: Paul Mackerras --- drivers/macintosh/macio_sysfs.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'drivers/macintosh') diff --git a/drivers/macintosh/macio_sysfs.c b/drivers/macintosh/macio_sysfs.c index 112e5ef728f..9e9453b5842 100644 --- a/drivers/macintosh/macio_sysfs.c +++ b/drivers/macintosh/macio_sysfs.c @@ -44,7 +44,7 @@ static ssize_t modalias_show (struct device *dev, struct device_attribute *attr, struct of_device *ofdev = to_of_device(dev); int len; - len = of_device_get_modalias(ofdev, buf, PAGE_SIZE); + len = of_device_get_modalias(ofdev, buf, PAGE_SIZE - 2); buf[len] = '\n'; buf[len+1] = 0; @@ -52,6 +52,15 @@ static ssize_t modalias_show (struct device *dev, struct device_attribute *attr, return len+1; } +static ssize_t devspec_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct of_device *ofdev; + + ofdev = to_of_device(dev); + return sprintf(buf, "%s\n", ofdev->node->full_name); +} + macio_config_of_attr (name, "%s\n"); macio_config_of_attr (type, "%s\n"); @@ -60,5 +69,6 @@ struct device_attribute macio_dev_attrs[] = { __ATTR_RO(type), __ATTR_RO(compatible), __ATTR_RO(modalias), + __ATTR_RO(devspec), __ATTR_NULL }; -- cgit v1.2.3 From c1a8e39819bd6797ee2b82b88517268d39921b03 Mon Sep 17 00:00:00 2001 From: Bartlomiej Zolnierkiewicz Date: Sun, 15 Jun 2008 21:00:23 +0200 Subject: ide-pmac: bugfix for media-bay support rework Fix bug introduced by: commit 2dde7861afa23cd59db83515cb0b810b92b220aa Author: Bartlomiej Zolnierkiewicz Date: Fri Apr 18 00:46:23 2008 +0200 ide: rework PowerMac media-bay support (take 2) ... [ Yeah, I suck. ] bay->cd_index shouldn't be changed if IDE devices are not present or retry operations won't happen. Cc: Benjamin Herrenschmidt Signed-off-by: Bartlomiej Zolnierkiewicz --- drivers/macintosh/mediabay.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'drivers/macintosh') diff --git a/drivers/macintosh/mediabay.c b/drivers/macintosh/mediabay.c index 82add26cc66..c34bdf852e3 100644 --- a/drivers/macintosh/mediabay.c +++ b/drivers/macintosh/mediabay.c @@ -556,7 +556,8 @@ static void media_bay_step(int i) printk("mediabay %d, registering IDE...\n", i); pmu_suspend(); ide_port_scan(bay->cd_port); - bay->cd_index = bay->cd_port->index; + if (bay->cd_port->present) + bay->cd_index = bay->cd_port->index; pmu_resume(); } if (bay->cd_index == -1) { -- cgit v1.2.3 From 8b9dba2ce28f64246198704b23f133bed5429e62 Mon Sep 17 00:00:00 2001 From: Julia Lawall Date: Mon, 9 Jun 2008 22:20:42 +1000 Subject: [POWERPC] Add missing of_node_put in drivers/macintosh/smu.c of_node_put is needed before discarding a value received from of_find_node_by_type, eg in error handling code. The semantic patch that makes the change is as follows: (http://www.emn.fr/x-info/coccinelle/) // @@ struct device_node *n; struct device_node *n1; struct device_node *n2; statement S; identifier f1,f2; expression E1,E2; constant C; @@ n = of_find_node_by_type(...) ... if (!n) S ... when != of_node_put(n) when != n1 = f1(n,...) when != E1 = n when any when strict ( + of_node_put(n); return -C; | of_node_put(n); | n2 = f2(n,...) | E2 = n | return ...; ) // Signed-off-by: Julia Lawall Acked-by: Stephen Rothwell Signed-off-by: Paul Mackerras --- drivers/macintosh/smu.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'drivers/macintosh') diff --git a/drivers/macintosh/smu.c b/drivers/macintosh/smu.c index 77ad192962c..d86d57af282 100644 --- a/drivers/macintosh/smu.c +++ b/drivers/macintosh/smu.c @@ -483,12 +483,15 @@ int __init smu_init (void) if (smu_cmdbuf_abs == 0) { printk(KERN_ERR "SMU: Command buffer not allocated !\n"); + of_node_put(np); return -EINVAL; } smu = alloc_bootmem(sizeof(struct smu_device)); - if (smu == NULL) + if (smu == NULL) { + of_node_put(np); return -ENOMEM; + } memset(smu, 0, sizeof(*smu)); spin_lock_init(&smu->lock); -- cgit v1.2.3 From 958a65f205fdc5ce5461d79376073b89acc51b31 Mon Sep 17 00:00:00 2001 From: Julia Lawall Date: Mon, 9 Jun 2008 22:21:51 +1000 Subject: [POWERPC] Add missing of_node_put in drivers/macintosh/therm_adt746x.c of_node_put is needed before discarding a value received from of_find_node_by_name, eg in error handling code. The semantic patch that makes the change is as follows: (http://www.emn.fr/x-info/coccinelle/) // @@ struct device_node *n; struct device_node *n1; statement S; identifier f; expression E; constant C; @@ n = of_find_node_by_name(...) ... if (!n) S ... when != of_node_put(n) when != n1 = f(n,...) when != E = n when any when strict ( + of_node_put(n); return -C; | of_node_put(n); | n1 = f(n,...) | E = n | return ...; ) // Signed-off-by: Julia Lawall Acked-by: Stephen Rothwell Signed-off-by: Paul Mackerras --- drivers/macintosh/therm_adt746x.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'drivers/macintosh') diff --git a/drivers/macintosh/therm_adt746x.c b/drivers/macintosh/therm_adt746x.c index 54f4942a296..5366dc93fb3 100644 --- a/drivers/macintosh/therm_adt746x.c +++ b/drivers/macintosh/therm_adt746x.c @@ -562,18 +562,24 @@ thermostat_init(void) therm_type = ADT7460; else if (of_device_is_compatible(np, "adt7467")) therm_type = ADT7467; - else + else { + of_node_put(np); return -ENODEV; + } prop = of_get_property(np, "hwsensor-params-version", NULL); printk(KERN_INFO "adt746x: version %d (%ssupported)\n", *prop, (*prop == 1)?"":"un"); - if (*prop != 1) + if (*prop != 1) { + of_node_put(np); return -ENODEV; + } prop = of_get_property(np, "reg", NULL); - if (!prop) + if (!prop) { + of_node_put(np); return -ENODEV; + } /* look for bus either by path or using "reg" */ if (strstr(np->full_name, "/i2c-bus@") != NULL) { @@ -610,6 +616,7 @@ thermostat_init(void) if (of_dev == NULL) { printk(KERN_ERR "Can't register temperatures device !\n"); + of_node_put(np); return -ENODEV; } -- cgit v1.2.3 From 305c73687157d677bee6f2a5dbee438d844a028c Mon Sep 17 00:00:00 2001 From: Adrian Bunk Date: Wed, 11 Jun 2008 03:47:45 +1000 Subject: [POWERPC] Build fix for drivers/macintosh/mediabay.c This fixes the following build error with CONFIG_BLK_DEV_IDE_PMAC=n: <-- snip --> ... CC drivers/macintosh/mediabay.o /home/bunk/linux/kernel-2.6/git/linux-2.6/drivers/macintosh/mediabay.c: In function 'check_media_bay': /home/bunk/linux/kernel-2.6/git/linux-2.6/drivers/macintosh/mediabay.c:428: error: 'struct media_bay_info' has no member named 'cd_index' make[3]: *** [drivers/macintosh/mediabay.o] Error 1 <-- snip --> Reported-by: Adrian Bunk Signed-off-by: Adrian Bunk Signed-off-by: Paul Mackerras --- drivers/macintosh/mediabay.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/macintosh') diff --git a/drivers/macintosh/mediabay.c b/drivers/macintosh/mediabay.c index c34bdf852e3..818aba36854 100644 --- a/drivers/macintosh/mediabay.c +++ b/drivers/macintosh/mediabay.c @@ -84,7 +84,7 @@ struct media_bay_info { int cd_irq; int cd_retry; #endif -#if defined(CONFIG_BLK_DEV_IDE_PMAC) || defined(CONFIG_MAC_FLOPPY) +#if defined(CONFIG_BLK_DEV_IDE_PMAC) int cd_index; #endif }; @@ -417,6 +417,7 @@ static void poll_media_bay(struct media_bay_info* bay) } } +#ifdef CONFIG_BLK_DEV_IDE_PMAC int check_media_bay(struct device_node *which_bay, int what) { int i; @@ -432,7 +433,6 @@ int check_media_bay(struct device_node *which_bay, int what) } EXPORT_SYMBOL(check_media_bay); -#ifdef CONFIG_BLK_DEV_IDE_PMAC int check_media_bay_by_base(unsigned long base, int what) { int i; -- cgit v1.2.3 From 26ce4f0684ef4b96d0244ac58b89ec282d5b980c Mon Sep 17 00:00:00 2001 From: Jonathan Corbet Date: Fri, 16 May 2008 14:19:56 -0600 Subject: adb: BKL pushdown Put explicit lock_kernel() calls in adb_open(). The fact that adb_release() already has them suggests this is necessary. Signed-off-by: Jonathan Corbet --- drivers/macintosh/adb.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'drivers/macintosh') diff --git a/drivers/macintosh/adb.c b/drivers/macintosh/adb.c index dbaad39020a..40c70ba62bf 100644 --- a/drivers/macintosh/adb.c +++ b/drivers/macintosh/adb.c @@ -644,12 +644,18 @@ do_adb_query(struct adb_request *req) static int adb_open(struct inode *inode, struct file *file) { struct adbdev_state *state; + int ret = 0; - if (iminor(inode) > 0 || adb_controller == NULL) - return -ENXIO; + lock_kernel(); + if (iminor(inode) > 0 || adb_controller == NULL) { + ret = -ENXIO; + goto out; + } state = kmalloc(sizeof(struct adbdev_state), GFP_KERNEL); - if (state == 0) - return -ENOMEM; + if (state == 0) { + ret = -ENOMEM; + goto out; + } file->private_data = state; spin_lock_init(&state->lock); atomic_set(&state->n_pending, 0); @@ -657,7 +663,9 @@ static int adb_open(struct inode *inode, struct file *file) init_waitqueue_head(&state->wait_queue); state->inuse = 1; - return 0; +out: + unlock_kernel(); + return ret; } static int adb_release(struct inode *inode, struct file *file) -- cgit v1.2.3 From b82829943c470e59cfd3ee84d8ed6ae5d5e1a55b Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Tue, 20 May 2008 19:15:32 +0200 Subject: ans-lcd: BKL pushdown Signed-off-by: Arnd Bergmann --- drivers/macintosh/ans-lcd.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'drivers/macintosh') diff --git a/drivers/macintosh/ans-lcd.c b/drivers/macintosh/ans-lcd.c index 73c50bc0209..6a822189325 100644 --- a/drivers/macintosh/ans-lcd.c +++ b/drivers/macintosh/ans-lcd.c @@ -3,6 +3,7 @@ */ #include +#include #include #include #include @@ -119,6 +120,7 @@ anslcd_ioctl( struct inode * inode, struct file * file, static int anslcd_open( struct inode * inode, struct file * file ) { + cycle_kernel_lock(); return 0; } -- cgit v1.2.3 From b9bde77a6a4f76b767d4363a5f74127528426159 Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Tue, 20 May 2008 19:16:11 +0200 Subject: macintosh-smu: BKL pushdown Signed-off-by: Arnd Bergmann --- drivers/macintosh/smu.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'drivers/macintosh') diff --git a/drivers/macintosh/smu.c b/drivers/macintosh/smu.c index 77ad192962c..b82fcd210bf 100644 --- a/drivers/macintosh/smu.c +++ b/drivers/macintosh/smu.c @@ -19,6 +19,7 @@ * the userland interface */ +#include #include #include #include @@ -1083,10 +1084,12 @@ static int smu_open(struct inode *inode, struct file *file) pp->mode = smu_file_commands; init_waitqueue_head(&pp->wait); + lock_kernel(); spin_lock_irqsave(&smu_clist_lock, flags); list_add(&pp->list, &smu_clist); spin_unlock_irqrestore(&smu_clist_lock, flags); file->private_data = pp; + unlock_kernel(); return 0; } -- cgit v1.2.3 From ad9e05aef7c861280b404d38fb50a8ff11d01e11 Mon Sep 17 00:00:00 2001 From: Stephen Rothwell Date: Fri, 23 May 2008 16:27:02 +1000 Subject: macintosh: Use linux/of_{device,platform}.h instead of asm Signed-off-by: Stephen Rothwell Acked-by: Benjamin Herrenschmidt Signed-off-by: Paul Mackerras --- drivers/macintosh/smu.c | 4 ++-- drivers/macintosh/therm_adt746x.c | 2 +- drivers/macintosh/therm_pm72.c | 4 ++-- drivers/macintosh/therm_windtunnel.c | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) (limited to 'drivers/macintosh') diff --git a/drivers/macintosh/smu.c b/drivers/macintosh/smu.c index d86d57af282..1272184a3a6 100644 --- a/drivers/macintosh/smu.c +++ b/drivers/macintosh/smu.c @@ -35,6 +35,8 @@ #include #include #include +#include +#include #include #include @@ -45,8 +47,6 @@ #include #include #include -#include -#include #define VERSION "0.7" #define AUTHOR "(c) 2005 Benjamin Herrenschmidt, IBM Corp." diff --git a/drivers/macintosh/therm_adt746x.c b/drivers/macintosh/therm_adt746x.c index 5366dc93fb3..22bf981d393 100644 --- a/drivers/macintosh/therm_adt746x.c +++ b/drivers/macintosh/therm_adt746x.c @@ -24,13 +24,13 @@ #include #include #include +#include #include #include #include #include #include -#include #undef DEBUG diff --git a/drivers/macintosh/therm_pm72.c b/drivers/macintosh/therm_pm72.c index ddfb426a9ab..817607e2af6 100644 --- a/drivers/macintosh/therm_pm72.c +++ b/drivers/macintosh/therm_pm72.c @@ -123,14 +123,14 @@ #include #include #include +#include +#include #include #include #include #include #include -#include #include -#include #include "therm_pm72.h" diff --git a/drivers/macintosh/therm_windtunnel.c b/drivers/macintosh/therm_windtunnel.c index d11821af3b8..6d9e7ac7122 100644 --- a/drivers/macintosh/therm_windtunnel.c +++ b/drivers/macintosh/therm_windtunnel.c @@ -37,13 +37,13 @@ #include #include #include +#include #include #include #include #include #include -#include #include #define LOG_TEMP 0 /* continously log temperature */ -- cgit v1.2.3 From 1baaeea00594776978d875a0f618591056a3705a Mon Sep 17 00:00:00 2001 From: Daniel Walker Date: Tue, 10 Jun 2008 09:26:08 +1000 Subject: macintosh/therm_windtunnel: Convert semaphore to mutex Signed-off-by: Daniel Walker Signed-off-by: Andrew Morton Acked-by: Benjamin Herrenschmidt Signed-off-by: Paul Mackerras --- drivers/macintosh/therm_windtunnel.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'drivers/macintosh') diff --git a/drivers/macintosh/therm_windtunnel.c b/drivers/macintosh/therm_windtunnel.c index 6d9e7ac7122..3da0a02efd7 100644 --- a/drivers/macintosh/therm_windtunnel.c +++ b/drivers/macintosh/therm_windtunnel.c @@ -62,7 +62,7 @@ static struct { volatile int running; struct task_struct *poll_task; - struct semaphore lock; + struct mutex lock; struct of_device *of_dev; struct i2c_client *thermostat; @@ -286,23 +286,23 @@ restore_regs( void ) static int control_loop(void *dummy) { - down(&x.lock); + mutex_lock(&x.lock); setup_hardware(); - up(&x.lock); + mutex_unlock(&x.lock); for (;;) { msleep_interruptible(8000); if (kthread_should_stop()) break; - down(&x.lock); + mutex_lock(&x.lock); poll_temp(); - up(&x.lock); + mutex_unlock(&x.lock); } - down(&x.lock); + mutex_lock(&x.lock); restore_regs(); - up(&x.lock); + mutex_unlock(&x.lock); return 0; } @@ -489,7 +489,7 @@ g4fan_init( void ) const struct apple_thermal_info *info; struct device_node *np; - init_MUTEX( &x.lock ); + mutex_init(&x.lock); if( !(np=of_find_node_by_name(NULL, "power-mgt")) ) return -ENODEV; -- cgit v1.2.3 From 9a24729d8aeef967eac7af71c6a69edc83d06558 Mon Sep 17 00:00:00 2001 From: Daniel Walker Date: Tue, 10 Jun 2008 09:26:09 +1000 Subject: macintosh/media bay: Convert semaphore to mutex Signed-off-by: Daniel Walker Signed-off-by: Andrew Morton Acked-by: Benjamin Herrenschmidt Signed-off-by: Paul Mackerras --- drivers/macintosh/mediabay.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) (limited to 'drivers/macintosh') diff --git a/drivers/macintosh/mediabay.c b/drivers/macintosh/mediabay.c index 818aba36854..b1e5b470525 100644 --- a/drivers/macintosh/mediabay.c +++ b/drivers/macintosh/mediabay.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -77,7 +78,7 @@ struct media_bay_info { int index; int cached_gpio; int sleeping; - struct semaphore lock; + struct mutex lock; #ifdef CONFIG_BLK_DEV_IDE_PMAC ide_hwif_t *cd_port; void __iomem *cd_base; @@ -459,27 +460,27 @@ int media_bay_set_ide_infos(struct device_node* which_bay, unsigned long base, if (bay->mdev && which_bay == bay->mdev->ofdev.node) { int timeout = 5000, index = hwif->index; - down(&bay->lock); + mutex_lock(&bay->lock); bay->cd_port = hwif; bay->cd_base = (void __iomem *) base; bay->cd_irq = irq; if ((MB_CD != bay->content_id) || bay->state != mb_up) { - up(&bay->lock); + mutex_unlock(&bay->lock); return 0; } printk(KERN_DEBUG "Registered ide%d for media bay %d\n", index, i); do { if (MB_IDE_READY(i)) { bay->cd_index = index; - up(&bay->lock); + mutex_unlock(&bay->lock); return 0; } mdelay(1); } while(--timeout); printk(KERN_DEBUG "Timeount waiting IDE in bay %d\n", i); - up(&bay->lock); + mutex_unlock(&bay->lock); return -ENODEV; } } @@ -617,10 +618,10 @@ static int media_bay_task(void *x) while (!kthread_should_stop()) { for (i = 0; i < media_bay_count; ++i) { - down(&media_bays[i].lock); + mutex_lock(&media_bays[i].lock); if (!media_bays[i].sleeping) media_bay_step(i); - up(&media_bays[i].lock); + mutex_unlock(&media_bays[i].lock); } msleep_interruptible(MB_POLL_DELAY); @@ -660,7 +661,7 @@ static int __devinit media_bay_attach(struct macio_dev *mdev, const struct of_de bay->index = i; bay->ops = match->data; bay->sleeping = 0; - init_MUTEX(&bay->lock); + mutex_init(&bay->lock); /* Init HW probing */ if (bay->ops->init) @@ -698,10 +699,10 @@ static int media_bay_suspend(struct macio_dev *mdev, pm_message_t state) if (state.event != mdev->ofdev.dev.power.power_state.event && (state.event & PM_EVENT_SLEEP)) { - down(&bay->lock); + mutex_lock(&bay->lock); bay->sleeping = 1; set_mb_power(bay, 0); - up(&bay->lock); + mutex_unlock(&bay->lock); msleep(MB_POLL_DELAY); mdev->ofdev.dev.power.power_state = state; } @@ -720,12 +721,12 @@ static int media_bay_resume(struct macio_dev *mdev) they seem to help the 3400 get it right. */ /* Force MB power to 0 */ - down(&bay->lock); + mutex_lock(&bay->lock); set_mb_power(bay, 0); msleep(MB_POWER_DELAY); if (bay->ops->content(bay) != bay->content_id) { printk("mediabay%d: content changed during sleep...\n", bay->index); - up(&bay->lock); + mutex_unlock(&bay->lock); return 0; } set_mb_power(bay, 1); @@ -741,7 +742,7 @@ static int media_bay_resume(struct macio_dev *mdev) } while((bay->state != mb_empty) && (bay->state != mb_up)); bay->sleeping = 0; - up(&bay->lock); + mutex_unlock(&bay->lock); } return 0; } -- cgit v1.2.3 From 9b4a8dd2e9f8af206eb39e3d99c442b0d6158953 Mon Sep 17 00:00:00 2001 From: Adrian Bunk Date: Tue, 24 Jun 2008 03:46:57 +1000 Subject: drivers/macintosh: Various cleanups This contains the following cleanups: - make the following needlessly global code static: - adb.c: adb_controller - adb.c: adb_init() - adbhid.c: adb_to_linux_keycodes[] (also make it const) - via-pmu68k.c: backlight_level - via-pmu68k.c: backlight_enabled - remove the following unused code: - via-pmu68k.c: sleep_notifier_list Signed-off-by: Adrian Bunk Acked-by: Geert Uytterhoeven Acked-by: Stephen Rothwell Signed-off-by: Paul Mackerras --- drivers/macintosh/adb.c | 5 ++--- drivers/macintosh/adbhid.c | 2 +- drivers/macintosh/via-pmu68k.c | 5 ++--- 3 files changed, 5 insertions(+), 7 deletions(-) (limited to 'drivers/macintosh') diff --git a/drivers/macintosh/adb.c b/drivers/macintosh/adb.c index dbaad39020a..61b62a6f681 100644 --- a/drivers/macintosh/adb.c +++ b/drivers/macintosh/adb.c @@ -46,7 +46,6 @@ #endif -EXPORT_SYMBOL(adb_controller); EXPORT_SYMBOL(adb_client_list); extern struct adb_driver via_macii_driver; @@ -80,7 +79,7 @@ static struct adb_driver *adb_driver_list[] = { static struct class *adb_dev_class; -struct adb_driver *adb_controller; +static struct adb_driver *adb_controller; BLOCKING_NOTIFIER_HEAD(adb_client_list); static int adb_got_sleep; static int adb_inited; @@ -290,7 +289,7 @@ static int adb_resume(struct platform_device *dev) } #endif /* CONFIG_PM */ -int __init adb_init(void) +static int __init adb_init(void) { struct adb_driver *driver; int i; diff --git a/drivers/macintosh/adbhid.c b/drivers/macintosh/adbhid.c index ef4c117ea35..59ea520a5d7 100644 --- a/drivers/macintosh/adbhid.c +++ b/drivers/macintosh/adbhid.c @@ -75,7 +75,7 @@ static struct notifier_block adbhid_adb_notifier = { #define ADB_KEY_POWER_OLD 0x7e #define ADB_KEY_POWER 0x7f -u16 adb_to_linux_keycodes[128] = { +static const u16 adb_to_linux_keycodes[128] = { /* 0x00 */ KEY_A, /* 30 */ /* 0x01 */ KEY_S, /* 31 */ /* 0x02 */ KEY_D, /* 32 */ diff --git a/drivers/macintosh/via-pmu68k.c b/drivers/macintosh/via-pmu68k.c index e2f84da09e7..b64741c95ac 100644 --- a/drivers/macintosh/via-pmu68k.c +++ b/drivers/macintosh/via-pmu68k.c @@ -101,7 +101,6 @@ static int pmu_kind = PMU_UNKNOWN; static int pmu_fully_inited; int asleep; -BLOCKING_NOTIFIER_HEAD(sleep_notifier_list); static int pmu_probe(void); static int pmu_init(void); @@ -741,8 +740,8 @@ pmu_handle_data(unsigned char *data, int len) } } -int backlight_level = -1; -int backlight_enabled = 0; +static int backlight_level = -1; +static int backlight_enabled = 0; #define LEVEL_TO_BRIGHT(lev) ((lev) < 1? 0x7f: 0x4a - ((lev) << 1)) -- cgit v1.2.3 From 73f38fe1b563a9d23ffacbda7b51decf41b0c49c Mon Sep 17 00:00:00 2001 From: Julia Lawall Date: Tue, 24 Jun 2008 04:14:52 +1000 Subject: drivers/macintosh/smu.c: Improve error handling This makes two changes: * As noted by Akinobu Mita in patch b1fceac2b9e04d278316b2faddf276015fc06e3b, alloc_bootmem never returns NULL and always returns a zeroed region of memory. Thus the error checking code and memset after the call to alloc_bootmem are not necessary. * The old error handling code consisted of setting a global variable to NULL and returning an error code, which could cause previously allocated resources never to be freed. The patch adds calls to appropriate resource deallocation functions. Signed-off-by: Julia Lawall Signed-off-by: Paul Mackerras --- drivers/macintosh/smu.c | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) (limited to 'drivers/macintosh') diff --git a/drivers/macintosh/smu.c b/drivers/macintosh/smu.c index 1272184a3a6..76dbf25cb70 100644 --- a/drivers/macintosh/smu.c +++ b/drivers/macintosh/smu.c @@ -474,6 +474,7 @@ int __init smu_init (void) { struct device_node *np; const u32 *data; + int ret = 0; np = of_find_node_by_type(NULL, "smu"); if (np == NULL) @@ -483,16 +484,11 @@ int __init smu_init (void) if (smu_cmdbuf_abs == 0) { printk(KERN_ERR "SMU: Command buffer not allocated !\n"); - of_node_put(np); - return -EINVAL; + ret = -EINVAL; + goto fail_np; } smu = alloc_bootmem(sizeof(struct smu_device)); - if (smu == NULL) { - of_node_put(np); - return -ENOMEM; - } - memset(smu, 0, sizeof(*smu)); spin_lock_init(&smu->lock); INIT_LIST_HEAD(&smu->cmd_list); @@ -510,14 +506,14 @@ int __init smu_init (void) smu->db_node = of_find_node_by_name(NULL, "smu-doorbell"); if (smu->db_node == NULL) { printk(KERN_ERR "SMU: Can't find doorbell GPIO !\n"); - goto fail; + ret = -ENXIO; + goto fail_bootmem; } data = of_get_property(smu->db_node, "reg", NULL); if (data == NULL) { - of_node_put(smu->db_node); - smu->db_node = NULL; printk(KERN_ERR "SMU: Can't find doorbell GPIO address !\n"); - goto fail; + ret = -ENXIO; + goto fail_db_node; } /* Current setup has one doorbell GPIO that does both doorbell @@ -551,7 +547,8 @@ int __init smu_init (void) smu->db_buf = ioremap(0x8000860c, 0x1000); if (smu->db_buf == NULL) { printk(KERN_ERR "SMU: Can't map doorbell buffer pointer !\n"); - goto fail; + ret = -ENXIO; + goto fail_msg_node; } /* U3 has an issue with NAP mode when issuing SMU commands */ @@ -562,10 +559,17 @@ int __init smu_init (void) sys_ctrler = SYS_CTRLER_SMU; return 0; - fail: +fail_msg_node: + if (smu->msg_node) + of_node_put(smu->msg_node); +fail_db_node: + of_node_put(smu->db_node); +fail_bootmem: + free_bootmem((unsigned long)smu, sizeof(struct smu_device)); smu = NULL; - return -ENXIO; - +fail_np: + of_node_put(np); + return ret; } -- cgit v1.2.3 From ffe83733b88655b643e9d4ad0dda5ef9584d5926 Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Tue, 20 May 2008 19:16:58 +0200 Subject: via-pmu: BKL pushdown Signed-off-by: Arnd Bergmann --- drivers/macintosh/via-pmu.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'drivers/macintosh') diff --git a/drivers/macintosh/via-pmu.c b/drivers/macintosh/via-pmu.c index d6365a9f063..d524dc245a2 100644 --- a/drivers/macintosh/via-pmu.c +++ b/drivers/macintosh/via-pmu.c @@ -18,6 +18,7 @@ * */ #include +#include #include #include #include @@ -2047,6 +2048,7 @@ pmu_open(struct inode *inode, struct file *file) pp->rb_get = pp->rb_put = 0; spin_lock_init(&pp->lock); init_waitqueue_head(&pp->wait); + lock_kernel(); spin_lock_irqsave(&all_pvt_lock, flags); #if defined(CONFIG_INPUT_ADBHID) && defined(CONFIG_PMAC_BACKLIGHT) pp->backlight_locker = 0; @@ -2054,6 +2056,7 @@ pmu_open(struct inode *inode, struct file *file) list_add(&pp->list, &all_pmu_pvt); spin_unlock_irqrestore(&all_pvt_lock, flags); file->private_data = pp; + unlock_kernel(); return 0; } -- cgit v1.2.3