+static int cegw_open(struct inode *inode, struct file *file)
+{
+ file->private_data = "greetings";
+
+ printk("cegw device opened\n");
+ return 0;
+}
+
+static int cegw_release(struct inode *inode, struct file *file)
+{
+ printk("cegw device released, data=%s\n", file->private_data);
+ return 0;
+}
+
+static long cegw_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
+{
+ switch (cmd) {
+ case CEGW_IOCTL_CAN_SOCK:
+ printk("ioctl can sock\n");
+ break;
+ case CEGW_IOCTL_UDP_SOCK:
+ printk("ioctl udp sock\n");
+ break;
+ default:
+ printk("undefined ioctl command\n");
+ break;
+ }
+
+ return 0;
+}
+
+static const struct file_operations cegw_fops = {
+ .owner = THIS_MODULE,
+ .open = cegw_open,
+ .release = cegw_release,
+ .unlocked_ioctl = cegw_ioctl
+};
+
+static struct miscdevice cegw_device = {
+ .minor = MISC_DYNAMIC_MINOR,
+ .name = "cegw",
+ .fops = &cegw_fops
+};
+