From: Kitae Kim Date: Thu, 18 Oct 2012 02:35:49 +0000 (+0900) Subject: maru_codec : change a way to register device from chrdrv to misc. X-Git-Tag: 2.2.1_release^2~88^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a216508ea8f628475c511a13759ce09bf4e37623;p=sdk%2Femulator%2Femulator-kernel.git maru_codec : change a way to register device from chrdrv to misc. As codec device changed a way to register device from chrdev to misc, codec device does not need to use fixed major and minor numbers. Signed-off-by : Kitae Kim --- diff --git a/drivers/maru/maru_codec.c b/drivers/maru/maru_codec.c index 18db34aea1ea..2fa7b1b5e46b 100644 --- a/drivers/maru/maru_codec.c +++ b/drivers/maru/maru_codec.c @@ -36,6 +36,7 @@ #include #include #include +#include #include #include #include @@ -44,8 +45,9 @@ #include #include #include +#include -#define DRIVER_NAME "codec" +#define DEVICE_NAME "codec" #define CODEC_MAJOR 240 MODULE_DESCRIPTION("Virtual Codec Device Driver"); @@ -53,7 +55,7 @@ MODULE_AUTHOR("Kitae KIM 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; } @@ -297,9 +299,18 @@ const struct file_operations svcodec_fops = { .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)); @@ -325,7 +336,7 @@ static int __devinit svcodec_probe(struct pci_dev *pci_dev, 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; } @@ -340,7 +351,7 @@ static int __devinit svcodec_probe(struct pci_dev *pci_dev, 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; } @@ -359,11 +370,18 @@ static int __devinit svcodec_probe(struct pci_dev *pci_dev, 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; @@ -412,6 +430,8 @@ static void __devinit svcodec_remove(struct pci_dev *pci_dev) kfree(svcodec); } + + misc_deregister(&codec_dev); pci_disable_device(pci_dev); } @@ -422,12 +442,13 @@ static struct pci_device_id svcodec_pci_table[] __devinitdata = { .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, diff --git a/ramfs/init b/ramfs/init index 9c6a3c1866a6..b109a0f3fd54 100644 --- a/ramfs/init +++ b/ramfs/init @@ -176,7 +176,6 @@ echo "create device filesystem" /bin/mkdir -p /new_root/sys #/bin/mknod /new_root/dev/opengl c 240 0 -/bin/mknod -m 666 /new_root/dev/codec c 240 0 >${CONSOLE} <${CONSOLE} 2>&1