[patch] v4l zoltrix radio driver fix

Gerd Knorr (kraxel@bytesex.org)
Wed, 10 Apr 2002 12:58:21 +0200


Hi,

This patch updates the zotrix radio driver to the videodev redesign
(2.5.7-preN), that one somehow didn't made it in (maybe I forgot to mail
it ...).

Gerd

==============================[ cut here ]==============================
# ChangeSet
# 1.586 02/04/08 10:02:38 kraxel@bytesex.org +1 -0
# adapt zotrix radio driver to pre 2.4.7 videodev redesign
#
# drivers/media/radio/radio-zoltrix.c
# 1.5 02/03/19 18:23:29 kraxel@bytesex.org +53 -72
# adapt zotrix radio driver to pre 2.4.7 videodev redesign
#
======================================================================
diff -Nru a/drivers/media/radio/radio-zoltrix.c b/drivers/media/radio/radio-zoltrix.c
--- a/drivers/media/radio/radio-zoltrix.c Mon Apr 8 10:17:54 2002
+++ b/drivers/media/radio/radio-zoltrix.c Mon Apr 8 10:17:54 2002
@@ -40,7 +40,6 @@

static int io = CONFIG_RADIO_ZOLTRIX_PORT;
static int radio_nr = -1;
-static int users = 0;

struct zol_device {
int port;
@@ -216,106 +215,93 @@
return 0;
}

