free(new_regs); 89. } 90. break; 91. 92. case IOCTL_REG_GET: 93. { 94. new_regs = (struct reg_data*)kmalloc(sizeof(struct reg_data), GFP_KERNEL); 95. if((ret_val = copy_from_user(new_regs, (struct reg_data*)ioctl_param, sizeof(struct reg_data))) != 0) 96. { 97. kfree(new_regs); 98. printk(KERN_ERR " error copy line_datafrom user.\n"); 99. return -1; 100. } 101. 102. //ret = ioread16(g_mkg_mem_base+new_regs->addr); 103. kfree(new_regs); 104. return ret; 105. } 106. break; 107. 108. } 109.#endif 110. 111. return -1; 112.} 113. 114.struct file_operations our_file_ops = { 115. .unlocked_ioctl = device_ioctl, 116. .read = device_read, 117. .write = device_write, 118. .open = device_open, 119. .release = device_release, 120. .owner = THIS_MODULE, 121.}; 122. 123.int init_module() 124.{ 125. int ret_val; 126. int ret; 127. void __iomem *ret_from_request; 128. int loop = 5; 129. 130. //=== Allocate character device 131. ret_val = register_chrdev(MAJOR_NUM, DEVICE_NAME, &our_file_ops); 132. if (ret_val < 0) 133. { 134. printk(KERN_ALERT " device %s failed(%d)\n", DEVICE_NAME, ret_val); 135. return ret_val; 136. } 137. 138. ret = check_mem_region(MKG_MEM_BASE, MKG_MEM_LEN); 139. if (ret < 0) 140. { 141. printk(KERN_ERR "mkg check_mem_region bussy error!\n"); 142. return -1; 143. } 144. 145. ret_from_reques上一页 [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] ... 下一页 >>
|