Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3f8d6f73 authored by Dean Anderson's avatar Dean Anderson Committed by Mauro Carvalho Chehab
Browse files

V4L/DVB (8317): Sensoray 2255 V4l driver checkpatch fixes



This patch fixes some coding style issues.
It also fixes a NULL de-reference on driver unload.
The permissions for the module parameters were changed to 0644.

Signed-off-by: default avatarDean Anderson <dean@sensoray.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@infradead.org>
parent 91a1d912
Loading
Loading
Loading
Loading
+35 −26
Original line number Original line Diff line number Diff line
@@ -275,6 +275,10 @@ struct s2255_fh {
	struct s2255_mode	mode;
	struct s2255_mode	mode;
};
};


/*
 * TODO: fixme S2255_MAX_USERS. Do not limit open driver handles.
 * Limit V4L to one stream at a time.
 */
#define S2255_MAX_USERS         1
#define S2255_MAX_USERS         1


#define CUR_USB_FWVER	774	/* current cypress EEPROM firmware version */
#define CUR_USB_FWVER	774	/* current cypress EEPROM firmware version */
@@ -329,11 +333,11 @@ static unsigned int vid_limit = 16; /* Video memory limit, in Mb */
/* start video number */
/* start video number */
static int video_nr = -1;	/* /dev/videoN, -1 for autodetect */
static int video_nr = -1;	/* /dev/videoN, -1 for autodetect */


module_param(debug, int, 0);
module_param(debug, int, 0644);
MODULE_PARM_DESC(debug, "Debug level(0-100) default 0");
MODULE_PARM_DESC(debug, "Debug level(0-100) default 0");
module_param(vid_limit, int, 0);
module_param(vid_limit, int, 0644);
MODULE_PARM_DESC(vid_limit, "video memory limit(Mb)");
MODULE_PARM_DESC(vid_limit, "video memory limit(Mb)");
module_param(video_nr, int, 0);
module_param(video_nr, int, 0644);
MODULE_PARM_DESC(video_nr, "start video minor(-1 default autodetect)");
MODULE_PARM_DESC(video_nr, "start video minor(-1 default autodetect)");


/* USB device table */
/* USB device table */
@@ -437,7 +441,10 @@ static int norm_minh(struct video_device *vdev)
}
}




/* converts 2255 planar format to yuyv or uyvy */
/*
 * TODO: fixme: move YUV reordering to hardware
 * converts 2255 planar format to yuyv or uyvy
 */
