Commit d27ba47e authored by Linus Torvalds's avatar Linus Torvalds
Browse files

Merge master.kernel.org:/pub/scm/linux/kernel/git/davem/sparc-2.6

parents e3d8b77b dd3e2dcf
......@@ -130,8 +130,6 @@ Code Seq# Include File Comments
<mailto:zapman@interlan.net>
'i' 00-3F linux/i2o.h
'j' 00-3F linux/joystick.h
'k' all asm-sparc/kbio.h
asm-sparc64/kbio.h
'l' 00-3F linux/tcfs_fs.h transparent cryptographic file system
<http://mikonos.dia.unisa.it/tcfs>
'l' 40-7F linux/udf_fs_i.h in development:
......
......@@ -201,6 +201,14 @@ config SUN_OPENPROMFS
Only choose N if you know in advance that you will not need to modify
OpenPROM settings on the running system.
config SPARC_LED
tristate "Sun4m LED driver"
help
This driver toggles the front-panel LED on sun4m systems
in a user-specifyable manner. It's state can be probed
by reading /proc/led and it's blinking mode can be changed
via writes to /proc/led
source "fs/Kconfig.binfmt"
config SUNOS_EMUL
......
......@@ -21,6 +21,7 @@ obj-$(CONFIG_SUN_AUXIO) += auxio.o
obj-$(CONFIG_PCI) += ebus.o
obj-$(CONFIG_SUN_PM) += apc.o pmc.o
obj-$(CONFIG_MODULES) += module.o sparc_ksyms.o
obj-$(CONFIG_SPARC_LED) += led.o
ifdef CONFIG_SUNOS_EMUL
obj-y += sys_sunos.o sunos_ioctl.o
......
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/init.h>
#include <linux/proc_fs.h>
#include <linux/string.h>
#include <asm/auxio.h>
#define LED_MAX_LENGTH 8 /* maximum chars written to proc file */
static inline void led_toggle(void)
{
unsigned char val = get_auxio();
unsigned char on, off;
if (val & AUXIO_LED) {
on = 0;
off = AUXIO_LED;
} else {
on = AUXIO_LED;
off = 0;
}
set_auxio(on, off);
}
static struct timer_list led_blink_timer;
static void led_blink(unsigned long timeout)
{
led_toggle();
/* reschedule */
if (!timeout) { /* blink according to load */
led_blink_timer.expires = jiffies +
((1 + (avenrun[0] >> FSHIFT)) * HZ);
led_blink_timer.data = 0;
} else { /* blink at user specified interval */
led_blink_timer.expires = jiffies + (timeout * HZ);
led_blink_timer.data = timeout;
}
add_timer(&led_blink_timer);
}
static int led_read_proc(char *buf, char **start, off_t offset, int count,
int *eof, void *data)
{
int len = 0;
if (get_auxio() & AUXIO_LED)
len = sprintf(buf, "on\n");
else
len = sprintf(buf, "off\n");
return len;
}
static int led_write_proc(struct file *file, const char *buffer,
unsigned long count, void *data)
{
char *buf = NULL;
if (count > LED_MAX_LENGTH)
count = LED_MAX_LENGTH;
buf = kmalloc(sizeof(char) * (count + 1), GFP_KERNEL);
if (!buf)
return -ENOMEM;
if (copy_from_user(buf, buffer, count)) {
kfree(buf);
return -EFAULT;
}
buf[count] = '\0';
/* work around \n when echo'ing into proc */
if (buf[count - 1] == '\n')
buf[count - 1] = '\0';
/* before we change anything we want to stop any running timers,
* otherwise calls such as on will have no persistent effect
*/
del_timer_sync(&led_blink_timer);
if (!strcmp(buf, "on")) {
auxio_set_led(AUXIO_LED_ON);
} else if (!strcmp(buf, "toggle")) {
led_toggle();
} else if ((*buf > '0') && (*buf <= '9')) {
led_blink(simple_strtoul(buf, NULL, 10));
} else if (!strcmp(buf, "load")) {
led_blink(0);
} else {
auxio_set_led(AUXIO_LED_OFF);
}
kfree(buf);
return count;
}
static struct proc_dir_entry *led;
#define LED_VERSION "0.1"
static int __init led_init(void)
{
init_timer(&led_blink_timer);
led_blink_timer.function = led_blink;
led = create_proc_entry("led", 0, NULL);
if (!led)
return -ENOMEM;
led->read_proc = led_read_proc; /* reader function */
led->write_proc = led_write_proc; /* writer function */
led->owner = THIS_MODULE;
printk(KERN_INFO
"led: version %s, Lars Kotthoff <metalhead@metalhead.ws>\n",
LED_VERSION);
return 0;
}
static void __exit led_exit(void)
{
remove_proc_entry("led", NULL);
del_timer_sync(&led_blink_timer);
}
module_init(led_init);
module_exit(led_exit);
MODULE_AUTHOR("Lars Kotthoff <metalhead@metalhead.ws>");
MODULE_DESCRIPTION("Provides control of the front LED on SPARC systems.");
MODULE_LICENSE("GPL");
MODULE_VERSION(LED_VERSION);
......@@ -23,7 +23,6 @@
#include <linux/smp_lock.h>
#include <linux/syscalls.h>
#include <linux/file.h>
#include <asm/kbio.h>
#if 0
extern char sunkbd_type;
......
......@@ -11,33 +11,14 @@
#define INCLUDES
#include "compat_ioctl.c"
#include <linux/ncp_fs.h>
#include <linux/syscalls.h>
#include <asm/fbio.h>
#include <asm/kbio.h>
#include <asm/vuid_event.h>
#include <asm/envctrl.h>
#include <asm/display7seg.h>
#include <asm/openpromio.h>
#include <asm/audioio.h>
#include <asm/watchdog.h>
/* Use this to get at 32-bit user passed pointers.
* See sys_sparc32.c for description about it.
*/
#define A(__x) compat_ptr(__x)
static __inline__ void *alloc_user_space(long len)
{
struct pt_regs *regs = current_thread_info()->kregs;
unsigned long usp = regs->u_regs[UREG_I6];
if (!(test_thread_flag(TIF_32BIT)))
usp += STACK_BIAS;
return (void *) (usp - len);
}
#define CODE
#include "compat_ioctl.c"
......@@ -111,357 +92,6 @@ static int fbiogscursor(unsigned int fd, unsigned int cmd, unsigned long arg)
return sys_ioctl (fd, FBIOSCURSOR, (unsigned long)p);
}
#if defined(CONFIG_DRM) || defined(CONFIG_DRM_MODULE)
/* This really belongs in include/linux/drm.h -DaveM */
#include "../../../drivers/char/drm/drm.h"
typedef struct drm32_version {
int version_major; /* Major version */
int version_minor; /* Minor version */
int version_patchlevel;/* Patch level */
int name_len; /* Length of name buffer */
u32 name; /* Name of driver */
int date_len; /* Length of date buffer */
u32 date; /* User-space buffer to hold date */
int desc_len; /* Length of desc buffer */
u32 desc; /* User-space buffer to hold desc */
} drm32_version_t;
#define DRM32_IOCTL_VERSION DRM_IOWR(0x00, drm32_version_t)
static int drm32_version(unsigned int fd, unsigned int cmd, unsigned long arg)
{
drm32_version_t __user *uversion = (drm32_version_t __user *)arg;
drm_version_t __user *p = compat_alloc_user_space(sizeof(*p));
compat_uptr_t addr;
int n;
int ret;
if (clear_user(p, 3 * sizeof(int)) ||
get_user(n, &uversion->name_len) ||
put_user(n, &p->name_len) ||
get_user(addr, &uversion->name) ||
put_user(compat_ptr(addr), &p->name) ||
get_user(n, &uversion->date_len) ||
put_user(n, &p->date_len) ||
get_user(addr, &uversion->date) ||
put_user(compat_ptr(addr), &p->date) ||
get_user(n, &uversion->desc_len) ||
put_user(n, &p->desc_len) ||
get_user(addr, &uversion->desc) ||
put_user(compat_ptr(addr), &p->desc))
return -EFAULT;
ret = sys_ioctl(fd, DRM_IOCTL_VERSION, (unsigned long)p);
if (ret)
return ret;
if (copy_in_user(uversion, p, 3 * sizeof(int)) ||
get_user(n, &p->name_len) ||
put_user(n, &uversion->name_len) ||
get_user(n, &p->date_len) ||
put_user(n, &uversion->date_len) ||
get_user(n, &p->desc_len) ||
put_user(n, &uversion->desc_len))
return -EFAULT;
return 0;
}
typedef struct drm32_unique {
int unique_len; /* Length of unique */
u32 unique; /* Unique name for driver instantiation */
} drm32_unique_t;
#define DRM32_IOCTL_GET_UNIQUE DRM_IOWR(0x01, drm32_unique_t)
#define DRM32_IOCTL_SET_UNIQUE DRM_IOW( 0x10, drm32_unique_t)
static int drm32_getsetunique(unsigned int fd, unsigned int cmd, unsigned long arg)
{
drm32_unique_t __user *uarg = (drm32_unique_t __user *)arg;
drm_unique_t __user *p = compat_alloc_user_space(sizeof(*p));
compat_uptr_t addr;
int n;
int ret;
if (get_user(n, &uarg->unique_len) ||
put_user(n, &p->unique_len) ||
get_user(addr, &uarg->unique) ||
put_user(compat_ptr(addr), &p->unique))
return -EFAULT;
if (cmd == DRM32_IOCTL_GET_UNIQUE)
ret = sys_ioctl (fd, DRM_IOCTL_GET_UNIQUE, (unsigned long)p);
else
ret = sys_ioctl (fd, DRM_IOCTL_SET_UNIQUE, (unsigned long)p);
if (ret)
return ret;
if (get_user(n, &p->unique_len) || put_user(n, &uarg->unique_len))
return -EFAULT;
return 0;
}
typedef struct drm32_map {
u32 offset; /* Requested physical address (0 for SAREA)*/
u32 size; /* Requested physical size (bytes) */
drm_map_type_t type; /* Type of memory to map */
drm_map_flags_t flags; /* Flags */
u32 handle; /* User-space: "Handle" to pass to mmap */
/* Kernel-space: kernel-virtual address */
int mtrr; /* MTRR slot used */
/* Private data */
} drm32_map_t;
#define DRM32_IOCTL_ADD_MAP DRM_IOWR(0x15, drm32_map_t)
static int drm32_addmap(unsigned int fd, unsigned int cmd, unsigned long arg)
{
drm32_map_t __user *uarg = (drm32_map_t __user *) arg;
drm_map_t karg;
mm_segment_t old_fs;
u32 tmp;
int ret;
ret = get_user(karg.offset, &uarg->offset);
ret |= get_user(karg.size, &uarg->size);
ret |= get_user(karg.type, &uarg->type);
ret |= get_user(karg.flags, &uarg->flags);
ret |= get_user(tmp, &uarg->handle);
ret |= get_user(karg.mtrr, &uarg->mtrr);
if (ret)
return -EFAULT;
karg.handle = (void *) (unsigned long) tmp;
old_fs = get_fs();
set_fs(KERNEL_DS);
ret = sys_ioctl(fd, DRM_IOCTL_ADD_MAP, (unsigned long) &karg);
set_fs(old_fs);
if (!ret) {
ret = put_user(karg.offset, &uarg->offset);
ret |= put_user(karg.size, &uarg->size);
ret |= put_user(karg.type, &uarg->type);
ret |= put_user(karg.flags, &uarg->flags);
tmp = (u32) (long)karg.handle;
ret |= put_user(tmp, &uarg->handle);
ret |= put_user(karg.mtrr, &uarg->mtrr);
if (ret)
ret = -EFAULT;
}
return ret;
}
typedef struct drm32_buf_info {
int count; /* Entries in list */
u32 list; /* (drm_buf_desc_t *) */
} drm32_buf_info_t;
#define DRM32_IOCTL_INFO_BUFS DRM_IOWR(0x18, drm32_buf_info_t)
static int drm32_info_bufs(unsigned int fd, unsigned int cmd, unsigned long arg)
{
drm32_buf_info_t __user *uarg = (drm32_buf_info_t __user *)arg;
drm_buf_info_t __user *p = compat_alloc_user_space(sizeof(*p));
compat_uptr_t addr;
int n;
int ret;
if (get_user(n, &uarg->count) || put_user(n, &p->count) ||
get_user(addr, &uarg->list) || put_user(compat_ptr(addr), &p->list))
return -EFAULT;
ret = sys_ioctl(fd, DRM_IOCTL_INFO_BUFS, (unsigned long)p);
if (ret)
return ret;
if (get_user(n, &p->count) || put_user(n, &uarg->count))
return -EFAULT;
return 0;
}
typedef struct drm32_buf_free {
int count;
u32 list; /* (int *) */
} drm32_buf_free_t;
#define DRM32_IOCTL_FREE_BUFS DRM_IOW( 0x1a, drm32_buf_free_t)
static int drm32_free_bufs(unsigned int fd, unsigned int cmd, unsigned long arg)
{
drm32_buf_free_t __user *uarg = (drm32_buf_free_t __user *)arg;
drm_buf_free_t __user *p = compat_alloc_user_space(sizeof(*p));
compat_uptr_t addr;
int n;
if (get_user(n, &uarg->count) || put_user(n, &p->count) ||
get_user(addr, &uarg->list) || put_user(compat_ptr(addr), &p->list))
return -EFAULT;
return sys_ioctl(fd, DRM_IOCTL_FREE_BUFS, (unsigned long)p);
}
typedef struct drm32_buf_pub {
int idx; /* Index into master buflist */
int total; /* Buffer size */
int used; /* Amount of buffer in use (for DMA) */
u32 address; /* Address of buffer (void *) */
} drm32_buf_pub_t;
typedef struct drm32_buf_map {
int count; /* Length of buflist */
u32 virtual; /* Mmaped area in user-virtual (void *) */
u32 list; /* Buffer information (drm_buf_pub_t *) */
} drm32_buf_map_t;
#define DRM32_IOCTL_MAP_BUFS DRM_IOWR(0x19, drm32_buf_map_t)
static int drm32_map_bufs(unsigned int fd, unsigned int cmd, unsigned long arg)
{
drm32_buf_map_t __user *uarg = (drm32_buf_map_t __user *)arg;
drm32_buf_pub_t __user *ulist;
drm_buf_map_t __user *arg64;
drm_buf_pub_t __user *list;
int orig_count, ret, i;
int n;
compat_uptr_t addr;
if (get_user(orig_count, &uarg->count))
return -EFAULT;
arg64 = compat_alloc_user_space(sizeof(drm_buf_map_t) +
(size_t)orig_count * sizeof(drm_buf_pub_t));
list = (void __user *)(arg64 + 1);
if (put_user(orig_count, &arg64->count) ||
put_user(list, &arg64->list) ||
get_user(addr, &uarg->virtual) ||
put_user(compat_ptr(addr), &arg64->virtual) ||
get_user(addr, &uarg->list))
return -EFAULT;
ulist = compat_ptr(addr);
for (i = 0; i < orig_count; i++) {
if (get_user(n, &ulist[i].idx) ||
put_user(n, &list[i].idx) ||
get_user(n, &ulist[i].total) ||
put_user(n, &list[i].total) ||
get_user(n, &ulist[i].used) ||
put_user(n, &list[i].used) ||
get_user(addr, &ulist[i].address) ||
put_user(compat_ptr(addr), &list[i].address))
return -EFAULT;
}
ret = sys_ioctl(fd, DRM_IOCTL_MAP_BUFS, (unsigned long) arg64);
if (ret)
return ret;
for (i = 0; i < orig_count; i++) {
void __user *p;
if (get_user(n, &list[i].idx) ||
put_user(n, &ulist[i].idx) ||
get_user(n, &list[i].total) ||
put_user(n, &ulist[i].total) ||
get_user(n, &list[i].used) ||
put_user(n, &ulist[i].used) ||
get_user(p, &list[i].address) ||
put_user((unsigned long)p, &ulist[i].address))
return -EFAULT;
}
if (get_user(n, &arg64->count) || put_user(n, &uarg->count))
return -EFAULT;
return 0;
}
typedef struct drm32_dma {
/* Indices here refer to the offset into
buflist in drm_buf_get_t. */
int context; /* Context handle */
int send_count; /* Number of buffers to send */
u32 send_indices; /* List of handles to buffers (int *) */
u32 send_sizes; /* Lengths of data to send (int *) */
drm_dma_flags_t flags; /* Flags */
int request_count; /* Number of buffers requested */
int request_size; /* Desired size for buffers */
u32 request_indices; /* Buffer information (int *) */
u32 request_sizes; /* (int *) */
int granted_count; /* Number of buffers granted */
} drm32_dma_t;
#define DRM32_IOCTL_DMA DRM_IOWR(0x29, drm32_dma_t)
/* RED PEN The DRM layer blindly dereferences the send/request
* index/size arrays even though they are userland
* pointers. -DaveM
*/
static int drm32_dma(unsigned int fd, unsigned int cmd, unsigned long arg)
{
drm32_dma_t __user *uarg = (drm32_dma_t __user *) arg;
drm_dma_t __user *p = compat_alloc_user_space(sizeof(*p));
compat_uptr_t addr;
int ret;
if (copy_in_user(p, uarg, 2 * sizeof(int)) ||
get_user(addr, &uarg->send_indices) ||
put_user(compat_ptr(addr), &p->send_indices) ||
get_user(addr, &uarg->send_sizes) ||
put_user(compat_ptr(addr), &p->send_sizes) ||
copy_in_user(&p->flags, &uarg->flags, sizeof(drm_dma_flags_t)) ||
copy_in_user(&p->request_count, &uarg->request_count, sizeof(int))||
copy_in_user(&p->request_size, &uarg->request_size, sizeof(int)) ||
get_user(addr, &uarg->request_indices) ||
put_user(compat_ptr(addr), &p->request_indices) ||
get_user(addr, &uarg->request_sizes) ||
put_user(compat_ptr(addr), &p->request_sizes) ||
copy_in_user(&p->granted_count, &uarg->granted_count, sizeof(int)))
return -EFAULT;
ret = sys_ioctl(fd, DRM_IOCTL_DMA, (unsigned long)p);
if (ret)
return ret;
if (copy_in_user(uarg, p, 2 * sizeof(int)) ||
copy_in_user(&uarg->flags, &p->flags, sizeof(drm_dma_flags_t)) ||
copy_in_user(&uarg->request_count, &p->request_count, sizeof(int))||
copy_in_user(&uarg->request_size, &p->request_size, sizeof(int)) ||
copy_in_user(&uarg->granted_count, &p->granted_count, sizeof(int)))
return -EFAULT;
return 0;
}
typedef struct drm32_ctx_res {
int count;
u32 contexts; /* (drm_ctx_t *) */
} drm32_ctx_res_t;
#define DRM32_IOCTL_RES_CTX DRM_IOWR(0x26, drm32_ctx_res_t)
static int drm32_res_ctx(unsigned int fd, unsigned int cmd, unsigned long arg)
{
drm32_ctx_res_t __user *uarg = (drm32_ctx_res_t __user *) arg;
drm_ctx_res_t __user *p = compat_alloc_user_space(sizeof(*p));
compat_uptr_t addr;
int ret;
if (copy_in_user(p, uarg, sizeof(int)) ||
get_user(addr, &uarg->contexts) ||
put_user(compat_ptr(addr), &p->contexts))
return -EFAULT;
ret = sys_ioctl(fd, DRM_IOCTL_RES_CTX, (unsigned long)p);
if (ret)
return ret;
if (copy_in_user(uarg, p, sizeof(int)))
return -EFAULT;
return 0;
}
#endif
typedef int (* ioctl32_handler_t)(unsigned int, unsigned int, unsigned long, struct file *);
#define COMPATIBLE_IOCTL(cmd) HANDLE_IOCTL((cmd),sys_ioctl)
......@@ -485,103 +115,14 @@ COMPATIBLE_IOCTL(FBIOSCURPOS)
COMPATIBLE_IOCTL(FBIOGCURPOS)
COMPATIBLE_IOCTL(FBIOGCURMAX)
/* Little k */
COMPATIBLE_IOCTL(KIOCTYPE)
COMPATIBLE_IOCTL(KIOCLAYOUT)
COMPATIBLE_IOCTL(KIOCGTRANS)
COMPATIBLE_IOCTL(KIOCTRANS)
COMPATIBLE_IOCTL(KIOCCMD)
COMPATIBLE_IOCTL(KIOCSDIRECT)
COMPATIBLE_IOCTL(KIOCSLED)
COMPATIBLE_IOCTL(KIOCGLED)
COMPATIBLE_IOCTL(KIOCSRATE)
COMPATIBLE_IOCTL(KIOCGRATE)
COMPATIBLE_IOCTL(VUIDSFORMAT)
COMPATIBLE_IOCTL(VUIDGFORMAT)
/* Little v, the video4linux ioctls */
COMPATIBLE_IOCTL(_IOR('p', 20, int[7])) /* RTCGET */
COMPATIBLE_IOCTL(_IOW('p', 21, int[7])) /* RTCSET */
COMPATIBLE_IOCTL(ENVCTRL_RD_WARNING_TEMPERATURE)
COMPATIBLE_IOCTL(ENVCTRL_RD_SHUTDOWN_TEMPERATURE)
COMPATIBLE_IOCTL(ENVCTRL_RD_CPU_TEMPERATURE)
COMPATIBLE_IOCTL(ENVCTRL_RD_FAN_STATUS)
COMPATIBLE_IOCTL(ENVCTRL_RD_VOLTAGE_STATUS)
COMPATIBLE_IOCTL(ENVCTRL_RD_SCSI_TEMPERATURE)
COMPATIBLE_IOCTL(ENVCTRL_RD_ETHERNET_TEMPERATURE)
COMPATIBLE_IOCTL(ENVCTRL_RD_MTHRBD_TEMPERATURE)
COMPATIBLE_IOCTL(ENVCTRL_RD_CPU_VOLTAGE)
COMPATIBLE_IOCTL(ENVCTRL_RD_GLOBALADDRESS)
/* COMPATIBLE_IOCTL(D7SIOCRD) same value as ENVCTRL_RD_VOLTAGE_STATUS */
COMPATIBLE_IOCTL(D7SIOCWR)
COMPATIBLE_IOCTL</