-static int zol_ioctl(struct video_device *dev, unsigned int cmd, void *arg)
+static int zol_ioctl(struct inode *inode, struct file *file,
+ unsigned int cmd, void *arg)
{
+ struct video_device *dev = video_devdata(file);
struct zol_device *zol = dev->priv;

switch (cmd) {
case VIDIOCGCAP:
{
- struct video_capability v;
- v.type = VID_TYPE_TUNER;
- v.channels = 1 + zol->stereo;
- v.audios = 1;
- /* No we don't do pictures */
- v.maxwidth = 0;
- v.maxheight = 0;
- v.minwidth = 0;
- v.minheight = 0;
- strcpy(v.name, "Zoltrix Radio");
- if (copy_to_user(arg, &v, sizeof(v)))
- return -EFAULT;
+ struct video_capability *v = arg;
+
+ memset(v,0,sizeof(*v));
+ v->type = VID_TYPE_TUNER;
+ v->channels = 1 + zol->stereo;
+ v->audios = 1;
+ strcpy(v->name, "Zoltrix Radio");
return 0;
}
case VIDIOCGTUNER:
{
- struct video_tuner v;
- if (copy_from_user(&v, arg, sizeof(v)))
- return -EFAULT;
- if (v.tuner)
+ struct video_tuner *v = arg;
+ if (v->tuner)
return -EINVAL;
- strcpy(v.name, "FM");
- v.rangelow = (int) (88.0 * 16000);
- v.rangehigh = (int) (108.0 * 16000);
- v.flags = zol_is_stereo(zol)
+ strcpy(v->name, "FM");
+ v->rangelow = (int) (88.0 * 16000);
+ v->rangehigh = (int) (108.0 * 16000);
+ v->flags = zol_is_stereo(zol)
? VIDEO_TUNER_STEREO_ON : 0;
- v.flags |= VIDEO_TUNER_LOW;
- v.mode = VIDEO_MODE_AUTO;
- v.signal = 0xFFFF * zol_getsigstr(zol);
- if (copy_to_user(arg, &v, sizeof(v)))
- return -EFAULT;
+ v->flags |= VIDEO_TUNER_LOW;
+ v->mode = VIDEO_MODE_AUTO;
+ v->signal = 0xFFFF * zol_getsigstr(zol);
return 0;
}
case VIDIOCSTUNER:
{
- struct video_tuner v;
- if (copy_from_user(&v, arg, sizeof(v)))
- return -EFAULT;
- if (v.tuner != 0)
+ struct video_tuner *v = arg;
+ if (v->tuner != 0)
return -EINVAL;
/* Only 1 tuner so no setting needed ! */
return 0;
}
case VIDIOCGFREQ:
- if (copy_to_user(arg, &zol->curfreq, sizeof(zol->curfreq)))
- return -EFAULT;
+ {
+ unsigned long *freq = arg;
+ *freq = zol->curfreq;
return 0;
+ }
case VIDIOCSFREQ:
- if (copy_from_user(&zol->curfreq, arg, sizeof(zol->curfreq)))
- return -EFAULT;
+ {
+ unsigned long *freq = arg;
+ zol->curfreq = *freq;
zol_setfreq(zol, zol->curfreq);
return 0;
+ }
case VIDIOCGAUDIO:
{
- struct video_audio v;
- memset(&v, 0, sizeof(v));
- v.flags |= VIDEO_AUDIO_MUTABLE | VIDEO_AUDIO_VOLUME;
- v.mode != zol_is_stereo(zol)
+ struct video_audio *v = arg;
+ memset(&v, 0, sizeof(*v));
+ v->flags |= VIDEO_AUDIO_MUTABLE | VIDEO_AUDIO_VOLUME;
+ v->mode != zol_is_stereo(zol)
? VIDEO_SOUND_STEREO : VIDEO_SOUND_MONO;
- v.volume = zol->curvol * 4096;
- v.step = 4096;
- strcpy(v.name, "Zoltrix Radio");
- if (copy_to_user(arg, &v, sizeof(v)))
- return -EFAULT;
+ v->volume = zol->curvol * 4096;
+ v->step = 4096;
+ strcpy(v->name, "Zoltrix Radio");
return 0;
}
case VIDIOCSAUDIO:
{
- struct video_audio v;
- if (copy_from_user(&v, arg, sizeof(v)))
- return -EFAULT;
- if (v.audio)
+ struct video_audio *v = arg;
+ if (v->audio)
return -EINVAL;

- if (v.flags & VIDEO_AUDIO_MUTE)
+ if (v->flags & VIDEO_AUDIO_MUTE)
zol_mute(zol);
- else
- {
+ else {
zol_unmute(zol);
- zol_setvol(zol, v.volume / 4096);
+ zol_setvol(zol, v->volume / 4096);
}

- if (v.mode & VIDEO_SOUND_STEREO)
- {
+ if (v->mode & VIDEO_SOUND_STEREO) {
zol->stereo = 1;
zol_setfreq(zol, zol->curfreq);
}
- if (v.mode & VIDEO_SOUND_MONO)
- {
+ if (v->mode & VIDEO_SOUND_MONO) {
zol->stereo = 0;
zol_setfreq(zol, zol->curfreq);
}
-
return 0;
}
default:
@@ -323,20 +309,16 @@
}
}

-static int zol_open(struct video_device *dev, int flags)
-{
- if (users)
- return -EBUSY;
- users++;
- return 0;
-}
+static struct zol_device zoltrix_unit;

-static void zol_close(struct video_device *dev)
+static struct file_operations zoltrix_fops =
{
- users--;
-}
-
-static struct zol_device zoltrix_unit;
+ owner: THIS_MODULE,
+ open: video_exclusive_open,
+ release: video_exclusive_release,
+ ioctl: video_generic_ioctl,
+ llseek: no_llseek,
+};

static struct video_device zoltrix_radio =
{
@@ -344,9 +326,8 @@
name: "Zoltrix Radio Plus",
type: VID_TYPE_TUNER,
hardware: VID_HARDWARE_ZOLTRIX,
- open: zol_open,
- close: zol_close,
- ioctl: zol_ioctl,
+ fops: &zoltrix_fops,
+ kernel_ioctl: zol_ioctl,
};

static int __init zoltrix_init(void)
======================================================================
This BitKeeper patch contains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QU,I
M/YR^W'27$8GC]`;C57$8-:CZ?I/!'O*-,;9K=AV-K[=VG#UE.(K5F+HUU,B'
M)195_%7#PAP;'"K,!;%COC3P]OHEML.3_F_K<%/BTUI[VN_VAD>#R_Y:2R12
M,>K9[0>\L!A*.]8%*K!KDY8`=;D!Q)4_#BB\P.A4N\>`J.5QJOT+FFTXC*MA
MC/S.]%_;&.N?AA#!/*.?!^1N$[._4CQ9QG.>%>]A')3N;>)YZW@^,SWZ8C/T
M;8^&@[L]KCC_>E$'AF_J/VG_:#)'@^XQ3F!P>?3NI`?+'>GG_LG@M+<SLA??
M8(#O&`;X[0T#%FD\G^H'4*$`!RE9V]V,N=`S--B(GO,.M:6!H^T],?(GX%B-
MW&BP3L%H`QV7CZVZQ.3U8TAZQL.F>0HF2@_<"1J^D-PI(SFEG"8Y1.2Q2\($
M%]\&@I;ID*H7^)_*!&OOI#?(KK-?]`>?NL.+R]YYKU\SF;@P3EQ^S^FT_VGM
MXM-Z%[@W/?041,[5>E\!1M6N5N_J'!G.DZB@&H4TC9G'KA/MXV$ZTQD*TR3?
M>([2&:X&<G5I.$*TP;4JZ4U"_Z(KEQ^/+^@5'YST\)Q`]Z0#VZN<G+X-XGF.
M)QV%3]`LT[%6N>Y\RVRE1TMS3F&:TF*L,6D4E*<7:F,<EYYL$R;IL!35K:_4
M+*Y4@15+.@`KU,?#VEX_;!"#372&9T(9&^TJFV.ROOW''USK8)+/IX>V(Z7G
,!*[U-X>E`_I/#```
`
end
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/