#include <linux/sched.h>
#include <linux/spinlock.h>
#include <linux/delay.h>
+#include <linux/serial_8250.h>
#include "smapi.h"
#include "mwavedd.h"
#include "3780i.h"
int mwave_3780i_io = 0;
int mwave_uart_irq = 0;
int mwave_uart_io = 0;
-MODULE_PARM(mwave_debug, "i");
-MODULE_PARM(mwave_3780i_irq, "i");
-MODULE_PARM(mwave_3780i_io, "i");
-MODULE_PARM(mwave_uart_irq, "i");
-MODULE_PARM(mwave_uart_io, "i");
+module_param(mwave_debug, int, 0);
+module_param(mwave_3780i_irq, int, 0);
+module_param(mwave_3780i_io, int, 0);
+module_param(mwave_uart_irq, int, 0);
+module_param(mwave_uart_io, int, 0);
static int mwave_open(struct inode *inode, struct file *file);
static int mwave_close(struct inode *inode, struct file *file);
unsigned int retval = 0;
PRINTK_3(TRACE_MWAVE,
- "mwavedd::mwave_open, entry inode %x file %x\n",
- (int) inode, (int) file);
+ "mwavedd::mwave_open, entry inode %p file %p\n",
+ inode, file);
PRINTK_2(TRACE_MWAVE,
"mwavedd::mwave_open, exit return retval %x\n", retval);
unsigned int retval = 0;
PRINTK_3(TRACE_MWAVE,
- "mwavedd::mwave_close, entry inode %x file %x\n",
- (int) inode, (int) file);
+ "mwavedd::mwave_close, entry inode %p file %p\n",
+ inode, file);
PRINTK_2(TRACE_MWAVE, "mwavedd::mwave_close, exit retval %x\n",
retval);
{
unsigned int retval = 0;
pMWAVE_DEVICE_DATA pDrvData = &mwave_s_mdd;
+ void __user *arg = (void __user *)ioarg;
PRINTK_5(TRACE_MWAVE,
- "mwavedd::mwave_ioctl, entry inode %x file %x cmd %x arg %x\n",
- (int) inode, (int) file, iocmd, (int) ioarg);
+ "mwavedd::mwave_ioctl, entry inode %p file %p cmd %x arg %x\n",
+ inode, file, iocmd, (int) ioarg);
switch (iocmd) {
" retval %x from tp3780I_QueryAbilities\n",
retval);
if (retval == 0) {
- if( copy_to_user((char *) ioarg,
- (char *) &rAbilities,
+ if( copy_to_user(arg, &rAbilities,
sizeof(MW_ABILITIES)) )
return -EFAULT;
}
case IOCTL_MW_READ_DATA:
case IOCTL_MW_READCLEAR_DATA: {
MW_READWRITE rReadData;
- unsigned short *pusBuffer = 0;
+ unsigned short __user *pusBuffer = NULL;
- if( copy_from_user((char *) &rReadData,
- (char *) ioarg,
+ if( copy_from_user(&rReadData, arg,
sizeof(MW_READWRITE)) )
return -EFAULT;
- pusBuffer = (unsigned short *) (rReadData.pBuf);
+ pusBuffer = (unsigned short __user *) (rReadData.pBuf);
PRINTK_4(TRACE_MWAVE,
"mwavedd::mwave_ioctl IOCTL_MW_READ_DATA,"
rReadData.ulDataLength, ioarg, pusBuffer);
retval = tp3780I_ReadWriteDspDStore(&pDrvData->rBDData,
iocmd,
- (void *) pusBuffer,
+ pusBuffer,
rReadData.ulDataLength,
rReadData.usDspAddress);
}
case IOCTL_MW_READ_INST: {
MW_READWRITE rReadData;
- unsigned short *pusBuffer = 0;
+ unsigned short __user *pusBuffer = NULL;
- if( copy_from_user((char *) &rReadData, (char *) ioarg,
+ if( copy_from_user(&rReadData, arg,
sizeof(MW_READWRITE)) )
return -EFAULT;
- pusBuffer = (unsigned short *) (rReadData.pBuf);
+ pusBuffer = (unsigned short __user *) (rReadData.pBuf);
PRINTK_4(TRACE_MWAVE,
"mwavedd::mwave_ioctl IOCTL_MW_READ_INST,"
case IOCTL_MW_WRITE_DATA: {
MW_READWRITE rWriteData;
- unsigned short *pusBuffer = 0;
+ unsigned short __user *pusBuffer = NULL;
- if( copy_from_user((char *) &rWriteData,
- (char *) ioarg,
+ if( copy_from_user(&rWriteData, arg,
sizeof(MW_READWRITE)) )
return -EFAULT;
- pusBuffer = (unsigned short *) (rWriteData.pBuf);
+ pusBuffer = (unsigned short __user *) (rWriteData.pBuf);
PRINTK_4(TRACE_MWAVE,
"mwavedd::mwave_ioctl IOCTL_MW_WRITE_DATA,"
case IOCTL_MW_WRITE_INST: {
MW_READWRITE rWriteData;
- unsigned short *pusBuffer = 0;
+ unsigned short __user *pusBuffer = NULL;
- if( copy_from_user((char *) &rWriteData,
- (char *) ioarg,
+ if( copy_from_user(&rWriteData, arg,
sizeof(MW_READWRITE)) )
return -EFAULT;
- pusBuffer = (unsigned short *) (rWriteData.pBuf);
+ pusBuffer = (unsigned short __user *)(rWriteData.pBuf);
PRINTK_4(TRACE_MWAVE,
"mwavedd::mwave_ioctl IOCTL_MW_WRITE_INST,"
ipcnum,
pDrvData->IPCs[ipcnum].usIntCount);
- if (ipcnum > ARRAY_SIZE(pDrvData->IPCs)) {
+ if (ipcnum >= ARRAY_SIZE(pDrvData->IPCs)) {
PRINTK_ERROR(KERN_ERR_MWAVE
"mwavedd::mwave_ioctl:"
" IOCTL_MW_REGISTER_IPC:"
}
-static ssize_t mwave_read(struct file *file, char *buf, size_t count,
+static ssize_t mwave_read(struct file *file, char __user *buf, size_t count,
loff_t * ppos)
{
PRINTK_5(TRACE_MWAVE,
- "mwavedd::mwave_read entry file %p, buf %p, count %x ppos %p\n",
+ "mwavedd::mwave_read entry file %p, buf %p, count %zx ppos %p\n",
file, buf, count, ppos);
return -EINVAL;
}
-static ssize_t mwave_write(struct file *file, const char *buf,
+static ssize_t mwave_write(struct file *file, const char __user *buf,
size_t count, loff_t * ppos)
{
PRINTK_5(TRACE_MWAVE,
"mwavedd::mwave_write entry file %p, buf %p,"
- " count %x ppos %p\n",
+ " count %zx ppos %p\n",
file, buf, count, ppos);
return -EINVAL;
static int register_serial_portandirq(unsigned int port, int irq)
{
- struct serial_struct serial;
-
+ struct uart_port uart;
+
switch ( port ) {
case 0x3f8:
case 0x2f8:
} /* switch */
/* irq is okay */
- memset(&serial, 0, sizeof(serial));
- serial.port = port;
- serial.irq = irq;
- serial.flags = ASYNC_SHARE_IRQ;
-
- return register_serial(&serial);
+ memset(&uart, 0, sizeof(struct uart_port));
+
+ uart.uartclk = 1843200;
+ uart.iobase = port;
+ uart.irq = irq;
+ uart.iotype = UPIO_PORT;
+ uart.flags = UPF_SHARE_IRQ;
+ return serial8250_register_port(&uart);
}
-static struct file_operations mwave_fops = {
+static const struct file_operations mwave_fops = {
.owner = THIS_MODULE,
.read = mwave_read,
.write = mwave_write,
static struct miscdevice mwave_misc_dev = { MWAVE_MINOR, "mwave", &mwave_fops };
+#if 0 /* totally b0rked */
/*
* sysfs support <paulsch@us.ibm.com>
*/
/* Prevent code redundancy, create a macro for mwave_show_* functions. */
#define mwave_show_function(attr_name, format_string, field) \
-static ssize_t mwave_show_##attr_name(struct device *dev, char *buf) \
+static ssize_t mwave_show_##attr_name(struct device *dev, struct device_attribute *attr, char *buf) \
{ \
DSP_3780I_CONFIG_SETTINGS *pSettings = \
&mwave_s_mdd.rBDData.rDspSettings; \
&dev_attr_uart_irq,
&dev_attr_uart_io,
};
+#endif
/*
* mwave_init is called on module load
*/
static void mwave_exit(void)
{
- int i;
pMWAVE_DEVICE_DATA pDrvData = &mwave_s_mdd;
PRINTK_1(TRACE_MWAVE, "mwavedd::mwave_exit entry\n");
+#if 0
for (i = 0; i < pDrvData->nr_registered_attrs; i++)
device_remove_file(&mwave_device, mwave_dev_attrs[i]);
pDrvData->nr_registered_attrs = 0;
device_unregister(&mwave_device);
pDrvData->device_registered = FALSE;
}
+#endif
if ( pDrvData->sLine >= 0 ) {
- unregister_serial(pDrvData->sLine);
+ serial8250_unregister_port(pDrvData->sLine);
}
if (pDrvData->bMwaveDevRegistered) {
misc_deregister(&mwave_misc_dev);
}
/* uart is registered */
+#if 0
/* sysfs */
memset(&mwave_device, 0, sizeof (struct device));
snprintf(mwave_device.bus_id, BUS_ID_SIZE, "mwave");
}
pDrvData->nr_registered_attrs++;
}
+#endif
/* SUCCESS! */
return 0;