Coccinelle release 1.0.0-rc1
[bpt/coccinelle.git] / tests / video_ver2.c
1 static int typhoon_ioctl(struct video_device *dev, unsigned int cmd, void *arg)
2 {
3 struct typhoon_device *typhoon = dev->priv;
4
5 switch (cmd) {
6 case VIDIOCGTUNER:
7 {
8 struct video_tuner v;
9 if (copy_from_user(&v, arg, sizeof(v)) != 0)
10 return -EFAULT;
11 if (v.tuner) /* Only 1 tuner */
12 return -EINVAL;
13 v.rangelow = 875 * 1600;
14 v.rangehigh = 1080 * 1600;
15 v.flags = VIDEO_TUNER_LOW;
16 v.mode = VIDEO_MODE_AUTO;
17 v.signal = 0xFFFF; /* We can't get the signal strength */
18 strcpy(v.name, "FM");
19 if (copy_to_user(arg, &v, sizeof(v)))
20 return -EFAULT;
21 return 0;
22 }
23 case VIDIOCSTUNER:
24 {
25 struct video_tuner v;
26 if (copy_from_user(&v, arg, sizeof(v)))
27 return -EFAULT;
28 if (v.tuner != 0)
29 return -EINVAL;
30 /* Only 1 tuner so no setting needed ! */
31 return 0;
32 }
33 case VIDIOCSFREQ:
34 if (copy_from_user(&typhoon->curfreq, arg,
35 sizeof(typhoon->curfreq)))
36 return -EFAULT;
37 typhoon_setfreq(typhoon, typhoon->curfreq);
38 return 0;
39 }
40 return -ENOIOCTLCMD;
41 }