s390/ptrace: get rid of long longs in psw_bits
[linux/fpc-iii.git] / drivers / media / pci / cx23885 / cx23885-ioctl.c
blobd2cdd40f79f54611b9b6aa46ad7a0d5a9b00d9f0
1 /*
2 * Driver for the Conexant CX23885/7/8 PCIe bridge
4 * Various common ioctl() support functions
6 * Copyright (c) 2009 Andy Walls <awalls@md.metrocast.net>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
20 #include "cx23885.h"
21 #include "cx23885-ioctl.h"
23 #ifdef CONFIG_VIDEO_ADV_DEBUG
24 int cx23885_g_chip_info(struct file *file, void *fh,
25 struct v4l2_dbg_chip_info *chip)
27 struct cx23885_dev *dev = video_drvdata(file);
29 if (chip->match.addr > 1)
30 return -EINVAL;
31 if (chip->match.addr == 1) {
32 if (dev->v4l_device == NULL)
33 return -EINVAL;
34 strlcpy(chip->name, "cx23417", sizeof(chip->name));
35 } else {
36 strlcpy(chip->name, dev->v4l2_dev.name, sizeof(chip->name));
38 return 0;
41 static int cx23417_g_register(struct cx23885_dev *dev,
42 struct v4l2_dbg_register *reg)
44 u32 value;
46 if (dev->v4l_device == NULL)
47 return -EINVAL;
49 if ((reg->reg & 0x3) != 0 || reg->reg >= 0x10000)
50 return -EINVAL;
52 if (mc417_register_read(dev, (u16) reg->reg, &value))
53 return -EINVAL; /* V4L2 spec, but -EREMOTEIO really */
55 reg->size = 4;
56 reg->val = value;
57 return 0;
60 int cx23885_g_register(struct file *file, void *fh,
61 struct v4l2_dbg_register *reg)
63 struct cx23885_dev *dev = video_drvdata(file);
65 if (reg->match.addr > 1)
66 return -EINVAL;
67 if (reg->match.addr)
68 return cx23417_g_register(dev, reg);
70 if ((reg->reg & 0x3) != 0 || reg->reg >= pci_resource_len(dev->pci, 0))
71 return -EINVAL;
73 reg->size = 4;
74 reg->val = cx_read(reg->reg);
75 return 0;
78 static int cx23417_s_register(struct cx23885_dev *dev,
79 const struct v4l2_dbg_register *reg)
81 if (dev->v4l_device == NULL)
82 return -EINVAL;
84 if ((reg->reg & 0x3) != 0 || reg->reg >= 0x10000)
85 return -EINVAL;
87 if (mc417_register_write(dev, (u16) reg->reg, (u32) reg->val))
88 return -EINVAL; /* V4L2 spec, but -EREMOTEIO really */
89 return 0;
92 int cx23885_s_register(struct file *file, void *fh,
93 const struct v4l2_dbg_register *reg)
95 struct cx23885_dev *dev = video_drvdata(file);
97 if (reg->match.addr > 1)
98 return -EINVAL;
99 if (reg->match.addr)
100 return cx23417_s_register(dev, reg);
102 if ((reg->reg & 0x3) != 0 || reg->reg >= pci_resource_len(dev->pci, 0))
103 return -EINVAL;
105 cx_write(reg->reg, reg->val);
106 return 0;
108 #endif