static void planar422p_to_yuv_packed(const unsigned char *in,
static void planar422p_to_yuv_packed(const unsigned char *in,
				     unsigned char *out,
				     unsigned char *out,
				     int width, int height,
				     int width, int height,
@@ -502,7 +509,7 @@ static void s2255_fwchunk_complete(struct urb *urb)
	struct usb_device *udev = urb->dev;
	struct usb_device *udev = urb->dev;
	int len;
	int len;
	dprintk(100, "udev %p urb %p", udev, urb);
	dprintk(100, "udev %p urb %p", udev, urb);

	/* TODO: fixme.  reflect change in status */
	if (urb->status) {
	if (urb->status) {
		dev_err(&udev->dev, "URB failed with status %d", urb->status);
		dev_err(&udev->dev, "URB failed with status %d", urb->status);
		return;
		return;
@@ -682,7 +689,7 @@ static int buffer_setup(struct videobuf_queue *vq, unsigned int *count,
	if (0 == *count)
	if (0 == *count)
		*count = S2255_DEF_BUFS;
		*count = S2255_DEF_BUFS;


	while (*size * *count > vid_limit * 1024 * 1024)
	while (*size * (*count) > vid_limit * 1024 * 1024)
		(*count)--;
		(*count)--;


	return 0;
	return 0;
@@ -789,7 +796,7 @@ static int res_get(struct s2255_dev *dev, struct s2255_fh *fh)


static int res_locked(struct s2255_dev *dev, struct s2255_fh *fh)
static int res_locked(struct s2255_dev *dev, struct s2255_fh *fh)
{
{
	return (dev->resources[fh->channel]);
	return dev->resources[fh->channel];
}
}


static void res_free(struct s2255_dev *dev, struct s2255_fh *fh)
static void res_free(struct s2255_dev *dev, struct s2255_fh *fh)
@@ -806,7 +813,8 @@ static int vidioc_querycap(struct file *file, void *priv,
	struct s2255_dev *dev = fh->dev;
	struct s2255_dev *dev = fh->dev;
	strlcpy(cap->driver, "s2255", sizeof(cap->driver));
	strlcpy(cap->driver, "s2255", sizeof(cap->driver));
	strlcpy(cap->card, "s2255", sizeof(cap->card));
	strlcpy(cap->card, "s2255", sizeof(cap->card));
	strlcpy(cap->bus_info, dev_name(&dev->udev->dev), sizeof(cap->bus_info));
	strlcpy(cap->bus_info, dev_name(&dev->udev->dev),
		sizeof(cap->bus_info));
	cap->version = S2255_VERSION;
	cap->version = S2255_VERSION;
	cap->capabilities = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_STREAMING;
	cap->capabilities = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_STREAMING;
	return 0;
	return 0;
@@ -839,8 +847,7 @@ static int vidioc_g_fmt_vid_cap(struct file *file, void *priv,
	f->fmt.pix.pixelformat = fh->fmt->fourcc;
	f->fmt.pix.pixelformat = fh->fmt->fourcc;
	f->fmt.pix.bytesperline = f->fmt.pix.width * (fh->fmt->depth >> 3);
	f->fmt.pix.bytesperline = f->fmt.pix.width * (fh->fmt->depth >> 3);
	f->fmt.pix.sizeimage = f->fmt.pix.height * f->fmt.pix.bytesperline;
	f->fmt.pix.sizeimage = f->fmt.pix.height * f->fmt.pix.bytesperline;

	return 0;
	return (0);
}
}


static int vidioc_try_fmt_vid_cap(struct file *file, void *priv,
static int vidioc_try_fmt_vid_cap(struct file *file, void *priv,
@@ -961,7 +968,7 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv,
	ret = vidioc_try_fmt_vid_cap(file, fh, f);
	ret = vidioc_try_fmt_vid_cap(file, fh, f);


	if (ret < 0)
	if (ret < 0)
		return (ret);
		return ret;


	fmt = format_by_fourcc(f->fmt.pix.pixelformat);
	fmt = format_by_fourcc(f->fmt.pix.pixelformat);


@@ -1336,7 +1343,7 @@ static int vidioc_enum_input(struct file *file, void *priv,
	inp->type = V4L2_INPUT_TYPE_CAMERA;
	inp->type = V4L2_INPUT_TYPE_CAMERA;
	inp->std = S2255_NORMS;
	inp->std = S2255_NORMS;
	strlcpy(inp->name, "Camera", sizeof(inp->name));
	strlcpy(inp->name, "Camera", sizeof(inp->name));
	return (0);
	return 0;
}
}


static int vidioc_g_input(struct file *file, void *priv, unsigned int *i)
static int vidioc_g_input(struct file *file, void *priv, unsigned int *i)
@@ -1360,7 +1367,7 @@ static int vidioc_queryctrl(struct file *file, void *priv,
	for (i = 0; i < ARRAY_SIZE(s2255_qctrl); i++)
	for (i = 0; i < ARRAY_SIZE(s2255_qctrl); i++)
		if (qc->id && qc->id == s2255_qctrl[i].id) {
		if (qc->id && qc->id == s2255_qctrl[i].id) {
			memcpy(qc, &(s2255_qctrl[i]), sizeof(*qc));
			memcpy(qc, &(s2255_qctrl[i]), sizeof(*qc));
			return (0);
			return 0;
		}
		}


	dprintk(4, "query_ctrl -EINVAL %d\n", qc->id);
	dprintk(4, "query_ctrl -EINVAL %d\n", qc->id);
@@ -1375,7 +1382,7 @@ static int vidioc_g_ctrl(struct file *file, void *priv,
	for (i = 0; i < ARRAY_SIZE(s2255_qctrl); i++)
	for (i = 0; i < ARRAY_SIZE(s2255_qctrl); i++)
		if (ctrl->id == s2255_qctrl[i].id) {
		if (ctrl->id == s2255_qctrl[i].id) {
			ctrl->value = qctl_regs[i];
			ctrl->value = qctl_regs[i];
			return (0);
			return 0;
		}
		}
	dprintk(4, "g_ctrl -EINVAL\n");
	dprintk(4, "g_ctrl -EINVAL\n");


@@ -1395,7 +1402,7 @@ static int vidioc_s_ctrl(struct file *file, void *priv,
		if (ctrl->id == s2255_qctrl[i].id) {
		if (ctrl->id == s2255_qctrl[i].id) {
			if (ctrl->value < s2255_qctrl[i].minimum ||
			if (ctrl->value < s2255_qctrl[i].minimum ||
			    ctrl->value > s2255_qctrl[i].maximum)
			    ctrl->value > s2255_qctrl[i].maximum)
				return (-ERANGE);
				return -ERANGE;


			qctl_regs[i] = ctrl->value;
			qctl_regs[i] = ctrl->value;
			/* update the mode to the corresponding value */
			/* update the mode to the corresponding value */
@@ -1571,6 +1578,11 @@ static void s2255_destroy(struct kref *kref)
		usb_free_urb(dev->fw_data->fw_urb);
		usb_free_urb(dev->fw_data->fw_urb);
		dev->fw_data->fw_urb = NULL;
		dev->fw_data->fw_urb = NULL;
	}
	}
	/*
	 * TODO: fixme(above, below): potentially leaving timers alive.
	 *                            do not ignore timeout below if
	 *                            it occurs.
	 */


	/* make sure we aren't waiting for the DSP */
	/* make sure we aren't waiting for the DSP */
	if (atomic_read(&dev->fw_data->fw_state) == S2255_FW_LOADED_DSPWAIT) {
	if (atomic_read(&dev->fw_data->fw_state) == S2255_FW_LOADED_DSPWAIT) {
@@ -1582,15 +1594,12 @@ static void s2255_destroy(struct kref *kref)
	}
	}


	if (dev->fw_data) {
	if (dev->fw_data) {
		if (dev->fw_data->fw)
			release_firmware(dev->fw_data->fw);
		kfree(dev->fw_data->pfw_data);
		kfree(dev->fw_data->pfw_data);
		kfree(dev->fw_data);
		kfree(dev->fw_data);
	}
	}


	if (dev->fw_data->fw) {
		release_firmware(dev->fw_data->fw);
		dev->fw_data->fw = NULL;
	}

	usb_put_dev(dev->udev);
	usb_put_dev(dev->udev);
	dprintk(1, "%s", __func__);
	dprintk(1, "%s", __func__);
	kfree(dev);
	kfree(dev);