// rather than 64k as some of the games work more responsively.
// log base 2( buff sz = 32k).
static unsigned long defaultorder = 3;
-MODULE_PARM(defaultorder, "i");
+module_param(defaultorder, ulong, 0);
//
// Turn on/off debugging compilation by commenting out "#define CSDEBUG"
#if CSDEBUG
static unsigned long cs_debuglevel = 1; // levels range from 1-9
static unsigned long cs_debugmask = CS_INIT | CS_ERROR; // use CS_DBGOUT with various mask values
-MODULE_PARM(cs_debuglevel, "i");
-MODULE_PARM(cs_debugmask, "i");
+module_param(cs_debuglevel, ulong, 0);
+module_param(cs_debugmask, ulong, 0);
#endif
#define CS_TRUE 1
#define CS_FALSE 0
})
//LIST_HEAD(cs4281_devs);
-struct list_head cs4281_devs = { &cs4281_devs, &cs4281_devs };
+static struct list_head cs4281_devs = { &cs4281_devs, &cs4281_devs };
struct cs4281_state;
// hardware resources
unsigned int pBA0phys, pBA1phys;
- char *pBA0, *pBA1;
+ char __iomem *pBA0;
+ char __iomem *pBA1;
unsigned int irq;
// mixer registers
void *tmpbuff; // tmp buffer for sample conversions
unsigned ena;
spinlock_t lock;
- struct semaphore open_sem;
- struct semaphore open_sem_adc;
- struct semaphore open_sem_dac;
+ struct mutex open_sem;
+ struct mutex open_sem_adc;
+ struct mutex open_sem_dac;
mode_t open_mode;
wait_queue_head_t open_wait;
wait_queue_head_t open_wait_adc;
* Suspend - save the ac97 regs, mute the outputs and power down the part.
*
****************************************************************************/
-void cs4281_ac97_suspend(struct cs4281_state *s)
+static void cs4281_ac97_suspend(struct cs4281_state *s)
{
int Count,i;
* Resume - power up the part and restore its registers..
*
****************************************************************************/
-void cs4281_ac97_resume(struct cs4281_state *s)
+static void cs4281_ac97_resume(struct cs4281_state *s)
{
int Count,i;
} // SavePowerState
*/
-void cs4281_SuspendFIFO(struct cs4281_state *s, struct cs4281_pipeline *pl)
+static void cs4281_SuspendFIFO(struct cs4281_state *s, struct cs4281_pipeline *pl)
{
/*
* We need to save the contents of the BASIC FIFO Registers.
pl->u32FCRn_Save = readl(s->pBA0 + pl->u32FCRnAddress);
pl->u32FSICn_Save = readl(s->pBA0 + pl->u32FSICnAddress);
}
-void cs4281_ResumeFIFO(struct cs4281_state *s, struct cs4281_pipeline *pl)
+static void cs4281_ResumeFIFO(struct cs4281_state *s, struct cs4281_pipeline *pl)
{
/*
* We need to restore the contents of the BASIC FIFO Registers.
writel(pl->u32FCRn_Save,s->pBA0 + pl->u32FCRnAddress);
writel(pl->u32FSICn_Save,s->pBA0 + pl->u32FSICnAddress);
}
-void cs4281_SuspendDMAengine(struct cs4281_state *s, struct cs4281_pipeline *pl)
+static void cs4281_SuspendDMAengine(struct cs4281_state *s, struct cs4281_pipeline *pl)
{
//
// We need to save the contents of the BASIC DMA Registers.
pl->u32DCCn_Save = readl(s->pBA0 + pl->u32DCCnAddress);
pl->u32DCAn_Save = readl(s->pBA0 + pl->u32DCAnAddress);
}
-void cs4281_ResumeDMAengine(struct cs4281_state *s, struct cs4281_pipeline *pl)
+static void cs4281_ResumeDMAengine(struct cs4281_state *s, struct cs4281_pipeline *pl)
{
//
// We need to save the contents of the BASIC DMA Registers.
writel( pl->u32DCAn_Save, s->pBA0 + pl->u32DCAnAddress);
}
-int cs4281_suspend(struct cs4281_state *s)
+static int cs4281_suspend(struct cs4281_state *s)
{
int i;
u32 u32CLKCR1;
return 0;
}
-int cs4281_resume(struct cs4281_state *s)
+static int cs4281_resume(struct cs4281_state *s)
{
int i;
unsigned temp1;
#define DMABUF_MINORDER 1 // ==> min buffer size = 8K.
-extern void dealloc_dmabuf(struct cs4281_state *s, struct dmabuf *db)
+static void dealloc_dmabuf(struct cs4281_state *s, struct dmabuf *db)
{
struct page *map, *mapend;
}
db->buforder = order;
// Now mark the pages as reserved; otherwise the
- // remap_page_range() in cs4281_mmap doesn't work.
+ // remap_pfn_range() in cs4281_mmap doesn't work.
// 1. get index to last page in mem_map array for rawbuf.
mapend = virt_to_page(db->rawbuf +
(PAGE_SIZE << db->buforder) - 1);
}
s->buforder_tmpbuff = order;
// Now mark the pages as reserved; otherwise the
- // remap_page_range() in cs4281_mmap doesn't work.
+ // remap_pfn_range() in cs4281_mmap doesn't work.
// 1. get index to last page in mem_map array for rawbuf.
mapend = virt_to_page(s->tmpbuff +
(PAGE_SIZE << s->buforder_tmpbuff) - 1);
SOUND_MASK_MIC, SOUND_MASK_CD, 0, SOUND_MASK_LINE1,
SOUND_MASK_LINE, SOUND_MASK_VOLUME, 0, 0
};
+ void __user *argp = (void __user *)arg;
// Index of mixtable1[] member is Device ID
// and must be <= SOUND_MIXER_NRDEVICES.
case SOUND_MIXER_CS_GETDBGMASK:
return put_user(cs_debugmask,
- (unsigned long *) arg);
+ (unsigned long __user *) argp);
case SOUND_MIXER_CS_GETDBGLEVEL:
return put_user(cs_debuglevel,
- (unsigned long *) arg);
+ (unsigned long __user *) argp);
case SOUND_MIXER_CS_SETDBGMASK:
- if (get_user(val, (unsigned long *) arg))
+ if (get_user(val, (unsigned long __user *) argp))
return -EFAULT;
cs_debugmask = val;
return 0;
case SOUND_MIXER_CS_SETDBGLEVEL:
- if (get_user(val, (unsigned long *) arg))
+ if (get_user(val, (unsigned long __user *) argp))
return -EFAULT;
cs_debuglevel = val;
return 0;
#ifndef NOT_CS4281_PM
case SOUND_MIXER_CS_APM:
- if (get_user(val, (unsigned long *) arg))
+ if (get_user(val, (unsigned long __user *) argp))
return -EFAULT;
if(val == CS_IOCTL_CMD_SUSPEND)
cs4281_suspend(s);
if (cmd == SOUND_MIXER_PRIVATE1) {
// enable/disable/query mixer preamp
- if (get_user(val, (int *) arg))
+ if (get_user(val, (int __user *) argp))
return -EFAULT;
if (val != -1) {
cs4281_read_ac97(s, BA0_AC97_MIC_VOLUME, &temp1);
}
cs4281_read_ac97(s, BA0_AC97_MIC_VOLUME, &temp1);
val = (temp1 & 0x40) ? 1 : 0;
- return put_user(val, (int *) arg);
+ return put_user(val, (int __user *) argp);
}
if (cmd == SOUND_MIXER_PRIVATE2) {
// enable/disable/query spatializer
- if (get_user(val, (int *) arg))
+ if (get_user(val, (int __user *)argp))
return -EFAULT;
if (val != -1) {
temp1 = (val & 0x3f) >> 2;
temp1 | 0x2000);
}
cs4281_read_ac97(s, BA0_AC97_3D_CONTROL, &temp1);
- return put_user((temp1 << 2) | 3, (int *) arg);
+ return put_user((temp1 << 2) | 3, (int __user *)argp);
}
if (cmd == SOUND_MIXER_INFO) {
mixer_info info;
strlcpy(info.id, "CS4281", sizeof(info.id));
strlcpy(info.name, "Crystal CS4281", sizeof(info.name));
info.modify_counter = s->mix.modcnt;
- if (copy_to_user((void *) arg, &info, sizeof(info)))
+ if (copy_to_user(argp, &info, sizeof(info)))
return -EFAULT;
return 0;
}
_old_mixer_info info;
strlcpy(info.id, "CS4281", sizeof(info.id));
strlcpy(info.name, "Crystal CS4281", sizeof(info.name));
- if (copy_to_user((void *) arg, &info, sizeof(info)))
+ if (copy_to_user(argp, &info, sizeof(info)))
return -EFAULT;
return 0;
}
if (cmd == OSS_GETVERSION)
- return put_user(SOUND_VERSION, (int *) arg);
+ return put_user(SOUND_VERSION, (int __user *) argp);
if (_IOC_TYPE(cmd) != 'M' || _SIOC_SIZE(cmd) != sizeof(int))
return -EINVAL;
if (_SIOC_DIR(cmd) == _SIOC_READ) {
switch (_IOC_NR(cmd)) {
case SOUND_MIXER_RECSRC: // Arg contains a bit for each recording source
- cs4281_read_ac97(s, BA0_AC97_RECORD_SELECT,
- &temp1);
- return put_user(mixer_src[temp1 & 7], (int *) arg);
+ cs4281_read_ac97(s, BA0_AC97_RECORD_SELECT, &temp1);
+ return put_user(mixer_src[temp1&7], (int __user *)argp);
case SOUND_MIXER_DEVMASK: // Arg contains a bit for each supported device
return put_user(SOUND_MASK_PCM | SOUND_MASK_SYNTH |
SOUND_MASK_LINE1 | SOUND_MASK_MIC |
SOUND_MASK_VOLUME |
SOUND_MASK_RECLEV |
- SOUND_MASK_SPEAKER, (int *) arg);
+ SOUND_MASK_SPEAKER, (int __user *)argp);
case SOUND_MIXER_RECMASK: // Arg contains a bit for each supported recording source
return put_user(SOUND_MASK_LINE | SOUND_MASK_MIC |
SOUND_MASK_CD | SOUND_MASK_VOLUME |
- SOUND_MASK_LINE1, (int *) arg);
+ SOUND_MASK_LINE1, (int __user *) argp);
case SOUND_MIXER_STEREODEVS: // Mixer channels supporting stereo
return put_user(SOUND_MASK_PCM | SOUND_MASK_SYNTH |
SOUND_MASK_CD | SOUND_MASK_LINE |
SOUND_MASK_LINE1 | SOUND_MASK_MIC |
SOUND_MASK_VOLUME |
- SOUND_MASK_RECLEV, (int *) arg);
+ SOUND_MASK_RECLEV, (int __user *)argp);
case SOUND_MIXER_CAPS:
- return put_user(SOUND_CAP_EXCL_INPUT, (int *) arg);
+ return put_user(SOUND_CAP_EXCL_INPUT, (int __user *)argp);
default:
i = _IOC_NR(cmd);
if (i >= SOUND_MIXER_NRDEVICES
|| !(vidx = mixtable1[i]))
return -EINVAL;
- return put_user(s->mix.vol[vidx - 1], (int *) arg);
+ return put_user(s->mix.vol[vidx - 1], (int __user *)argp);
}
}
// If ioctl doesn't have both the SIOC_READ and
switch (_IOC_NR(cmd)) {
case SOUND_MIXER_RECSRC: // Arg contains a bit for each recording source
- if (get_user(val, (int *) arg))
+ if (get_user(val, (int __user *)argp))
return -EFAULT;
i = hweight32(val); // i = # bits on in val.
if (i != 1) // One & only 1 bit must be on.
return 0;
case SOUND_MIXER_VOLUME:
- if (get_user(val, (int *) arg))
+ if (get_user(val, (int __user *)argp))
return -EFAULT;
l = val & 0xff;
if (l > 100)
#else
s->mix.vol[8] = val;
#endif
- return put_user(s->mix.vol[8], (int *) arg);
+ return put_user(s->mix.vol[8], (int __user *)argp);
case SOUND_MIXER_SPEAKER:
- if (get_user(val, (int *) arg))
+ if (get_user(val, (int __user *)argp))
return -EFAULT;
l = val & 0xff;
if (l > 100)
#else
s->mix.vol[6] = val;
#endif
- return put_user(s->mix.vol[6], (int *) arg);
+ return put_user(s->mix.vol[6], (int __user *)argp);
case SOUND_MIXER_RECLEV:
- if (get_user(val, (int *) arg))
+ if (get_user(val, (int __user *)argp))
return -EFAULT;
l = val & 0xff;
if (l > 100)
#else
s->mix.vol[7] = val;
#endif
- return put_user(s->mix.vol[7], (int *) arg);
+ return put_user(s->mix.vol[7], (int __user *)argp);
case SOUND_MIXER_MIC:
- if (get_user(val, (int *) arg))
+ if (get_user(val, (int __user *)argp))
return -EFAULT;
l = val & 0xff;
if (l > 100)
#else
s->mix.vol[5] = val;
#endif
- return put_user(s->mix.vol[5], (int *) arg);
+ return put_user(s->mix.vol[5], (int __user *)argp);
case SOUND_MIXER_SYNTH:
- if (get_user(val, (int *) arg))
+ if (get_user(val, (int __user *)argp))
return -EFAULT;
l = val & 0xff;
if (l > 100)
l = 100;
- if (get_user(val, (int *) arg))
+ if (get_user(val, (int __user *)argp))
return -EFAULT;
r = (val >> 8) & 0xff;
if (r > 100)
#else
s->mix.vol[4] = val;
#endif
- return put_user(s->mix.vol[4], (int *) arg);
+ return put_user(s->mix.vol[4], (int __user *)argp);
default:
i = _IOC_NR(cmd);
if (i >= SOUND_MIXER_NRDEVICES || !(vidx = mixtable1[i]))
return -EINVAL;
- if (get_user(val, (int *) arg))
+ if (get_user(val, (int __user *)argp))
return -EFAULT;
l = val & 0xff;
if (l > 100)
"write ac97 mixreg[%d]=0x%x mix.vol[]=0x%x\n",
vidx-1,temp1,s->mix.vol[vidx-1]));
#endif
- return put_user(s->mix.vol[vidx - 1], (int *) arg);
+ return put_user(s->mix.vol[vidx - 1], (int __user *)argp);
}
}
CS_DBGOUT(CS_FUNCTION | CS_OPEN, 4,
printk(KERN_INFO "cs4281: cs4281_open_mixdev()- 0\n"));
- return 0;
+ return nonseekable_open(inode, file);
}
// issues with 8 bit capture, so the driver always captures data in 16 bit
// and then if the user requested 8 bit, converts from 16 to 8 bit.
//
-static unsigned cs_copy_to_user(struct cs4281_state *s, void *dest,
+static unsigned cs_copy_to_user(struct cs4281_state *s, void __user *dest,
unsigned *hwsrc, unsigned cnt,
unsigned *copied)
{
// ---------------------------------------------------------------------
-static ssize_t cs4281_read(struct file *file, char *buffer, size_t count,
+static ssize_t cs4281_read(struct file *file, char __user *buffer, size_t count,
loff_t * ppos)
{
struct cs4281_state *s =
printk(KERN_INFO "cs4281: cs4281_read()+ %Zu \n", count));
VALIDATE_STATE(s);
- if (ppos != &file->f_pos)
- return -ESPIPE;
if (s->dma_adc.mapped)
return -ENXIO;
if (!s->dma_adc.ready && (ret = prog_dmabuf_adc(s)))
}
-static ssize_t cs4281_write(struct file *file, const char *buffer,
+static ssize_t cs4281_write(struct file *file, const char __user *buffer,
size_t count, loff_t * ppos)
{
struct cs4281_state *s =
count));
VALIDATE_STATE(s);
- if (ppos != &file->f_pos)
- return -ESPIPE;
if (s->dma_dac.mapped)
return -ENXIO;
if (!s->dma_dac.ready && (ret = prog_dmabuf_dac(s)))
size = vma->vm_end - vma->vm_start;
if (size > (PAGE_SIZE << db->buforder))
return -EINVAL;
- if (remap_page_range
- (vma, vma->vm_start, virt_to_phys(db->rawbuf), size,
- vma->vm_page_prot)) return -EAGAIN;
+ if (remap_pfn_range(vma, vma->vm_start,
+ virt_to_phys(db->rawbuf) >> PAGE_SHIFT,
+ size, vma->vm_page_prot))
+ return -EAGAIN;
db->mapped = 1;
CS_DBGOUT(CS_FUNCTION | CS_PARMS | CS_OPEN, 4,
audio_buf_info abinfo;
count_info cinfo;
int val, mapped, ret;
+ int __user *p = (int __user *)arg;
CS_DBGOUT(CS_FUNCTION, 4, printk(KERN_INFO
"cs4281: cs4281_ioctl(): file=%p cmd=0x%.8x\n", file, cmd));
CS_DBGOUT(CS_IOCTL | CS_PARMS, 4, printk(KERN_INFO
"cs4281: cs4281_ioctl(): SOUND_VERSION=0x%.8x\n",
SOUND_VERSION));
- return put_user(SOUND_VERSION, (int *) arg);
+ return put_user(SOUND_VERSION, p);
case SNDCTL_DSP_SYNC:
CS_DBGOUT(CS_IOCTL, 4, printk(KERN_INFO
case SNDCTL_DSP_GETCAPS:
return put_user(DSP_CAP_DUPLEX | DSP_CAP_REALTIME |
DSP_CAP_TRIGGER | DSP_CAP_MMAP,
- (int *) arg);
+ p);
case SNDCTL_DSP_RESET:
CS_DBGOUT(CS_IOCTL, 4, printk(KERN_INFO
return 0;
case SNDCTL_DSP_SPEED:
- if (get_user(val, (int *) arg))
+ if (get_user(val, p))
return -EFAULT;
CS_DBGOUT(CS_IOCTL | CS_PARMS, 4, printk(KERN_INFO
"cs4281: cs4281_ioctl(): DSP_SPEED val=%d\n", val));
else if (file->f_mode & FMODE_READ)
val = s->prop_adc.rate;
- return put_user(val, (int *) arg);
+ return put_user(val, p);
case SNDCTL_DSP_STEREO:
- if (get_user(val, (int *) arg))
+ if (get_user(val, p))
return -EFAULT;
CS_DBGOUT(CS_IOCTL | CS_PARMS, 4, printk(KERN_INFO
"cs4281: cs4281_ioctl(): DSP_STEREO val=%d\n", val));
return 0;
case SNDCTL_DSP_CHANNELS:
- if (get_user(val, (int *) arg))
+ if (get_user(val, p))
return -EFAULT;
CS_DBGOUT(CS_IOCTL | CS_PARMS, 4, printk(KERN_INFO
"cs4281: cs4281_ioctl(): DSP_CHANNELS val=%d\n",
else if (file->f_mode & FMODE_READ)
val = s->prop_adc.channels;
- return put_user(val, (int *) arg);
+ return put_user(val, p);
case SNDCTL_DSP_GETFMTS: // Returns a mask
CS_DBGOUT(CS_IOCTL | CS_PARMS, 4, printk(KERN_INFO
AFMT_S16_LE | AFMT_U16_LE | AFMT_S8 |
AFMT_U8));
return put_user(AFMT_S16_LE | AFMT_U16_LE | AFMT_S8 |
- AFMT_U8, (int *) arg);
+ AFMT_U8, p);
case SNDCTL_DSP_SETFMT:
- if (get_user(val, (int *) arg))
+ if (get_user(val, p))
return -EFAULT;
CS_DBGOUT(CS_IOCTL | CS_PARMS, 4, printk(KERN_INFO
"cs4281: cs4281_ioctl(): DSP_SETFMT val=0x%.8x\n",
CS_DBGOUT(CS_IOCTL | CS_PARMS, 4, printk(KERN_INFO
"cs4281: cs4281_ioctl(): DSP_SETFMT return val=0x%.8x\n",
val));
- return put_user(val, (int *) arg);
+ return put_user(val, p);
case SNDCTL_DSP_POST:
CS_DBGOUT(CS_IOCTL, 4, printk(KERN_INFO
val |= PCM_ENABLE_INPUT;
if (file->f_mode & s->ena & FMODE_WRITE)
val |= PCM_ENABLE_OUTPUT;
- return put_user(val, (int *) arg);
+ return put_user(val, p);
case SNDCTL_DSP_SETTRIGGER:
- if (get_user(val, (int *) arg))
+ if (get_user(val, p))
return -EFAULT;
if (file->f_mode & FMODE_READ) {
if (val & PCM_ENABLE_INPUT) {
abinfo.fragsize,abinfo.bytes,abinfo.fragstotal,
abinfo.fragments));
spin_unlock_irqrestore(&s->lock, flags);
- return copy_to_user((void *) arg, &abinfo,
+ return copy_to_user(p, &abinfo,
sizeof(abinfo)) ? -EFAULT : 0;
case SNDCTL_DSP_GETISPACE:
abinfo.bytes >> s->dma_adc.fragshift;
}
spin_unlock_irqrestore(&s->lock, flags);
- return copy_to_user((void *) arg, &abinfo,
+ return copy_to_user(p, &abinfo,
sizeof(abinfo)) ? -EFAULT : 0;
case SNDCTL_DSP_NONBLOCK:
cs4281_update_ptr(s,CS_FALSE);
val = s->dma_dac.count;
spin_unlock_irqrestore(&s->lock, flags);
- return put_user(val, (int *) arg);
+ return put_user(val, p);
case SNDCTL_DSP_GETIPTR:
if (!(file->f_mode & FMODE_READ))
if (s->dma_adc.mapped)
s->dma_adc.count &= s->dma_adc.fragsize - 1;
spin_unlock_irqrestore(&s->lock, flags);
- if (copy_to_user((void *) arg, &cinfo, sizeof(cinfo)))
+ if (copy_to_user(p, &cinfo, sizeof(cinfo)))
return -EFAULT;
return 0;
if (s->dma_dac.mapped)
s->dma_dac.count &= s->dma_dac.fragsize - 1;
spin_unlock_irqrestore(&s->lock, flags);
- if (copy_to_user((void *) arg, &cinfo, sizeof(cinfo)))
+ if (copy_to_user(p, &cinfo, sizeof(cinfo)))
return -EFAULT;
return 0;
if (file->f_mode & FMODE_WRITE) {
if ((val = prog_dmabuf_dac(s)))
return val;
- return put_user(s->dma_dac.fragsize, (int *) arg);
+ return put_user(s->dma_dac.fragsize, p);
}
if ((val = prog_dmabuf_adc(s)))
return val;
if (s->conversion)
- return put_user(s->dma_adc.fragsize / 2,
- (int *) arg);
+ return put_user(s->dma_adc.fragsize / 2, p);
else
- return put_user(s->dma_adc.fragsize, (int *) arg);
+ return put_user(s->dma_adc.fragsize, p);
case SNDCTL_DSP_SETFRAGMENT:
- if (get_user(val, (int *) arg))
+ if (get_user(val, p))
return -EFAULT;
return 0; // Say OK, but do nothing.
if ((file->f_mode & FMODE_READ && s->dma_adc.subdivision)
|| (file->f_mode & FMODE_WRITE
&& s->dma_dac.subdivision)) return -EINVAL;
- if (get_user(val, (int *) arg))
+ if (get_user(val, p))
return -EFAULT;
if (val != 1 && val != 2 && val != 4)
return -EINVAL;
case SOUND_PCM_READ_RATE:
if (file->f_mode & FMODE_READ)
- return put_user(s->prop_adc.rate, (int *) arg);
+ return put_user(s->prop_adc.rate, p);
else if (file->f_mode & FMODE_WRITE)
- return put_user(s->prop_dac.rate, (int *) arg);
+ return put_user(s->prop_dac.rate, p);
case SOUND_PCM_READ_CHANNELS:
if (file->f_mode & FMODE_READ)
- return put_user(s->prop_adc.channels, (int *) arg);
+ return put_user(s->prop_adc.channels, p);
else if (file->f_mode & FMODE_WRITE)
- return put_user(s->prop_dac.channels, (int *) arg);
+ return put_user(s->prop_dac.channels, p);
case SOUND_PCM_READ_BITS:
if (file->f_mode & FMODE_READ)
put_user(
(s->prop_adc.
fmt & (AFMT_S8 | AFMT_U8)) ? 8 : 16,
- (int *) arg);
+ p);
else if (file->f_mode & FMODE_WRITE)
return
put_user(
(s->prop_dac.
fmt & (AFMT_S8 | AFMT_U8)) ? 8 : 16,
- (int *) arg);
+ p);
case SOUND_PCM_WRITE_FILTER:
case SNDCTL_DSP_SETSYNCRO:
if (file->f_mode & FMODE_WRITE) {
drain_dac(s, file->f_flags & O_NONBLOCK);
- down(&s->open_sem_dac);
+ mutex_lock(&s->open_sem_dac);
stop_dac(s);
dealloc_dmabuf(s, &s->dma_dac);
s->open_mode &= ~FMODE_WRITE;
- up(&s->open_sem_dac);
+ mutex_unlock(&s->open_sem_dac);
wake_up(&s->open_wait_dac);
}
if (file->f_mode & FMODE_READ) {
drain_adc(s, file->f_flags & O_NONBLOCK);
- down(&s->open_sem_adc);
+ mutex_lock(&s->open_sem_adc);
stop_adc(s);
dealloc_dmabuf(s, &s->dma_adc);
s->open_mode &= ~FMODE_READ;
- up(&s->open_sem_adc);
+ mutex_unlock(&s->open_sem_adc);
wake_up(&s->open_wait_adc);
}
return 0;
return -ENODEV;
}
if (file->f_mode & FMODE_WRITE) {
- down(&s->open_sem_dac);
+ mutex_lock(&s->open_sem_dac);
while (s->open_mode & FMODE_WRITE) {
if (file->f_flags & O_NONBLOCK) {
- up(&s->open_sem_dac);
+ mutex_unlock(&s->open_sem_dac);
return -EBUSY;
}
- up(&s->open_sem_dac);
+ mutex_unlock(&s->open_sem_dac);
interruptible_sleep_on(&s->open_wait_dac);
if (signal_pending(current))
return -ERESTARTSYS;
- down(&s->open_sem_dac);
+ mutex_lock(&s->open_sem_dac);
}
}
if (file->f_mode & FMODE_READ) {
- down(&s->open_sem_adc);
+ mutex_lock(&s->open_sem_adc);
while (s->open_mode & FMODE_READ) {
if (file->f_flags & O_NONBLOCK) {
- up(&s->open_sem_adc);
+ mutex_unlock(&s->open_sem_adc);
return -EBUSY;
}
- up(&s->open_sem_adc);
+ mutex_unlock(&s->open_sem_adc);
interruptible_sleep_on(&s->open_wait_adc);
if (signal_pending(current))
return -ERESTARTSYS;
- down(&s->open_sem_adc);
+ mutex_lock(&s->open_sem_adc);
}
}
s->open_mode |= file->f_mode & (FMODE_READ | FMODE_WRITE);
s->ena &= ~FMODE_READ;
s->dma_adc.ossfragshift = s->dma_adc.ossmaxfrags =
s->dma_adc.subdivision = 0;
- up(&s->open_sem_adc);
+ mutex_unlock(&s->open_sem_adc);
if (prog_dmabuf_adc(s)) {
CS_DBGOUT(CS_OPEN | CS_ERROR, 2, printk(KERN_ERR
s->ena &= ~FMODE_WRITE;
s->dma_dac.ossfragshift = s->dma_dac.ossmaxfrags =
s->dma_dac.subdivision = 0;
- up(&s->open_sem_dac);
+ mutex_unlock(&s->open_sem_dac);
if (prog_dmabuf_dac(s)) {
CS_DBGOUT(CS_OPEN | CS_ERROR, 2, printk(KERN_ERR
}
CS_DBGOUT(CS_FUNCTION | CS_OPEN, 2,
printk(KERN_INFO "cs4281: cs4281_open()- 0\n"));
- return 0;
+ return nonseekable_open(inode, file);
}
// ---------------------------------------------------------------------
-static ssize_t cs4281_midi_read(struct file *file, char *buffer,
+static ssize_t cs4281_midi_read(struct file *file, char __user *buffer,
size_t count, loff_t * ppos)
{
struct cs4281_state *s =
int cnt;
VALIDATE_STATE(s);
- if (ppos != &file->f_pos)
- return -ESPIPE;
if (!access_ok(VERIFY_WRITE, buffer, count))
return -EFAULT;
ret = 0;
}
-static ssize_t cs4281_midi_write(struct file *file, const char *buffer,
+static ssize_t cs4281_midi_write(struct file *file, const char __user *buffer,
size_t count, loff_t * ppos)
{
struct cs4281_state *s =
int cnt;
VALIDATE_STATE(s);
- if (ppos != &file->f_pos)
- return -ESPIPE;
if (!access_ok(VERIFY_READ, buffer, count))
return -EFAULT;
ret = 0;
VALIDATE_STATE(s);
file->private_data = s;
// wait for device to become free
- down(&s->open_sem);
+ mutex_lock(&s->open_sem);
while (s->open_mode & (file->f_mode << FMODE_MIDI_SHIFT)) {
if (file->f_flags & O_NONBLOCK) {
- up(&s->open_sem);
+ mutex_unlock(&s->open_sem);
return -EBUSY;
}
- up(&s->open_sem);
+ mutex_unlock(&s->open_sem);
interruptible_sleep_on(&s->open_wait);
if (signal_pending(current))
return -ERESTARTSYS;
- down(&s->open_sem);
+ mutex_lock(&s->open_sem);
}
spin_lock_irqsave(&s->lock, flags);
if (!(s->open_mode & (FMODE_MIDI_READ | FMODE_MIDI_WRITE))) {
(file->
f_mode << FMODE_MIDI_SHIFT) & (FMODE_MIDI_READ |
FMODE_MIDI_WRITE);
- up(&s->open_sem);
- return 0;
+ mutex_unlock(&s->open_sem);
+ return nonseekable_open(inode, file);
}
remove_wait_queue(&s->midi.owait, &wait);
current->state = TASK_RUNNING;
}
- down(&s->open_sem);
+ mutex_lock(&s->open_sem);
s->open_mode &=
(~(file->f_mode << FMODE_MIDI_SHIFT)) & (FMODE_MIDI_READ |
FMODE_MIDI_WRITE);
del_timer(&s->midi.timer);
}
spin_unlock_irqrestore(&s->lock, flags);
- up(&s->open_sem);
+ mutex_unlock(&s->open_sem);
wake_up(&s->open_wait);
return 0;
}
static struct initvol {
int mixch;
int vol;
-} initvol[] __initdata = {
+} initvol[] __devinitdata = {
{
SOUND_MIXER_WRITE_VOLUME, 0x4040}, {
#ifndef NOT_CS4281_PM
-void __devinit cs4281_BuildFIFO(
+static void __devinit cs4281_BuildFIFO(
struct cs4281_pipeline *p,
struct cs4281_state *s)
{
}
-void __devinit cs4281_BuildDMAengine(
+static void __devinit cs4281_BuildDMAengine(
struct cs4281_pipeline *p,
struct cs4281_state *s)
{
}
-void __devinit cs4281_InitPM(struct cs4281_state *s)
+static void __devinit cs4281_InitPM(struct cs4281_state *s)
{
int i;
struct cs4281_pipeline *p;
static int __devinit cs4281_probe(struct pci_dev *pcidev,
const struct pci_device_id *pciid)
{
-#ifndef NOT_CS4281_PM
- struct pm_dev *pmdev;
-#endif
struct cs4281_state *s;
dma_addr_t dma_mask;
mm_segment_t fs;
init_waitqueue_head(&s->open_wait_dac);
init_waitqueue_head(&s->midi.iwait);
init_waitqueue_head(&s->midi.owait);
- init_MUTEX(&s->open_sem);
- init_MUTEX(&s->open_sem_adc);
- init_MUTEX(&s->open_sem_dac);
+ mutex_init(&s->open_sem);
+ mutex_init(&s->open_sem_adc);
+ mutex_init(&s->open_sem_dac);
spin_lock_init(&s->lock);
s->pBA0phys = pci_resource_start(pcidev, 0);
s->pBA1phys = pci_resource_start(pcidev, 1);
s->pcidev = pcidev;
s->irq = pcidev->irq;
if (request_irq
- (s->irq, cs4281_interrupt, SA_SHIRQ, "Crystal CS4281", s)) {
+ (s->irq, cs4281_interrupt, IRQF_SHARED, "Crystal CS4281", s)) {
CS_DBGOUT(CS_INIT | CS_ERROR, 1,
printk(KERN_ERR "cs4281: irq %u in use\n", s->irq));
goto err_irq;
}
#ifndef NOT_CS4281_PM
cs4281_InitPM(s);
- pmdev = cs_pm_register(PM_PCI_DEV, PM_PCI_ID(pcidev), cs4281_pm_callback);
- if (pmdev)
- {
- CS_DBGOUT(CS_INIT | CS_PM, 4, printk(KERN_INFO
- "cs4281: probe() pm_register() succeeded (%p).\n", pmdev));
- pmdev->data = s;
- }
- else
- {
- CS_DBGOUT(CS_INIT | CS_PM | CS_ERROR, 0, printk(KERN_INFO
- "cs4281: probe() pm_register() failed (%p).\n", pmdev));
- s->pm.flags |= CS4281_PM_NOT_REGISTERED;
- }
+ s->pm.flags |= CS4281_PM_NOT_REGISTERED;
#endif
pci_set_master(pcidev); // enable bus mastering
MODULE_DEVICE_TABLE(pci, cs4281_pci_tbl);
-struct pci_driver cs4281_pci_driver = {
+static struct pci_driver cs4281_pci_driver = {
.name = "cs4281",
.id_table = cs4281_pci_tbl,
.probe = cs4281_probe,
.resume = CS4281_RESUME_TBL,
};
-int __init cs4281_init_module(void)
+static int __init cs4281_init_module(void)
{
int rtn = 0;
CS_DBGOUT(CS_INIT | CS_FUNCTION, 2, printk(KERN_INFO
printk(KERN_INFO "cs4281: version v%d.%02d.%d time " __TIME__ " "
__DATE__ "\n", CS4281_MAJOR_VERSION, CS4281_MINOR_VERSION,
CS4281_ARCH);
- rtn = pci_module_init(&cs4281_pci_driver);
+ rtn = pci_register_driver(&cs4281_pci_driver);
CS_DBGOUT(CS_INIT | CS_FUNCTION, 2,
printk(KERN_INFO "cs4281: cs4281_init_module()- (%d)\n",rtn));
return rtn;
}
-void __exit cs4281_cleanup_module(void)
+static void __exit cs4281_cleanup_module(void)
{
pci_unregister_driver(&cs4281_pci_driver);
-#ifndef NOT_CS4281_PM
- cs_pm_unregister_all(cs4281_pm_callback);
-#endif
CS_DBGOUT(CS_INIT | CS_FUNCTION, 2,
printk(KERN_INFO "cs4281: cleanup_cs4281() finished\n"));
}
module_init(cs4281_init_module);
module_exit(cs4281_cleanup_module);
-#ifndef MODULE
-int __init init_cs4281(void)
-{
- return cs4281_init_module();
-}
-#endif