Commit 2e83fc4d authored by Linus Torvalds's avatar Linus Torvalds

Merge branch 'powerpc-next' of git://git.kernel.org/pub/scm/linux/kernel/git/paulus/powerpc

* 'powerpc-next' of git://git.kernel.org/pub/scm/linux/kernel/git/paulus/powerpc:
  [POWERPC] Assign PDE->data before gluing PDE into /proc tree
  [POWERPC] devres: Add devm_ioremap_prot()
  [POWERPC] macintosh: ADB driver: adb_handler_sem semaphore to mutex
  [POWERPC] macintosh: windfarm_smu_sat: semaphore to mutex
  [POWERPC] macintosh: therm_pm72: driver_lock semaphore to mutex
parents 17aa7e03 9185ef67
...@@ -23,3 +23,4 @@ obj-$(CONFIG_SMP) += locks.o ...@@ -23,3 +23,4 @@ obj-$(CONFIG_SMP) += locks.o
endif endif
obj-$(CONFIG_PPC_LIB_RHEAP) += rheap.o obj-$(CONFIG_PPC_LIB_RHEAP) += rheap.o
obj-$(CONFIG_HAS_IOMEM) += devres.o
/*
* Copyright (C) 2008 Freescale Semiconductor, 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
* 2 of the License, or (at your option) any later version.
*/
#include <linux/device.h> /* devres_*(), devm_ioremap_release() */
#include <linux/io.h> /* ioremap_flags() */
#include <linux/module.h> /* EXPORT_SYMBOL() */
/**
* devm_ioremap_prot - Managed ioremap_flags()
* @dev: Generic device to remap IO address for
* @offset: BUS offset to map
* @size: Size of map
* @flags: Page flags
*
* Managed ioremap_prot(). Map is automatically unmapped on driver
* detach.
*/
void __iomem *devm_ioremap_prot(struct device *dev, resource_size_t offset,
size_t size, unsigned long flags)
{
void __iomem **ptr, *addr;
ptr = devres_alloc(devm_ioremap_release, sizeof(*ptr), GFP_KERNEL);
if (!ptr)
return NULL;
addr = ioremap_flags(offset, size, flags);
if (addr) {
*ptr = addr;
devres_add(dev, ptr);
} else
devres_free(ptr);
return addr;
}
EXPORT_SYMBOL(devm_ioremap_prot);
...@@ -55,11 +55,6 @@ static ssize_t scanlog_read(struct file *file, char __user *buf, ...@@ -55,11 +55,6 @@ static ssize_t scanlog_read(struct file *file, char __user *buf,
dp = PDE(inode); dp = PDE(inode);
data = (unsigned int *)dp->data; data = (unsigned int *)dp->data;
if (!data) {
printk(KERN_ERR "scanlog: read failed no data\n");
return -EIO;
}
if (count > RTAS_DATA_BUF_SIZE) if (count > RTAS_DATA_BUF_SIZE)
count = RTAS_DATA_BUF_SIZE; count = RTAS_DATA_BUF_SIZE;
...@@ -146,11 +141,6 @@ static int scanlog_open(struct inode * inode, struct file * file) ...@@ -146,11 +141,6 @@ static int scanlog_open(struct inode * inode, struct file * file)
struct proc_dir_entry *dp = PDE(inode); struct proc_dir_entry *dp = PDE(inode);
unsigned int *data = (unsigned int *)dp->data; unsigned int *data = (unsigned int *)dp->data;
if (!data) {
printk(KERN_ERR "scanlog: open failed no data\n");
return -EIO;
}
if (data[0] != 0) { if (data[0] != 0) {
/* This imperfect test stops a second copy of the /* This imperfect test stops a second copy of the
* data (or a reset while data is being copied) * data (or a reset while data is being copied)
...@@ -168,10 +158,6 @@ static int scanlog_release(struct inode * inode, struct file * file) ...@@ -168,10 +158,6 @@ static int scanlog_release(struct inode * inode, struct file * file)
struct proc_dir_entry *dp = PDE(inode); struct proc_dir_entry *dp = PDE(inode);
unsigned int *data = (unsigned int *)dp->data; unsigned int *data = (unsigned int *)dp->data;
if (!data) {
printk(KERN_ERR "scanlog: release failed no data\n");
return -EIO;
}
data[0] = 0; data[0] = 0;
return 0; return 0;
...@@ -200,12 +186,11 @@ static int __init scanlog_init(void) ...@@ -200,12 +186,11 @@ static int __init scanlog_init(void)
if (!data) if (!data)
goto err; goto err;
ent = proc_create("ppc64/rtas/scan-log-dump", S_IRUSR, NULL, ent = proc_create_data("ppc64/rtas/scan-log-dump", S_IRUSR, NULL,
&scanlog_fops); &scanlog_fops, data);
if (!ent) if (!ent)
goto err; goto err;
ent->data = data;
proc_ppc64_scan_log_dump = ent; proc_ppc64_scan_log_dump = ent;
return 0; return 0;
......
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
#include <linux/device.h> #include <linux/device.h>
#include <linux/kthread.h> #include <linux/kthread.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/semaphore.h> #include <linux/mutex.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#ifdef CONFIG_PPC #ifdef CONFIG_PPC
...@@ -102,7 +102,7 @@ static struct adb_handler { ...@@ -102,7 +102,7 @@ static struct adb_handler {
} adb_handler[16]; } adb_handler[16];
/* /*
* The adb_handler_sem mutex protects all accesses to the original_address * The adb_handler_mutex mutex protects all accesses to the original_address
* and handler_id fields of adb_handler[i] for all i, and changes to the * and handler_id fields of adb_handler[i] for all i, and changes to the
* handler field. * handler field.
* Accesses to the handler field are protected by the adb_handler_lock * Accesses to the handler field are protected by the adb_handler_lock
...@@ -110,7 +110,7 @@ static struct adb_handler { ...@@ -110,7 +110,7 @@ static struct adb_handler {
* time adb_unregister returns, we know that the old handler isn't being * time adb_unregister returns, we know that the old handler isn't being
* called. * called.
*/ */
static DECLARE_MUTEX(adb_handler_sem); static DEFINE_MUTEX(adb_handler_mutex);
static DEFINE_RWLOCK(adb_handler_lock); static DEFINE_RWLOCK(adb_handler_lock);
#if 0 #if 0
...@@ -355,7 +355,7 @@ do_adb_reset_bus(void) ...@@ -355,7 +355,7 @@ do_adb_reset_bus(void)
msleep(500); msleep(500);
} }
down(&adb_handler_sem); mutex_lock(&adb_handler_mutex);
write_lock_irq(&adb_handler_lock); write_lock_irq(&adb_handler_lock);
memset(adb_handler, 0, sizeof(adb_handler)); memset(adb_handler, 0, sizeof(adb_handler));
write_unlock_irq(&adb_handler_lock); write_unlock_irq(&adb_handler_lock);
...@@ -376,7 +376,7 @@ do_adb_reset_bus(void) ...@@ -376,7 +376,7 @@ do_adb_reset_bus(void)
if (adb_controller->autopoll) if (adb_controller->autopoll)
adb_controller->autopoll(autopoll_devs); adb_controller->autopoll(autopoll_devs);
} }
up(&adb_handler_sem); mutex_unlock(&adb_handler_mutex);
blocking_notifier_call_chain(&adb_client_list, blocking_notifier_call_chain(&adb_client_list,
ADB_MSG_POST_RESET, NULL); ADB_MSG_POST_RESET, NULL);
...@@ -454,7 +454,7 @@ adb_register(int default_id, int handler_id, struct adb_ids *ids, ...@@ -454,7 +454,7 @@ adb_register(int default_id, int handler_id, struct adb_ids *ids,
{ {
int i; int i;
down(&adb_handler_sem); mutex_lock(&adb_handler_mutex);
ids->nids = 0; ids->nids = 0;
for (i = 1; i < 16; i++) { for (i = 1; i < 16; i++) {
if ((adb_handler[i].original_address == default_id) && if ((adb_handler[i].original_address == default_id) &&
...@@ -472,7 +472,7 @@ adb_register(int default_id, int handler_id, struct adb_ids *ids, ...@@ -472,7 +472,7 @@ adb_register(int default_id, int handler_id, struct adb_ids *ids,
ids->id[ids->nids++] = i; ids->id[ids->nids++] = i;
} }
} }
up(&adb_handler_sem); mutex_unlock(&adb_handler_mutex);
return ids->nids; return ids->nids;
} }
...@@ -481,7 +481,7 @@ adb_unregister(int index) ...@@ -481,7 +481,7 @@ adb_unregister(int index)
{ {
int ret = -ENODEV; int ret = -ENODEV;
down(&adb_handler_sem); mutex_lock(&adb_handler_mutex);
write_lock_irq(&adb_handler_lock); write_lock_irq(&adb_handler_lock);
if (adb_handler[index].handler) { if (adb_handler[index].handler) {
while(adb_handler[index].busy) { while(adb_handler[index].busy) {
...@@ -493,7 +493,7 @@ adb_unregister(int index) ...@@ -493,7 +493,7 @@ adb_unregister(int index)
adb_handler[index].handler = NULL; adb_handler[index].handler = NULL;
} }
write_unlock_irq(&adb_handler_lock); write_unlock_irq(&adb_handler_lock);
up(&adb_handler_sem); mutex_unlock(&adb_handler_mutex);
return ret; return ret;
} }
...@@ -557,19 +557,19 @@ adb_try_handler_change(int address, int new_id) ...@@ -557,19 +557,19 @@ adb_try_handler_change(int address, int new_id)
{ {
int ret; int ret;
down(&adb_handler_sem); mutex_lock(&adb_handler_mutex);
ret = try_handler_change(address, new_id); ret = try_handler_change(address, new_id);
up(&adb_handler_sem); mutex_unlock(&adb_handler_mutex);
return ret; return ret;
} }
int int
adb_get_infos(int address, int *original_address, int *handler_id) adb_get_infos(int address, int *original_address, int *handler_id)
{ {
down(&adb_handler_sem); mutex_lock(&adb_handler_mutex);
*original_address = adb_handler[address].original_address; *original_address = adb_handler[address].original_address;
*handler_id = adb_handler[address].handler_id; *handler_id = adb_handler[address].handler_id;
up(&adb_handler_sem); mutex_unlock(&adb_handler_mutex);
return (*original_address != 0); return (*original_address != 0);
} }
...@@ -628,10 +628,10 @@ do_adb_query(struct adb_request *req) ...@@ -628,10 +628,10 @@ do_adb_query(struct adb_request *req)
case ADB_QUERY_GETDEVINFO: case ADB_QUERY_GETDEVINFO:
if (req->nbytes < 3) if (req->nbytes < 3)
break; break;
down(&adb_handler_sem); mutex_lock(&adb_handler_mutex);
req->reply[0] = adb_handler[req->data[2]].original_address; req->reply[0] = adb_handler[req->data[2]].original_address;
req->reply[1] = adb_handler[req->data[2]].handler_id; req->reply[1] = adb_handler[req->data[2]].handler_id;
up(&adb_handler_sem); mutex_unlock(&adb_handler_mutex);
req->complete = 1; req->complete = 1;
req->reply_len = 2; req->reply_len = 2;
adb_write_done(req); adb_write_done(req);
......
...@@ -122,6 +122,7 @@ ...@@ -122,6 +122,7 @@
#include <linux/kmod.h> #include <linux/kmod.h>
#include <linux/i2c.h> #include <linux/i2c.h>
#include <linux/kthread.h> #include <linux/kthread.h>
#include <linux/mutex.h>
#include <asm/prom.h> #include <asm/prom.h>
#include <asm/machdep.h> #include <asm/machdep.h>
#include <asm/io.h> #include <asm/io.h>
...@@ -169,7 +170,7 @@ static int rackmac; ...@@ -169,7 +170,7 @@ static int rackmac;
static s32 dimm_output_clamp; static s32 dimm_output_clamp;
static int fcu_rpm_shift; static int fcu_rpm_shift;
static int fcu_tickle_ticks; static int fcu_tickle_ticks;
static DECLARE_MUTEX(driver_lock); static DEFINE_MUTEX(driver_lock);
/* /*
* We have 3 types of CPU PID control. One is "split" old style control * We have 3 types of CPU PID control. One is "split" old style control
...@@ -729,9 +730,9 @@ static void fetch_cpu_pumps_minmax(void) ...@@ -729,9 +730,9 @@ static void fetch_cpu_pumps_minmax(void)
static ssize_t show_##name(struct device *dev, struct device_attribute *attr, char *buf) \ static ssize_t show_##name(struct device *dev, struct device_attribute *attr, char *buf) \
{ \ { \
ssize_t r; \ ssize_t r; \
down(&driver_lock); \ mutex_lock(&driver_lock); \
r = sprintf(buf, "%d.%03d", FIX32TOPRINT(data)); \ r = sprintf(buf, "%d.%03d", FIX32TOPRINT(data)); \
up(&driver_lock); \ mutex_unlock(&driver_lock); \
return r; \ return r; \
} }
#define BUILD_SHOW_FUNC_INT(name, data) \ #define BUILD_SHOW_FUNC_INT(name, data) \
...@@ -1803,11 +1804,11 @@ static int main_control_loop(void *x) ...@@ -1803,11 +1804,11 @@ static int main_control_loop(void *x)
{ {
DBG("main_control_loop started\n"); DBG("main_control_loop started\n");
down(&driver_lock); mutex_lock(&driver_lock);
if (start_fcu() < 0) { if (start_fcu() < 0) {
printk(KERN_ERR "kfand: failed to start FCU\n"); printk(KERN_ERR "kfand: failed to start FCU\n");
up(&driver_lock); mutex_unlock(&driver_lock);
goto out; goto out;
} }
...@@ -1822,14 +1823,14 @@ static int main_control_loop(void *x) ...@@ -1822,14 +1823,14 @@ static int main_control_loop(void *x)
fcu_tickle_ticks = FCU_TICKLE_TICKS; fcu_tickle_ticks = FCU_TICKLE_TICKS;
up(&driver_lock); mutex_unlock(&driver_lock);
while (state == state_attached) { while (state == state_attached) {
unsigned long elapsed, start; unsigned long elapsed, start;
start = jiffies; start = jiffies;
down(&driver_lock); mutex_lock(&driver_lock);
/* Tickle the FCU just in case */ /* Tickle the FCU just in case */
if (--fcu_tickle_ticks < 0) { if (--fcu_tickle_ticks < 0) {
...@@ -1861,7 +1862,7 @@ static int main_control_loop(void *x) ...@@ -1861,7 +1862,7 @@ static int main_control_loop(void *x)
do_monitor_slots(&slots_state); do_monitor_slots(&slots_state);
else else
do_monitor_drives(&drives_state); do_monitor_drives(&drives_state);
up(&driver_lock); mutex_unlock(&driver_lock);
if (critical_state == 1) { if (critical_state == 1) {
printk(KERN_WARNING "Temperature control detected a critical condition\n"); printk(KERN_WARNING "Temperature control detected a critical condition\n");
...@@ -2019,13 +2020,13 @@ static void detach_fcu(void) ...@@ -2019,13 +2020,13 @@ static void detach_fcu(void)
*/ */
static int therm_pm72_attach(struct i2c_adapter *adapter) static int therm_pm72_attach(struct i2c_adapter *adapter)
{ {
down(&driver_lock); mutex_lock(&driver_lock);
/* Check state */ /* Check state */
if (state == state_detached) if (state == state_detached)
state = state_attaching; state = state_attaching;
if (state != state_attaching) { if (state != state_attaching) {
up(&driver_lock); mutex_unlock(&driver_lock);
return 0; return 0;
} }
...@@ -2054,7 +2055,7 @@ static int therm_pm72_attach(struct i2c_adapter *adapter) ...@@ -2054,7 +2055,7 @@ static int therm_pm72_attach(struct i2c_adapter *adapter)
state = state_attached; state = state_attached;
start_control_loops(); start_control_loops();
} }
up(&driver_lock); mutex_unlock(&driver_lock);
return 0; return 0;
} }
...@@ -2065,16 +2066,16 @@ static int therm_pm72_attach(struct i2c_adapter *adapter) ...@@ -2065,16 +2066,16 @@ static int therm_pm72_attach(struct i2c_adapter *adapter)
*/ */
static int therm_pm72_detach(struct i2c_adapter *adapter) static int therm_pm72_detach(struct i2c_adapter *adapter)
{ {
down(&driver_lock); mutex_lock(&driver_lock);
if (state != state_detached) if (state != state_detached)
state = state_detaching; state = state_detaching;
/* Stop control loops if any */ /* Stop control loops if any */
DBG("stopping control loops\n"); DBG("stopping control loops\n");
up(&driver_lock); mutex_unlock(&driver_lock);
stop_control_loops(); stop_control_loops();
down(&driver_lock); mutex_lock(&driver_lock);
if (u3_0 != NULL && !strcmp(adapter->name, "u3 0")) { if (u3_0 != NULL && !strcmp(adapter->name, "u3 0")) {
DBG("lost U3-0, disposing control loops\n"); DBG("lost U3-0, disposing control loops\n");
...@@ -2090,7 +2091,7 @@ static int therm_pm72_detach(struct i2c_adapter *adapter) ...@@ -2090,7 +2091,7 @@ static int therm_pm72_detach(struct i2c_adapter *adapter)
if (u3_0 == NULL && u3_1 == NULL) if (u3_0 == NULL && u3_1 == NULL)
state = state_detached; state = state_detached;
up(&driver_lock); mutex_unlock(&driver_lock);
return 0; return 0;
} }
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
#include <linux/init.h> #include <linux/init.h>
#include <linux/wait.h> #include <linux/wait.h>
#include <linux/i2c.h> #include <linux/i2c.h>
#include <linux/semaphore.h> #include <linux/mutex.h>
#include <asm/prom.h> #include <asm/prom.h>
#include <asm/smu.h> #include <asm/smu.h>
#include <asm/pmac_low_i2c.h> #include <asm/pmac_low_i2c.h>
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
struct wf_sat { struct wf_sat {
int nr; int nr;
atomic_t refcnt; atomic_t refcnt;
struct semaphore mutex; struct mutex mutex;
unsigned long last_read; /* jiffies when cache last updated */ unsigned long last_read; /* jiffies when cache last updated */
u8 cache[16]; u8 cache[16];
struct i2c_client i2c; struct i2c_client i2c;
...@@ -163,7 +163,7 @@ static int wf_sat_get(struct wf_sensor *sr, s32 *value) ...@@ -163,7 +163,7 @@ static int wf_sat_get(struct wf_sensor *sr, s32 *value)
if (sat->i2c.adapter == NULL) if (sat->i2c.adapter == NULL)
return -ENODEV; return -ENODEV;
down(&sat->mutex); mutex_lock(&sat->mutex);
if (time_after(jiffies, (sat->last_read + MAX_AGE))) { if (time_after(jiffies, (sat->last_read + MAX_AGE))) {
err = wf_sat_read_cache(sat); err = wf_sat_read_cache(sat);
if (err) if (err)
...@@ -182,7 +182,7 @@ static int wf_sat_get(struct wf_sensor *sr, s32 *value) ...@@ -182,7 +182,7 @@ static int wf_sat_get(struct wf_sensor *sr, s32 *value)
err = 0; err = 0;
fail: fail:
up(&sat->mutex); mutex_unlock(&sat->mutex);
return err; return err;
} }
...@@ -233,7 +233,7 @@ static void wf_sat_create(struct i2c_adapter *adapter, struct device_node *dev) ...@@ -233,7 +233,7 @@ static void wf_sat_create(struct i2c_adapter *adapter, struct device_node *dev)
sat->nr = -1; sat->nr = -1;
sat->node = of_node_get(dev); sat->node = of_node_get(dev);
atomic_set(&sat->refcnt, 0); atomic_set(&sat->refcnt, 0);
init_MUTEX(&sat->mutex); mutex_init(&sat->mutex);
sat->i2c.addr = (addr >> 1) & 0x7f; sat->i2c.addr = (addr >> 1) & 0x7f;
sat->i2c.adapter = adapter; sat->i2c.adapter = adapter;
sat->i2c.driver = &wf_sat_driver; sat->i2c.driver = &wf_sat_driver;
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
#define _ASM_POWERPC_IO_H #define _ASM_POWERPC_IO_H
#ifdef __KERNEL__ #ifdef __KERNEL__
/* /*
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version * as published by the Free Software Foundation; either version
...@@ -18,6 +18,9 @@ extern int check_legacy_ioport(unsigned long base_port); ...@@ -18,6 +18,9 @@ extern int check_legacy_ioport(unsigned long base_port);
#define _PNPWRP 0xa79 #define _PNPWRP 0xa79
#define PNPBIOS_BASE 0xf000 #define PNPBIOS_BASE 0xf000
#include <linux/device.h>
#include <linux/io.h>
#include <linux/compiler.h> #include <linux/compiler.h>
#include <asm/page.h> #include <asm/page.h>
#include <asm/byteorder.h> #include <asm/byteorder.h>
...@@ -744,6 +747,9 @@ static inline void * bus_to_virt(unsigned long address) ...@@ -744,6 +747,9 @@ static inline void * bus_to_virt(unsigned long address)
#define clrsetbits_8(addr, clear, set) clrsetbits(8, addr, clear, set) #define clrsetbits_8(addr, clear, set) clrsetbits(8, addr, clear, set)
void __iomem *devm_ioremap_prot(struct device *dev, resource_size_t offset,
size_t size, unsigned long flags);
#endif /* __KERNEL__ */ #endif /* __KERNEL__ */
#endif /* _ASM_POWERPC_IO_H */ #endif /* _ASM_POWERPC_IO_H */
...@@ -65,5 +65,6 @@ void __iomem *devm_ioremap_nocache(struct device *dev, resource_size_t offset, ...@@ -65,5 +65,6 @@ void __iomem *devm_ioremap_nocache(struct device *dev, resource_size_t offset,
void devm_iounmap(struct device *dev, void __iomem *addr); void devm_iounmap(struct device *dev, void __iomem *addr);
int check_signature(const volatile void __iomem *io_addr, int check_signature(const volatile void __iomem *io_addr,
const unsigned char *signature, int length); const unsigned char *signature, int length);
void devm_ioremap_release(struct device *dev, void *res);
#endif /* _LINUX_IO_H */ #endif /* _LINUX_IO_H */
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
#include <linux/io.h> #include <linux/io.h>
#include <linux/module.h> #include <linux/module.h>
static void devm_ioremap_release(struct device *dev, void *res) void devm_ioremap_release(struct device *dev, void *res)
{ {
iounmap(*(void __iomem **)res); iounmap(*(void __iomem **)res);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment