请问一下,我的开发板完整的AD驱动程序为什么没有file_operations结构。<br />能不能帮忙解释一下,<br />驱动一般都有file_operations结构来定义接口函数的呀!<br />如:<br />struct file_operations scull_fops = { .owner = THIS_MODULE,<br /><br />.llseek = scull_llseek,<br /><br />.read = scull_read,<br /><br />.write = scull_write,<br /><br />.ioctl = scull_ioctl,<br /><br />.open = scull_open,<br /><br />.release = scull_release,};<br /><br /><br /><br />我把源码贴给大家看看:<br /><br />/*<br />* s3c2410-adc.c<br />*<br />* S3C2410 ADC <br />* exclusive with s3c2410-ts.c<br />*<br />* Author: SeonKon Choi <bushi@mizi.com><br />* Date : $Date: 2003/01/20 14:24:49 $ <br />*<br />* $Revision: 1.1.2.6 $<br />*<br /><br /> Fri Dec 03 2002 SeonKon Choi <bushi@mizi.com><br /> - initial<br /><br />*<br />* This file is subject to the terms and conditions of the GNU General Public<br />* License. See the file COPYING in the main directory of this archive<br />* for more details.<br />*/<br />#include <linux/config.h><br />#include <linux/module.h><br />#include <linux/kernel.h><br />#include <linux/init.h><br /><br />#include <linux/sched.h><br />#include <linux/irq.h><br />#include <linux/delay.h><br /><br />#include <asm/hardware.h><br />#include <asm/semaphore.h><br /><br />#undef DEBUG<br /><br />#ifdef DEBUG<br />#define DPRINTK(x...) {printk(__FUNCTION__"(%d): ",__LINE__);printk(##x);}<br />#else<br />#define DPRINTK(x...) (void)(0)<br />#endif<br /><br />#define START_ADC_AIN(x) <br />{ <br /> ADCCON = PRESCALE_EN | PRSCVL(255) | ADC_INPUT((x)) ; <br /> ADCCON |= ADC_START; <br />}<br /><br />static struct semaphore adc_lock;<br />static wait_queue_head_t *adc_wait;<br /><br />static void adcdone_int_handler(int irq, void *dev_id, struct pt_regs *reg)<br />{<br />wake_up(adc_wait);<br />}<br /><br />int s3c2410_adc_read(int ain, wait_queue_head_t *wait)<br />{<br />int ret = 0;<br /><br />if (down_interruptible(&adc_lock))<br /> return -ERESTARTSYS;<br /><br />adc_wait = wait;<br /><br />START_ADC_AIN(ain);<br />sleep_on_timeout(adc_wait, HZ/100); /* 10ms */<br /><br />#if 0<br />if (signal_pending(current)) {<br /> up(&adc_lock);<br /> return -ERESTARTSYS;<br />}<br />#endif<br /><br />ret = ADCDAT0 ;<br /><br />up(&adc_lock);<br /><br />adc_wait = NULL;<br /><br />DPRINTK("AIN[%d] = 0x%04x, %d
", ain, ret, ADCCON & 0x80 ? 1:0);<br /><br />return (ret & 0x3ff);<br />}<br /><br />int __init s3c2410_adc_init(void)<br />{<br />init_MUTEX(&adc_lock);<br /><br />/* normal ADC */<br />ADCTSC = 0; //XP_PST(NOP_MODE);<br /><br />if (request_irq(IRQ_ADC_DONE, adcdone_int_handler, SA_INTERRUPT,<br /> "ADC", NULL) < 0)<br /> goto irq_err;<br /><br />return 0;<br /><br />irq_err:<br /><br />return 1;<br />}<br /><br />module_init(s3c2410_adc_init);<br /><br />#ifdef MODULE<br />void __exit s3c2410_adc_exit(void)<br />{<br />free_irq(IRQ_ADC_DONE, NULL);<br />}<br /><br />module_exit(s3c2410_adc_exit);<br />MODULE_LICENSE("GPL");<br />#endif<br /> |
|