/* search a mode with the right pixel format  */
static int gspca_get_mode(struct gspca_dev *gspca_dev, int mode, int pixfmt)
/* search a mode with the right pixel format  */
static int gspca_get_mode(struct gspca_dev *gspca_dev, int mode, int pixfmt)
{
	int modeU, modeD;
	modeU = modeD = mode;
	while ((modeU < gspca_dev->cam.nmodes) || modeD >= 0) {
		if (--modeD >= 0) {
			if (gspca_dev->cam.cam_mode[modeD].pixelformat
								== pixfmt)
				return modeD;
		}
		if (++modeU < gspca_dev->cam.nmodes) {
			if (gspca_dev->cam.cam_mode[modeU].pixelformat
								== pixfmt)
				return modeU;
		}
	}
	return -EINVAL;
}