#include <linux/io.h>
#include <linux/ioport.h>
#include <linux/kernel.h>
+#include <linux/miscdevice.h>
#include <linux/module.h>
#include <linux/pci.h>
#include <linux/types.h>
#include <linux/uaccess.h>
#include <linux/workqueue.h>
#include <linux/wait.h>
+#include <linux/slab.h>
-#define DRIVER_NAME "codec"
+#define DEVICE_NAME "codec"
#define CODEC_MAJOR 240
MODULE_DESCRIPTION("Virtual Codec Device Driver");
MODULE_LICENSE("GPL2");
#define CODEC_LOG(log_level, fmt, ...) \
- printk(log_level "%s: " fmt, DRIVER_NAME, ##__VA_ARGS__)
+ printk(log_level "%s: " fmt, DEVICE_NAME, ##__VA_ARGS__)
#define CODEC_IRQ 0x7f
/* register interrupt handler */
if (request_irq(svcodec->dev->irq, svcodec_irq_handler,
- IRQF_SHARED, DRIVER_NAME, svcodec)) {
+ IRQF_SHARED, DEVICE_NAME, svcodec)) {
CODEC_LOG(KERN_ERR, "failed to register irq handle\n");
return -EBUSY;
}
.release = svcodec_release,
};
+static struct miscdevice codec_dev = {
+ .minor = MISC_DYNAMIC_MINOR,
+ .name = DEVICE_NAME,
+ .fops = &svcodec_fops,
+ .mode = S_IRUGO | S_IWUGO,
+};
+
static int __devinit svcodec_probe(struct pci_dev *pci_dev,
const struct pci_device_id *pci_id)
{
+ int ret;
+
svcodec = kmalloc(sizeof(struct svcodec_device), GFP_KERNEL);
memset(svcodec, 0x00, sizeof(struct svcodec_device));
if (!request_mem_region(svcodec->mem_start,
svcodec->mem_size,
- DRIVER_NAME)) {
+ DEVICE_NAME)) {
CODEC_LOG(KERN_ERR, "request_mem_region failed\n");
goto err_out;
}
if (!request_mem_region(svcodec->io_start,
svcodec->io_size,
- DRIVER_NAME)) {
+ DEVICE_NAME)) {
CODEC_LOG(KERN_ERR, "request_io_region failed\n");
goto err_mem_region;
}
goto err_io_region;
}
+#if 0
/* register chrdev */
- if (register_chrdev(CODEC_MAJOR, DRIVER_NAME, &svcodec_fops)) {
+ if (register_chrdev(CODEC_MAJOR, DEVICE_NAME, &svcodec_fops)) {
CODEC_LOG(KERN_ERR, "register_chrdev failed\n");
goto err_io_unmap;
}
+#endif
+ ret = misc_register(&codec_dev);
+ if (ret) {
+ CODEC_LOG(KERN_ERR, "cannot register codec as misc\n");
+ goto err_io_unmap;
+ }
return 0;
kfree(svcodec);
}
+
+ misc_deregister(&codec_dev);
pci_disable_device(pci_dev);
}
.subvendor = PCI_ANY_ID,
.subdevice = PCI_ANY_ID,
},
+ {},
};
MODULE_DEVICE_TABLE(pci, svcodec_pci_table);
/* define PCI Driver for CODEC */
static struct pci_driver driver = {
- .name = DRIVER_NAME,
+ .name = DEVICE_NAME,
.id_table = svcodec_pci_table,
.probe = svcodec_probe,
.remove = svcodec_remove,