#include <linux/interrupt.h>
#include <linux/proc_fs.h>
+#include <linux/mutex.h>
#include <asm/uaccess.h>
-#include <asm/hardirq.h>
#include <asm/io.h>
#define DRIVER_NAME "forte"
unsigned long iobase;
int irq;
- struct semaphore open_sem; /* Device access */
+ struct mutex open_mutex; /* Device access */
spinlock_t lock; /* State */
spinlock_t ac97_lock;
* @reg: register to read
*/
-u16
+static u16
forte_ac97_read (struct ac97_codec *codec, u8 reg)
{
u16 ret = 0;
* @val: value to write
*/
-void
+static void
forte_ac97_write (struct ac97_codec *codec, u8 reg, u16 val)
{
struct forte_chip *chip = codec->private_data;
struct forte_chip *chip = forte; /* FIXME: HACK FROM HELL! */
if (file->f_flags & O_NONBLOCK) {
- if (down_trylock (&chip->open_sem)) {
+ if (!mutex_trylock(&chip->open_mutex)) {
DPRINTK ("%s: returning -EAGAIN\n", __FUNCTION__);
return -EAGAIN;
}
}
else {
- if (down_interruptible (&chip->open_sem)) {
+ if (mutex_lock_interruptible(&chip->open_mutex)) {
DPRINTK ("%s: returning -ERESTARTSYS\n", __FUNCTION__);
return -ERESTARTSYS;
}
if (file->f_mode & FMODE_READ)
forte_channel_init (forte, &forte->rec);
- return 0;
+ return nonseekable_open(inode, file);
}
spin_unlock_irq (&chip->lock);
}
- up (&chip->open_sem);
+ mutex_unlock(&chip->open_mutex);
return ret;
}
goto out;
}
- if (remap_page_range (vma, vma->vm_start, virt_to_phys (channel->buf),
+ if (remap_pfn_range(vma, vma->vm_start,
+ virt_to_phys(channel->buf) >> PAGE_SHIFT,
size, vma->vm_page_prot)) {
DPRINTK ("%s: remap el a no worko\n", __FUNCTION__);
ret = -EAGAIN;
unsigned int i = bytes, sz = 0;
unsigned long flags;
- if (ppos != &file->f_pos)
- return -ESPIPE;
-
if (!access_ok (VERIFY_READ, buffer, bytes))
return -EFAULT;
unsigned int i = bytes, sz;
unsigned long flags;
- if (ppos != &file->f_pos)
- return -ESPIPE;
-
if (!access_ok (VERIFY_WRITE, buffer, bytes))
return -EFAULT;
static int __init
forte_proc_init (void)
{
- if (!proc_mkdir ("driver/forte", 0))
+ if (!proc_mkdir ("driver/forte", NULL))
return -EIO;
- if (!create_proc_read_entry ("driver/forte/chip", 0, 0, forte_proc_read, forte)) {
+ if (!create_proc_read_entry ("driver/forte/chip", 0, NULL, forte_proc_read, forte)) {
remove_proc_entry ("driver/forte", NULL);
return -EIO;
}
- if (!create_proc_read_entry("driver/forte/ac97", 0, 0, ac97_read_proc, forte->ac97)) {
+ if (!create_proc_read_entry("driver/forte/ac97", 0, NULL, ac97_read_proc, forte->ac97)) {
remove_proc_entry ("driver/forte/chip", NULL);
remove_proc_entry ("driver/forte", NULL);
return -EIO;
memset (chip, 0, sizeof (struct forte_chip));
chip->pci_dev = pci_dev;
- init_MUTEX(&chip->open_sem);
+ mutex_init(&chip->open_mutex);
spin_lock_init (&chip->lock);
spin_lock_init (&chip->ac97_lock);
chip->iobase = pci_resource_start (pci_dev, 0);
chip->irq = pci_dev->irq;
- if (request_irq (chip->irq, forte_interrupt, SA_SHIRQ, DRIVER_NAME,
+ if (request_irq (chip->irq, forte_interrupt, IRQF_SHARED, DRIVER_NAME,
chip)) {
printk (KERN_WARNING PFX "Unable to reserve IRQ");
ret = -EIO;
pci_set_drvdata (pci_dev, chip);
- printk (KERN_INFO PFX "FM801 chip found at 0x%04lX-0x%04lX IRQ %u\n",
- chip->iobase, pci_resource_end (pci_dev, 0), chip->irq);
+ printk (KERN_INFO PFX "FM801 chip found at 0x%04lX-0x%16llX IRQ %u\n",
+ chip->iobase, (unsigned long long)pci_resource_end (pci_dev, 0),
+ chip->irq);
/* Power it up */
if ((ret = forte_chip_init (chip)) == 0)
{
printk (KERN_INFO PFX DRIVER_VERSION "\n");
- if (!pci_register_driver (&forte_pci_driver)) {
- pci_unregister_driver (&forte_pci_driver);
- return -ENODEV;
- }
-
- return 0;
+ return pci_register_driver (&forte_pci_driver);
}