diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c
index 297e95be25b3..1e0af19986e9 100644
--- a/drivers/base/regmap/regmap.c
+++ b/drivers/base/regmap/regmap.c
@@ -663,7 +663,9 @@ enum regmap_endian regmap_get_val_endian(struct device *dev,
 					 const struct regmap_bus *bus,
 					 const struct regmap_config *config)
 {
+#if IS_ENABLED(CONFIG_OF)
 	struct fwnode_handle *fwnode = dev ? dev_fwnode(dev) : NULL;
+#endif
 	enum regmap_endian endian;
 
 	/* Retrieve the endianness specification from the regmap config */
@@ -673,6 +675,7 @@ enum regmap_endian regmap_get_val_endian(struct device *dev,
 	if (endian != REGMAP_ENDIAN_DEFAULT)
 		return endian;
 
+#if IS_ENABLED(CONFIG_OF)
 	/* If the firmware node exist try to get endianness from it */
 	if (fwnode_property_read_bool(fwnode, "big-endian"))
 		endian = REGMAP_ENDIAN_BIG;
@@ -680,7 +683,7 @@ enum regmap_endian regmap_get_val_endian(struct device *dev,
 		endian = REGMAP_ENDIAN_LITTLE;
 	else if (fwnode_property_read_bool(fwnode, "native-endian"))
 		endian = REGMAP_ENDIAN_NATIVE;
-
+#endif
 	/* If the endianness was specified in fwnode, use that */
 	if (endian != REGMAP_ENDIAN_DEFAULT)
 		return endian;
diff --git a/drivers/hid/hid-asus.c b/drivers/hid/hid-asus.c
index 2ab22b925941..d5ad67f1b153 100644
--- a/drivers/hid/hid-asus.c
+++ b/drivers/hid/hid-asus.c
@@ -513,12 +513,10 @@ static void asus_kbd_backlight_work(struct work_struct *work)
  */
 static bool asus_kbd_wmi_led_control_present(struct hid_device *hdev)
 {
+#if IS_ENABLED(CONFIG_ASUS_WMI)
 	u32 value;
 	int ret;
 
-	if (!IS_ENABLED(CONFIG_ASUS_WMI))
-		return false;
-
 	ret = asus_wmi_evaluate_method(ASUS_WMI_METHODID_DSTS,
 				       ASUS_WMI_DEVID_KBD_BACKLIGHT, 0, &value);
 	hid_dbg(hdev, "WMI backlight check: rc %d value %x", ret, value);
@@ -526,6 +524,9 @@ static bool asus_kbd_wmi_led_control_present(struct hid_device *hdev)
 		return false;
 
 	return !!(value & ASUS_WMI_DSTS_PRESENCE_BIT);
+#else
+	return false;
+#endif
 }
 
 static int asus_kbd_register_leds(struct hid_device *hdev)
diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index 0ae9f6df59d1..2c574fa20e33 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -2509,7 +2509,7 @@ void hid_destroy_device(struct hid_device *hdev)
 }
 EXPORT_SYMBOL_GPL(hid_destroy_device);
 
-
+#if 0
 static int __hid_bus_reprobe_drivers(struct device *dev, void *data)
 {
 	struct hid_driver *hdrv = data;
@@ -2539,6 +2539,7 @@ static int __bus_removed_driver(struct device_driver *drv, void *data)
 {
 	return bus_rescan_devices(&hid_bus_type);
 }
+#endif
 
 int __hid_register_driver(struct hid_driver *hdrv, struct module *owner,
 		const char *mod_name)
@@ -2555,9 +2556,11 @@ int __hid_register_driver(struct hid_driver *hdrv, struct module *owner,
 
 	ret = driver_register(&hdrv->driver);
 
+#if 0
 	if (ret == 0)
 		bus_for_each_drv(&hid_bus_type, NULL, NULL,
 				 __hid_bus_driver_added);
+#endif
 
 	return ret;
 }
@@ -2568,7 +2571,9 @@ void hid_unregister_driver(struct hid_driver *hdrv)
 	driver_unregister(&hdrv->driver);
 	hid_free_dynids(hdrv);
 
+#if 0
 	bus_for_each_drv(&hid_bus_type, NULL, hdrv, __bus_removed_driver);
+#endif
 }
 EXPORT_SYMBOL_GPL(hid_unregister_driver);
 
diff --git a/drivers/hid/hid-multitouch.c b/drivers/hid/hid-multitouch.c
index 9d9f3e1bd5f4..476e8791edce 100644
--- a/drivers/hid/hid-multitouch.c
+++ b/drivers/hid/hid-multitouch.c
@@ -129,7 +129,7 @@ struct mt_application {
 				 */
 
 	__s32 dev_time;		/* the scan time provided by the device */
-	unsigned long jiffies;	/* the frame's jiffies */
+	unsigned long jfs;	/* the frame's jiffies */
 	int timestamp;		/* the timestamp to be sent */
 	int prev_scantime;		/* scantime reported previously */
 
@@ -942,9 +942,9 @@ static void mt_sync_frame(struct mt_device *td, struct mt_application *app,
 static int mt_compute_timestamp(struct mt_application *app, __s32 value)
 {
 	long delta = value - app->prev_scantime;
-	unsigned long jdelta = jiffies_to_usecs(jiffies - app->jiffies);
+	unsigned long jdelta = jiffies_to_usecs(jiffies - app->jfs);
 
-	app->jiffies = jiffies;
+	app->jfs = jiffies;
 
 	if (delta < 0)
 		delta += app->scantime_logical_max;
diff --git a/drivers/hid/wacom.h b/drivers/hid/wacom.h
index 203d27d198b8..463efcad9c5b 100644
--- a/drivers/hid/wacom.h
+++ b/drivers/hid/wacom.h
@@ -91,6 +91,7 @@
 #include <linux/leds.h>
 #include <linux/usb/input.h>
 #include <linux/power_supply.h>
+#include <linux/string.h>
 #include <asm/unaligned.h>
 
 /*
diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c
index 95f90699d2b1..c0fde2b92bd5 100644
--- a/drivers/input/evdev.c
+++ b/drivers/input/evdev.c
@@ -766,7 +766,7 @@ static int str_to_user(const char *str, unsigned int maxlen, void __user *p)
 	int len;
 
 	if (!str)
-		return -ENOENT;
+		str = "";
 
 	len = strlen(str) + 1;
 	if (len > maxlen)
diff --git a/drivers/leds/led-core.c b/drivers/leds/led-core.c
index 8eb8054ef9c6..f616c1068ccc 100644
--- a/drivers/leds/led-core.c
+++ b/drivers/leds/led-core.c
@@ -320,6 +320,7 @@ EXPORT_SYMBOL_GPL(led_update_brightness);
 
 u32 *led_get_default_pattern(struct led_classdev *led_cdev, unsigned int *size)
 {
+#if IS_ENABLED(CONFIG_OF)
 	struct fwnode_handle *fwnode = led_cdev->dev->fwnode;
 	u32 *pattern;
 	int count;
@@ -340,6 +341,9 @@ u32 *led_get_default_pattern(struct led_classdev *led_cdev, unsigned int *size)
 	*size = count;
 
 	return pattern;
+#else
+	return NULL;
+#endif
 }
 EXPORT_SYMBOL_GPL(led_get_default_pattern);
 
@@ -361,6 +365,7 @@ void led_sysfs_enable(struct led_classdev *led_cdev)
 }
 EXPORT_SYMBOL_GPL(led_sysfs_enable);
 
+#if IS_ENABLED(CONFIG_OF)
 static void led_parse_fwnode_props(struct device *dev,
 				   struct fwnode_handle *fwnode,
 				   struct led_properties *props)
@@ -411,12 +416,15 @@ static void led_parse_fwnode_props(struct device *dev,
 		props->func_enum_present = true;
 	}
 }
+#endif
 
 int led_compose_name(struct device *dev, struct led_init_data *init_data,
 		     char *led_classdev_name)
 {
 	struct led_properties props = {};
+#if IS_ENABLED(CONFIG_OF)
 	struct fwnode_handle *fwnode = init_data->fwnode;
+#endif
 	const char *devicename = init_data->devicename;
 
 	/* We want to label LEDs that can produce full range of colors
@@ -426,7 +434,9 @@ int led_compose_name(struct device *dev, struct led_init_data *init_data,
 	if (!led_classdev_name)
 		return -EINVAL;
 
+#if IS_ENABLED(CONFIG_OF)
 	led_parse_fwnode_props(dev, fwnode, &props);
+#endif
 
 	if (props.label) {
 		/*
@@ -468,9 +478,11 @@ int led_compose_name(struct device *dev, struct led_init_data *init_data,
 		}
 		snprintf(led_classdev_name, LED_MAX_NAME_SIZE, "%s:%s",
 			 devicename, init_data->default_label);
+#if IS_ENABLED(CONFIG_OF)
 	} else if (is_of_node(fwnode)) {
 		strscpy(led_classdev_name, to_of_node(fwnode)->name,
 			LED_MAX_NAME_SIZE);
+#endif
 	} else
 		return -EINVAL;
 
diff --git a/drivers/media/common/videobuf2/Makefile b/drivers/media/common/videobuf2/Makefile
index 54306f8d096c..f51ce82ce34e 100644
--- a/drivers/media/common/videobuf2/Makefile
+++ b/drivers/media/common/videobuf2/Makefile
@@ -1,6 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0
 videobuf2-common-objs := videobuf2-core.o
-videobuf2-common-objs += frame_vector.o
+# videobuf2-common-objs += frame_vector.o
 
 ifeq ($(CONFIG_TRACEPOINTS),y)
   videobuf2-common-objs += vb2-trace.o
diff --git a/drivers/media/common/videobuf2/videobuf2-core.c b/drivers/media/common/videobuf2/videobuf2-core.c
index 02281d13505f..4297324951e7 100644
--- a/drivers/media/common/videobuf2/videobuf2-core.c
+++ b/drivers/media/common/videobuf2/videobuf2-core.c
@@ -689,7 +689,7 @@ static int __verify_dmabuf_ops(struct vb2_queue *q)
 int vb2_verify_memory_type(struct vb2_queue *q,
 		enum vb2_memory memory, unsigned int type)
 {
-	if (memory != VB2_MEMORY_MMAP && memory != VB2_MEMORY_USERPTR &&
+	if (memory != VB2_MEMORY_MMAP && /* memory != VB2_MEMORY_USERPTR && */
 	    memory != VB2_MEMORY_DMABUF) {
 		dprintk(q, 1, "unsupported memory type\n");
 		return -EINVAL;
@@ -708,12 +708,12 @@ int vb2_verify_memory_type(struct vb2_queue *q,
 		dprintk(q, 1, "MMAP for current setup unsupported\n");
 		return -EINVAL;
 	}
-
+#if 0
 	if (memory == VB2_MEMORY_USERPTR && __verify_userptr_ops(q)) {
 		dprintk(q, 1, "USERPTR for current setup unsupported\n");
 		return -EINVAL;
 	}
-
+#endif
 	if (memory == VB2_MEMORY_DMABUF && __verify_dmabuf_ops(q)) {
 		dprintk(q, 1, "DMABUF for current setup unsupported\n");
 		return -EINVAL;
@@ -1363,9 +1363,11 @@ static int __buf_prepare(struct vb2_buffer *vb)
 	case VB2_MEMORY_MMAP:
 		ret = __prepare_mmap(vb);
 		break;
+#if 0
 	case VB2_MEMORY_USERPTR:
 		ret = __prepare_userptr(vb);
 		break;
+#endif
 	case VB2_MEMORY_DMABUF:
 		ret = __prepare_dmabuf(vb);
 		break;
diff --git a/drivers/media/common/videobuf2/videobuf2-memops.c b/drivers/media/common/videobuf2/videobuf2-memops.c
index 9dd6c27162f4..3bbf3dc7d9f9 100644
--- a/drivers/media/common/videobuf2/videobuf2-memops.c
+++ b/drivers/media/common/videobuf2/videobuf2-memops.c
@@ -22,6 +22,7 @@
 #include <media/videobuf2-v4l2.h>
 #include <media/videobuf2-memops.h>
 
+#if 0
 /**
  * vb2_create_framevec() - map virtual addresses to pfns
  * @start:	Virtual user address where we start mapping
@@ -63,7 +64,9 @@ struct frame_vector *vb2_create_framevec(unsigned long start,
 	return ERR_PTR(ret);
 }
 EXPORT_SYMBOL(vb2_create_framevec);
+#endif
 
+#if 0
 /**
  * vb2_destroy_framevec() - release vector of mapped pfns
  * @vec:	vector of pfns / pages to release
@@ -77,6 +80,7 @@ void vb2_destroy_framevec(struct frame_vector *vec)
 	frame_vector_destroy(vec);
 }
 EXPORT_SYMBOL(vb2_destroy_framevec);
+#endif
 
 /**
  * vb2_common_vm_open() - increase refcount of the vma
diff --git a/drivers/media/common/videobuf2/videobuf2-vmalloc.c b/drivers/media/common/videobuf2/videobuf2-vmalloc.c
index 83f95258ec8c..a8a29d4bdc70 100644
--- a/drivers/media/common/videobuf2/videobuf2-vmalloc.c
+++ b/drivers/media/common/videobuf2/videobuf2-vmalloc.c
@@ -71,6 +71,7 @@ static void vb2_vmalloc_put(void *buf_priv)
 	}
 }
 
+#if 0
 static void *vb2_vmalloc_get_userptr(struct device *dev, unsigned long vaddr,
 				     unsigned long size,
 				     enum dma_data_direction dma_dir)
@@ -146,6 +147,10 @@ static void vb2_vmalloc_put_userptr(void *buf_priv)
 	vb2_destroy_framevec(buf->vec);
 	kfree(buf);
 }
+#else
+#define	vb2_vmalloc_get_userptr NULL
+#define	vb2_vmalloc_put_userptr NULL
+#endif
 
 static void *vb2_vmalloc_vaddr(void *buf_priv)
 {
diff --git a/drivers/media/dvb-core/dvb_frontend.c b/drivers/media/dvb-core/dvb_frontend.c
index a6915582d1a6..49224a61da2b 100644
--- a/drivers/media/dvb-core/dvb_frontend.c
+++ b/drivers/media/dvb-core/dvb_frontend.c
@@ -2067,6 +2067,8 @@ static int dvb_frontend_do_ioctl(struct file *file, unsigned int cmd,
 	 * reading from them would interfere with a DVB tune application
 	 */
 	if ((file->f_flags & O_ACCMODE) == O_RDONLY
+	    && (cmd != FE_GET_PROPERTY)
+	    && (cmd != FE_GET_PROPERTY_OLD)
 	    && (_IOC_DIR(cmd) != _IOC_READ
 		|| cmd == FE_GET_EVENT
 		|| cmd == FE_DISEQC_RECV_SLAVE_REPLY)) {
@@ -2443,6 +2445,7 @@ static int dvb_frontend_handle_ioctl(struct file *file,
 		err = 0;
 		break;
 	}
+	case FE_GET_PROPERTY_OLD:
 	case FE_GET_PROPERTY:
 		err = dvb_get_property(fe, file, parg);
 		break;
diff --git a/drivers/media/dvb-frontends/cx24120.c b/drivers/media/dvb-frontends/cx24120.c
index d8acd582c711..f004d9965d4a 100644
--- a/drivers/media/dvb-frontends/cx24120.c
+++ b/drivers/media/dvb-frontends/cx24120.c
@@ -103,6 +103,8 @@ enum command_message_id {
 #define CX24120_BER_WINDOW	16
 #define CX24120_BER_WSIZE	((1 << CX24120_BER_WINDOW) * 208 * 8)
 
+#undef info
+#undef err
 #define info(args...) pr_info("cx24120: " args)
 #define err(args...)  pr_err("cx24120: ### ERROR: " args)
 
diff --git a/drivers/media/dvb-frontends/cx24123.c b/drivers/media/dvb-frontends/cx24123.c
index 3d84ee17e54c..4f5efe9dbc5e 100644
--- a/drivers/media/dvb-frontends/cx24123.c
+++ b/drivers/media/dvb-frontends/cx24123.c
@@ -29,6 +29,8 @@ static int debug;
 module_param(debug, int, 0644);
 MODULE_PARM_DESC(debug, "Activates frontend debugging (default:0)");
 
+#undef info
+#undef err
 #define info(args...) do { printk(KERN_INFO "CX24123: " args); } while (0)
 #define err(args...)  do { printk(KERN_ERR  "CX24123: " args); } while (0)
 
diff --git a/drivers/media/dvb-frontends/m88rs2000.c b/drivers/media/dvb-frontends/m88rs2000.c
index b294ba87e934..2145757f642c 100644
--- a/drivers/media/dvb-frontends/m88rs2000.c
+++ b/drivers/media/dvb-frontends/m88rs2000.c
@@ -45,6 +45,7 @@ MODULE_PARM_DESC(debug, "set debugging level (1=info (or-able)).");
 } while (0)
 
 #define deb_info(args...)  dprintk(0x01, args)
+#undef info
 #define info(format, arg...) \
 	printk(KERN_INFO "m88rs2000-fe: " format "\n" , ## arg)
 
diff --git a/drivers/media/dvb-frontends/tda18271c2dd.c b/drivers/media/dvb-frontends/tda18271c2dd.c
index a34834487943..2a7d7e80ca49 100644
--- a/drivers/media/dvb-frontends/tda18271c2dd.c
+++ b/drivers/media/dvb-frontends/tda18271c2dd.c
@@ -1091,7 +1091,7 @@ static int ChannelConfiguration(struct tda_state *state,
 	return status;
 }
 
-static int sleep(struct dvb_frontend *fe)
+static int do_sleep(struct dvb_frontend *fe)
 {
 	struct tda_state *state = fe->tuner_priv;
 
@@ -1203,7 +1203,7 @@ static const struct dvb_tuner_ops tuner_ops = {
 		.frequency_step_hz =  62500
 	},
 	.init              = init,
-	.sleep             = sleep,
+	.sleep             = do_sleep,
 	.set_params        = set_params,
 	.release           = release,
 	.get_if_frequency  = get_if_frequency,
diff --git a/drivers/media/i2c/adv7343.c b/drivers/media/i2c/adv7343.c
index 63e94dfcb5d3..667aba0894cd 100644
--- a/drivers/media/i2c/adv7343.c
+++ b/drivers/media/i2c/adv7343.c
@@ -397,6 +397,7 @@ static int adv7343_initialize(struct v4l2_subdev *sd)
 static struct adv7343_platform_data *
 adv7343_get_pdata(struct i2c_client *client)
 {
+#if IS_ENABLED(CONFIG_OF)
 	struct adv7343_platform_data *pdata;
 	struct device_node *np;
 
@@ -426,6 +427,9 @@ adv7343_get_pdata(struct i2c_client *client)
 done:
 	of_node_put(np);
 	return pdata;
+#else
+	return client->dev.platform_data;
+#endif
 }
 
 static int adv7343_probe(struct i2c_client *client)
diff --git a/drivers/media/i2c/tvp514x.c b/drivers/media/i2c/tvp514x.c
index a7fbe5b400c2..1893aeedc336 100644
--- a/drivers/media/i2c/tvp514x.c
+++ b/drivers/media/i2c/tvp514x.c
@@ -979,6 +979,7 @@ static const struct tvp514x_decoder tvp514x_dev = {
 static struct tvp514x_platform_data *
 tvp514x_get_pdata(struct i2c_client *client)
 {
+#if IS_ENABLED(CONFIG_OF)
 	struct tvp514x_platform_data *pdata = NULL;
 	struct v4l2_fwnode_endpoint bus_cfg = { .bus_type = 0 };
 	struct device_node *endpoint;
@@ -1012,6 +1013,9 @@ tvp514x_get_pdata(struct i2c_client *client)
 done:
 	of_node_put(endpoint);
 	return pdata;
+#else
+	return client->dev.platform_data;
+#endif
 }
 
 /**
@@ -1206,7 +1210,9 @@ MODULE_DEVICE_TABLE(of, tvp514x_of_match);
 
 static struct i2c_driver tvp514x_driver = {
 	.driver = {
+#if IS_ENABLED(CONFIG_OF)
 		.of_match_table = of_match_ptr(tvp514x_of_match),
+#endif
 		.name = TVP514X_MODULE_NAME,
 	},
 	.probe = tvp514x_probe,
diff --git a/drivers/media/i2c/tvp5150.c b/drivers/media/i2c/tvp5150.c
index e26e3f544054..c86bc1142e2d 100644
--- a/drivers/media/i2c/tvp5150.c
+++ b/drivers/media/i2c/tvp5150.c
@@ -1994,6 +1994,7 @@ static int tvp5150_validate_connectors(struct tvp5150 *decoder)
 	return 0;
 }
 
+#if IS_ENABLED(CONFIG_OF)
 static int tvp5150_parse_dt(struct tvp5150 *decoder, struct device_node *np)
 {
 	struct device *dev = decoder->sd.dev;
@@ -2105,11 +2106,13 @@ static int tvp5150_parse_dt(struct tvp5150 *decoder, struct device_node *np)
 err_put:
 	of_node_put(ep_np);
 err_free:
+#if IS_ENABLED(CONFIG_OF)
 	for (i = 0; i < TVP5150_MAX_CONNECTORS; i++)
 		v4l2_fwnode_connector_free(&decoder->connectors[i].base);
-
+#endif
 	return ret;
 }
+#endif
 
 static const char * const tvp5150_test_patterns[2] = {
 	"Disabled",
@@ -2120,7 +2123,9 @@ static int tvp5150_probe(struct i2c_client *c)
 {
 	struct tvp5150 *core;
 	struct v4l2_subdev *sd;
+#if IS_ENABLED(CONFIG_OF)
 	struct device_node *np = c->dev.of_node;
+#endif
 	struct regmap *map;
 	unsigned int i;
 	int res;
@@ -2148,7 +2153,8 @@ static int tvp5150_probe(struct i2c_client *c)
 	sd->internal_ops = &tvp5150_internal_ops;
 	sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE | V4L2_SUBDEV_FL_HAS_EVENTS;
 
-	if (IS_ENABLED(CONFIG_OF) && np) {
+#if IS_ENABLED(CONFIG_OF)
+	if (np) {
 		res = tvp5150_parse_dt(core, np);
 		if (res) {
 			dev_err(sd->dev, "DT parsing error: %d\n", res);
@@ -2158,6 +2164,10 @@ static int tvp5150_probe(struct i2c_client *c)
 		/* Default to BT.656 embedded sync */
 		core->mbus_type = V4L2_MBUS_BT656;
 	}
+#else
+	/* Default to BT.656 embedded sync */
+	core->mbus_type = V4L2_MBUS_BT656;
+#endif
 
 	res = tvp5150_mc_init(core);
 	if (res)
@@ -2213,11 +2223,16 @@ static int tvp5150_probe(struct i2c_client *c)
 	core->irq = c->irq;
 	tvp5150_reset(sd, 0);	/* Calls v4l2_ctrl_handler_setup() */
 	if (c->irq) {
+#if 0
 		res = devm_request_threaded_irq(&c->dev, c->irq, NULL,
 						tvp5150_isr, IRQF_TRIGGER_HIGH |
 						IRQF_ONESHOT, "tvp5150", core);
 		if (res)
 			goto err;
+#else
+		res = -EINVAL;
+		goto err;
+#endif
 	}
 
 	res = v4l2_async_register_subdev(sd);
@@ -2248,12 +2263,16 @@ static int tvp5150_remove(struct i2c_client *c)
 		"tvp5150.c: removing tvp5150 adapter on address 0x%x\n",
 		c->addr << 1);
 
+#if IS_ENABLED(CONFIG_OF)
 	for (i = 0; i < decoder->connectors_num; i++)
 		v4l2_fwnode_connector_free(&decoder->connectors[i].base);
+#endif
+#if defined(CONFIG_MEDIA_CONTROLLER)
 	for (i = 0; i < decoder->connectors_num; i++) {
 		media_device_unregister_entity(&decoder->connectors[i].ent);
 		media_entity_cleanup(&decoder->connectors[i].ent);
 	}
+#endif
 	v4l2_async_unregister_subdev(sd);
 	v4l2_ctrl_handler_free(&decoder->hdl);
 	pm_runtime_disable(&c->dev);
diff --git a/drivers/media/i2c/tvp7002.c b/drivers/media/i2c/tvp7002.c
index ada4ec5ef782..a46d93d8bf39 100644
--- a/drivers/media/i2c/tvp7002.c
+++ b/drivers/media/i2c/tvp7002.c
@@ -882,6 +882,7 @@ static const struct v4l2_subdev_ops tvp7002_ops = {
 static struct tvp7002_config *
 tvp7002_get_pdata(struct i2c_client *client)
 {
+#if IS_ENABLED(CONFIG_OF)
 	struct v4l2_fwnode_endpoint bus_cfg = { .bus_type = 0 };
 	struct tvp7002_config *pdata = NULL;
 	struct device_node *endpoint;
@@ -921,6 +922,9 @@ tvp7002_get_pdata(struct i2c_client *client)
 done:
 	of_node_put(endpoint);
 	return pdata;
+#else
+	return client->dev.platform_data;
+#endif
 }
 
 /*
@@ -1074,7 +1078,9 @@ MODULE_DEVICE_TABLE(of, tvp7002_of_match);
 /* I2C driver data */
 static struct i2c_driver tvp7002_driver = {
 	.driver = {
+#if IS_ENABLED(CONFIG_OF)
 		.of_match_table = of_match_ptr(tvp7002_of_match),
+#endif
 		.name = TVP7002_MODULE_NAME,
 	},
 	.probe_new = tvp7002_probe,
diff --git a/drivers/media/rc/lirc_dev.c b/drivers/media/rc/lirc_dev.c
index 116daf90c858..d78416b2e33d 100644
--- a/drivers/media/rc/lirc_dev.c
+++ b/drivers/media/rc/lirc_dev.c
@@ -823,6 +823,7 @@ void __exit lirc_dev_exit(void)
 	unregister_chrdev_region(lirc_base_dev, RC_DEV_MAX);
 }
 
+#if 0
 struct rc_dev *rc_dev_get_from_fd(int fd)
 {
 	struct fd f = fdget(fd);
@@ -845,5 +846,6 @@ struct rc_dev *rc_dev_get_from_fd(int fd)
 
 	return dev;
 }
+#endif
 
 MODULE_ALIAS("lirc_dev");
diff --git a/drivers/media/rc/rc-main.c b/drivers/media/rc/rc-main.c
index 8e88dc8ea6c5..1d0bfcbe7b73 100644
--- a/drivers/media/rc/rc-main.c
+++ b/drivers/media/rc/rc-main.c
@@ -1887,6 +1887,12 @@ static void rc_free_rx_device(struct rc_dev *dev)
 	ir_free_table(&dev->rc_map);
 }
 
+static char *rc_core_default_protocol;
+module_param_named(default_protocol, rc_core_default_protocol, charp, 0644);
+MODULE_PARM_DESC(default_protocol, "Select default protocol: "
+    "jvc, lirc, mce_kbd, nec, none, other, rc-5, rc-5-sz, "
+    "rc-6, sanyo, sharp, sony, unknown or xmp");
+
 int rc_register_device(struct rc_dev *dev)
 {
 	const char *path;
@@ -1966,6 +1972,15 @@ int rc_register_device(struct rc_dev *dev)
 	dev_dbg(&dev->dev, "Registered rc%u (driver: %s)\n", dev->minor,
 		dev->driver_name ? dev->driver_name : "unknown");
 
+	if (rc_core_default_protocol != NULL) {
+		/* set initial default protocol */
+		if (store_protocols(&dev->dev, &dev_attr_protocols,
+		    rc_core_default_protocol,
+		    strlen(rc_core_default_protocol)) < 0) {
+			printk(KERN_ERR "Could not store protocol '%s'\n",
+			    rc_core_default_protocol);
+		}
+	}
 	return 0;
 
 out_rx:
diff --git a/drivers/media/usb/as102/as102_drv.h b/drivers/media/usb/as102/as102_drv.h
index 4342c7ce3407..a790077b44a5 100644
--- a/drivers/media/usb/as102/as102_drv.h
+++ b/drivers/media/usb/as102/as102_drv.h
@@ -23,8 +23,8 @@ extern int elna_enable;
 
 #define AS102_DEVICE_MAJOR	192
 
-#define AS102_USB_BUF_SIZE	512
-#define MAX_STREAM_URB		32
+#define AS102_USB_BUF_SIZE	(1 << 14)
+#define MAX_STREAM_URB		2
 
 struct as10x_bus_adapter_t {
 	struct usb_device *usb_dev;
diff --git a/drivers/media/usb/cx231xx/cx231xx-i2c.c b/drivers/media/usb/cx231xx/cx231xx-i2c.c
index c6659253c6fb..0ed246b01cca 100644
--- a/drivers/media/usb/cx231xx/cx231xx-i2c.c
+++ b/drivers/media/usb/cx231xx/cx231xx-i2c.c
@@ -593,6 +593,7 @@ struct i2c_adapter *cx231xx_get_i2c_adap(struct cx231xx *dev, int i2c_port)
 		return dev->muxc->adapter[1];
 	default:
 		BUG();
+		return NULL;
 	}
 }
 EXPORT_SYMBOL_GPL(cx231xx_get_i2c_adap);
diff --git a/drivers/media/usb/dvb-usb-v2/lmedm04.c b/drivers/media/usb/dvb-usb-v2/lmedm04.c
index 1b6d4e4c52ca..719db9a1c7d2 100644
--- a/drivers/media/usb/dvb-usb-v2/lmedm04.c
+++ b/drivers/media/usb/dvb-usb-v2/lmedm04.c
@@ -86,6 +86,7 @@ static int dvb_usb_lme2510_debug;
 #define deb_info(level, args...) lme_debug(dvb_usb_lme2510_debug, level, args)
 #define debug_data_snipet(level, name, p) \
 	 deb_info(level, name" (%8phN)", p);
+#undef info
 #define info(args...) pr_info(DVB_USB_LOG_PREFIX": "args)
 
 module_param_named(debug, dvb_usb_lme2510_debug, int, 0644);
diff --git a/drivers/media/usb/dvb-usb-v2/usb_urb.c b/drivers/media/usb/dvb-usb-v2/usb_urb.c
index 2ad2ddeaff51..542c01844d13 100644
--- a/drivers/media/usb/dvb-usb-v2/usb_urb.c
+++ b/drivers/media/usb/dvb-usb-v2/usb_urb.c
@@ -250,6 +250,7 @@ static int usb_alloc_stream_buffers(struct usb_data_stream *stream, int num,
 int usb_urb_reconfig(struct usb_data_stream *stream,
 		struct usb_data_stream_properties *props)
 {
+#if 0
 	int buf_size;
 
 	if (!props)
@@ -299,7 +300,7 @@ int usb_urb_reconfig(struct usb_data_stream *stream,
 		return usb_urb_alloc_bulk_urbs(stream);
 	else if (props->type == USB_ISOC)
 		return usb_urb_alloc_isoc_urbs(stream);
-
+#endif
 	return 0;
 }
 
@@ -322,6 +323,11 @@ int usb_urb_initv2(struct usb_data_stream *stream,
 
 	switch (stream->props.type) {
 	case USB_BULK:
+
+		/* XXX override driver parameters */
+		stream->props.count = 2;
+		if (stream->props.u.bulk.buffersize < 131072)
+			stream->props.u.bulk.buffersize = 131072;
 		ret = usb_alloc_stream_buffers(stream, stream->props.count,
 				stream->props.u.bulk.buffersize);
 		if (ret < 0)
@@ -329,6 +335,19 @@ int usb_urb_initv2(struct usb_data_stream *stream,
 
 		return usb_urb_alloc_bulk_urbs(stream);
 	case USB_ISOC:
+
+		/* XXX override driver parameters */
+		switch (stream->udev->speed) {
+		case USB_SPEED_FULL:
+		case USB_SPEED_LOW:
+			stream->props.count = 2;
+			stream->props.u.isoc.framesperurb = 24;
+			break;
+		default:
+			stream->props.count = 2;
+			stream->props.u.isoc.framesperurb = 24 * 8;
+			break;
+		}
 		ret = usb_alloc_stream_buffers(stream, stream->props.count,
 				stream->props.u.isoc.framesize *
 				stream->props.u.isoc.framesperurb);
diff --git a/drivers/media/usb/dvb-usb/usb-urb.c b/drivers/media/usb/dvb-usb/usb-urb.c
index 9771f0954c69..1fe83a6bcf12 100644
--- a/drivers/media/usb/dvb-usb/usb-urb.c
+++ b/drivers/media/usb/dvb-usb/usb-urb.c
@@ -226,8 +226,24 @@ int usb_urb_init(struct usb_data_stream *stream, struct usb_data_stream_properti
 
 	switch (stream->props.type) {
 		case USB_BULK:
+			/* XXX override driver parameters */
+			stream->props.count = 2;
+			if (stream->props.u.bulk.buffersize < 131072)
+				stream->props.u.bulk.buffersize = 131072;
 			return usb_bulk_urb_init(stream);
 		case USB_ISOC:
+			/* XXX override driver parameters */
+			switch (stream->udev->speed) {
+			case USB_SPEED_FULL:
+			case USB_SPEED_LOW:
+				stream->props.count = 2;
+				stream->props.u.isoc.framesperurb = 24;
+				break;
+			default:
+				stream->props.count = 2;
+				stream->props.u.isoc.framesperurb = 24 * 8;
+				break;
+			}
 			return usb_isoc_urb_init(stream);
 		default:
 			err("unknown URB-type for data transfer.");
diff --git a/drivers/media/usb/em28xx/em28xx.h b/drivers/media/usb/em28xx/em28xx.h
index ab167cd1f400..c97d1da614d9 100644
--- a/drivers/media/usb/em28xx/em28xx.h
+++ b/drivers/media/usb/em28xx/em28xx.h
@@ -455,6 +455,7 @@ enum em28xx_led_role {
 	EM28XX_LED_DIGITAL_CAPTURING_TS2,
 	EM28XX_LED_ILLUMINATION,
 	EM28XX_NUM_LED_ROLES, /* must be the last */
+	EM28XX_LED_DUMMY = -1,	/* force enum signed */
 };
 
 struct em28xx_led {
diff --git a/drivers/media/usb/gspca/gspca.c b/drivers/media/usb/gspca/gspca.c
index 47d8f28bfdfc..deced3e89f5d 100644
--- a/drivers/media/usb/gspca/gspca.c
+++ b/drivers/media/usb/gspca/gspca.c
@@ -37,7 +37,7 @@
 #endif
 
 /* global values */
-#define DEF_NURBS 3		/* default number of URBs */
+#define DEF_NURBS 2		/* default number of URBs */
 #if DEF_NURBS > MAX_NURBS
 #error "DEF_NURBS too big"
 #endif
diff --git a/drivers/media/usb/stkwebcam/stk-webcam.h b/drivers/media/usb/stkwebcam/stk-webcam.h
index 14519e5308b1..e1ebdc9b4d7a 100644
--- a/drivers/media/usb/stkwebcam/stk-webcam.h
+++ b/drivers/media/usb/stkwebcam/stk-webcam.h
@@ -17,8 +17,8 @@
 #define DRIVER_VERSION		"v0.0.1"
 #define DRIVER_VERSION_NUM	0x000001
 
-#define MAX_ISO_BUFS		3
-#define ISO_FRAMES_PER_DESC	16
+#define MAX_ISO_BUFS		2
+#define ISO_FRAMES_PER_DESC	56
 #define ISO_MAX_FRAME_SIZE	3 * 1024
 #define ISO_BUFFER_SIZE		(ISO_FRAMES_PER_DESC * ISO_MAX_FRAME_SIZE)
 
diff --git a/drivers/media/usb/uvc/uvc_driver.c b/drivers/media/usb/uvc/uvc_driver.c
index 9a791d8ef200..189d45df67b0 100644
--- a/drivers/media/usb/uvc/uvc_driver.c
+++ b/drivers/media/usb/uvc/uvc_driver.c
@@ -2172,8 +2172,6 @@ static void uvc_unregister_video(struct uvc_device *dev)
 
 		video_unregister_device(&stream->vdev);
 		video_unregister_device(&stream->meta.vdev);
-
-		uvc_debugfs_cleanup_stream(stream);
 	}
 
 	uvc_status_unregister(dev);
@@ -2270,8 +2268,6 @@ static int uvc_register_video(struct uvc_device *dev,
 	else
 		stream->chain->caps |= V4L2_CAP_VIDEO_OUTPUT;
 
-	uvc_debugfs_init_stream(stream);
-
 	/* Register the device with V4L. */
 	return uvc_register_video_device(dev, stream, &stream->vdev,
 					 &stream->queue, stream->type,
@@ -3189,11 +3185,8 @@ static int __init uvc_init(void)
 {
 	int ret;
 
-	uvc_debugfs_init();
-
 	ret = usb_register(&uvc_driver.driver);
 	if (ret < 0) {
-		uvc_debugfs_cleanup();
 		return ret;
 	}
 
@@ -3203,7 +3196,6 @@ static int __init uvc_init(void)
 static void __exit uvc_cleanup(void)
 {
 	usb_deregister(&uvc_driver.driver);
-	uvc_debugfs_cleanup();
 }
 
 module_init(uvc_init);
diff --git a/drivers/media/usb/uvc/uvc_video.c b/drivers/media/usb/uvc/uvc_video.c
index a777b389a66e..a198165c4218 100644
--- a/drivers/media/usb/uvc/uvc_video.c
+++ b/drivers/media/usb/uvc/uvc_video.c
@@ -1110,7 +1110,11 @@ static inline enum dma_data_direction uvc_stream_dir(
 
 static inline struct device *uvc_stream_to_dmadev(struct uvc_streaming *stream)
 {
+#ifdef __linux__
 	return bus_to_hcd(stream->dev->udev->bus)->self.sysdev;
+#else
+	return NULL;
+#endif
 }
 
 static int uvc_submit_urb(struct uvc_urb *uvc_urb, gfp_t mem_flags)
@@ -1659,9 +1663,7 @@ static int uvc_alloc_urb_buffers(struct uvc_streaming *stream,
 	/* Compute the number of packets. Bulk endpoints might transfer UVC
 	 * payloads across multiple URBs.
 	 */
-	npackets = DIV_ROUND_UP(size, psize);
-	if (npackets > UVC_MAX_PACKETS)
-		npackets = UVC_MAX_PACKETS;
+	npackets = size / psize;
 
 	/* Retry allocations until one succeed. */
 	for (; npackets > 1; npackets /= 2) {
@@ -1761,7 +1763,23 @@ static int uvc_init_video_isoc(struct uvc_streaming *stream,
 	u32 size;
 
 	psize = uvc_endpoint_max_bpi(stream->dev->udev, ep);
-	size = stream->ctrl.dwMaxVideoFrameSize;
+
+	if (stream->dev->udev->speed == USB_SPEED_FULL) {
+		/* (8000 >> 3) = 1000 FPS */
+		size = (UVC_MAX_PACKETS >> 3) * psize;
+	} else {
+		/* 1000 - 8000 FPS, figure out */
+		size = ep->desc.bInterval;
+		if (size > 0)
+			size --;
+		if (size > 3)
+			size = 3;
+		size = (UVC_MAX_PACKETS >> size) * psize;
+	}
+
+	/* avoid division by zero */
+	if (psize == 0)
+		return -EINVAL;
 
 	npackets = uvc_alloc_urb_buffers(stream, size, psize, gfp_flags);
 	if (npackets == 0)
diff --git a/drivers/media/usb/uvc/uvcvideo.h b/drivers/media/usb/uvc/uvcvideo.h
index cce5e38133cd..73a75ae17127 100644
--- a/drivers/media/usb/uvc/uvcvideo.h
+++ b/drivers/media/usb/uvc/uvcvideo.h
@@ -183,9 +183,9 @@
 #define DRIVER_VERSION		"1.1.1"
 
 /* Number of isochronous URBs. */
-#define UVC_URBS		5
+#define UVC_URBS		2U
 /* Maximum number of packets per URB. */
-#define UVC_MAX_PACKETS		32
+#define UVC_MAX_PACKETS		128U	/* at 8000 FPS */
 /* Maximum status buffer size in bytes of interrupt URB. */
 #define UVC_MAX_STATUS_SIZE	16
 
diff --git a/drivers/media/v4l2-core/v4l2-async.c b/drivers/media/v4l2-core/v4l2-async.c
index e638aa8aecb7..736c0b26ef4c 100644
--- a/drivers/media/v4l2-core/v4l2-async.c
+++ b/drivers/media/v4l2-core/v4l2-async.c
@@ -69,6 +69,7 @@ static bool match_i2c(struct v4l2_async_notifier *notifier,
 static bool match_fwnode(struct v4l2_async_notifier *notifier,
 			 struct v4l2_subdev *sd, struct v4l2_async_subdev *asd)
 {
+#if IS_ENABLED(CONFIG_OF)
 	struct fwnode_handle *other_fwnode;
 	struct fwnode_handle *dev_fwnode;
 	bool asd_fwnode_is_ep;
@@ -141,6 +142,9 @@ static bool match_fwnode(struct v4l2_async_notifier *notifier,
 	}
 
 	return true;
+#else
+	return false;
+#endif
 }
 
 static LIST_HEAD(subdev_list);
@@ -570,6 +574,7 @@ __v4l2_async_notifier_unregister(struct v4l2_async_notifier *notifier)
 	list_del(&notifier->list);
 }
 
+#if 0
 void v4l2_async_notifier_unregister(struct v4l2_async_notifier *notifier)
 {
 	mutex_lock(&list_lock);
@@ -579,6 +584,7 @@ void v4l2_async_notifier_unregister(struct v4l2_async_notifier *notifier)
 	mutex_unlock(&list_lock);
 }
 EXPORT_SYMBOL(v4l2_async_notifier_unregister);
+#endif
 
 static void __v4l2_async_notifier_cleanup(struct v4l2_async_notifier *notifier)
 {
@@ -808,6 +814,7 @@ static void print_waiting_subdev(struct seq_file *s,
 			   asd->match.i2c.address);
 		break;
 	case V4L2_ASYNC_MATCH_FWNODE: {
+#if IS_ENABLED(CONFIG_OF)
 		struct fwnode_handle *devnode, *fwnode = asd->match.fwnode;
 
 		devnode = fwnode_graph_is_endpoint(fwnode) ?
@@ -819,6 +826,7 @@ static void print_waiting_subdev(struct seq_file *s,
 			   fwnode);
 
 		fwnode_handle_put(devnode);
+#endif
 		break;
 	}
 	}
diff --git a/drivers/media/v4l2-core/v4l2-dev.c b/drivers/media/v4l2-core/v4l2-dev.c
index 7d0edf3530be..3c1934776078 100644
--- a/drivers/media/v4l2-core/v4l2-dev.c
+++ b/drivers/media/v4l2-core/v4l2-dev.c
@@ -41,6 +41,16 @@
 
 static struct dentry *v4l2_debugfs_dir;
 
+static int v4l_vflip;
+module_param(v4l_vflip, int, 0644);
+MODULE_PARM_DESC(v4l_vflip,
+	"Force all V4L devices to flip the picture vertically.");
+
+static int v4l_hflip;
+module_param(v4l_hflip, int, 0644);
+MODULE_PARM_DESC(v4l_hflip,
+	"Force all V4L devices to flip the picture horizontally.");
+
 /*
  *	sysfs stuff
  */
@@ -367,6 +377,24 @@ static long v4l2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
 	} else
 		ret = -ENOTTY;
 
+	if (ret == 0 && cmd == VIDIOC_ENUMINPUT) {
+
+		__u32 status;
+
+		if (copy_from_user(&status, (char *)arg +
+		    offsetof(struct v4l2_input, status), sizeof(status)))
+			ret = -EFAULT;
+
+		if (v4l_vflip)
+			status ^= V4L2_IN_ST_VFLIP;
+		if (v4l_hflip)
+			status ^= V4L2_IN_ST_HFLIP;
+
+		if (copy_to_user((char *)arg + offsetof(struct v4l2_input,
+		    status), &status, sizeof(status)))
+			ret = -EFAULT;
+	}
+
 	return ret;
 }
 
@@ -453,13 +481,17 @@ static int v4l2_release(struct inode *inode, struct file *filp)
 	 * request at the same time.
 	 */
 	if (vdev->fops->release) {
+#if IS_ENABLED(MEDIA_CONTROLLER)
 		if (v4l2_device_supports_requests(vdev->v4l2_dev)) {
 			mutex_lock(&vdev->v4l2_dev->mdev->req_queue_mutex);
 			ret = vdev->fops->release(filp);
 			mutex_unlock(&vdev->v4l2_dev->mdev->req_queue_mutex);
 		} else {
+#endif
 			ret = vdev->fops->release(filp);
+#if IS_ENABLED(MEDIA_CONTROLLER)
 		}
+#endif
 	}
 
 	if (vdev->dev_debug & V4L2_DEV_DEBUG_FOP)
diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c
index 2673f51aafa4..738db4e2c1dd 100644
--- a/drivers/media/v4l2-core/v4l2-ioctl.c
+++ b/drivers/media/v4l2-core/v4l2-ioctl.c
@@ -2906,6 +2906,7 @@ static long __video_do_ioctl(struct file *file,
 	 * operation, and that should not be mixed with queueing a new
 	 * request at the same time.
 	 */
+#if IS_ENABLED(MEDIA_CONTROLLER)
 	if (v4l2_device_supports_requests(vfd->v4l2_dev) &&
 	    (cmd == VIDIOC_STREAMON || cmd == VIDIOC_STREAMOFF)) {
 		req_queue_lock = &vfd->v4l2_dev->mdev->req_queue_mutex;
@@ -2913,6 +2914,7 @@ static long __video_do_ioctl(struct file *file,
 		if (mutex_lock_interruptible(req_queue_lock))
 			return -ERESTARTSYS;
 	}
+#endif
 
 	lock = v4l2_ioctl_get_lock(vfd, vfh, cmd, arg);
 
diff --git a/drivers/media/v4l2-core/v4l2-subdev.c b/drivers/media/v4l2-core/v4l2-subdev.c
index 956dafab43d4..b767b82f90a8 100644
--- a/drivers/media/v4l2-core/v4l2-subdev.c
+++ b/drivers/media/v4l2-core/v4l2-subdev.c
@@ -428,6 +428,7 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg)
 
 		return v4l2_event_dequeue(vfh, arg, file->f_flags & O_NONBLOCK);
 
+#ifdef CONFIG_COMPAT_32BIT_TIME
 	case VIDIOC_DQEVENT_TIME32: {
 		struct v4l2_event_time32 *ev32 = arg;
 		struct v4l2_event ev = { };
@@ -451,7 +452,7 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg)
 
 		return rval;
 	}
-
+#endif
 	case VIDIOC_SUBSCRIBE_EVENT:
 		return v4l2_subdev_call(sd, core, subscribe_event, vfh, arg);
 
diff --git a/include/media/v4l2-device.h b/include/media/v4l2-device.h
index 8a8977a33ec1..4d999cd44927 100644
--- a/include/media/v4l2-device.h
+++ b/include/media/v4l2-device.h
@@ -246,11 +246,13 @@ static inline void v4l2_subdev_notify(struct v4l2_subdev *sd,
  *
  * @v4l2_dev: pointer to struct v4l2_device
  */
+#if IS_ENABLED(MEDIA_CONTROLLER)
 static inline bool v4l2_device_supports_requests(struct v4l2_device *v4l2_dev)
 {
 	return v4l2_dev->mdev && v4l2_dev->mdev->ops &&
 	       v4l2_dev->mdev->ops->req_queue;
 }
+#endif
 
 /* Helper macros to iterate over all subdevs. */
 
diff --git a/include/uapi/asm-generic/ioctl.h b/include/uapi/asm-generic/ioctl.h
index a84f4db8a250..6695939fb2d4 100644
--- a/include/uapi/asm-generic/ioctl.h
+++ b/include/uapi/asm-generic/ioctl.h
@@ -83,6 +83,7 @@
  * means userland is reading and kernel is writing.
  */
 #define _IO(type,nr)		_IOC(_IOC_NONE,(type),(nr),0)
+#define _IOWINT(type,nr)	_IOC(_IOC_NONE,(type),(nr),sizeof(int))
 #define _IOR(type,nr,size)	_IOC(_IOC_READ,(type),(nr),(_IOC_TYPECHECK(size)))
 #define _IOW(type,nr,size)	_IOC(_IOC_WRITE,(type),(nr),(_IOC_TYPECHECK(size)))
 #define _IOWR(type,nr,size)	_IOC(_IOC_READ|_IOC_WRITE,(type),(nr),(_IOC_TYPECHECK(size)))
diff --git a/include/uapi/linux/dvb/ca.h b/include/uapi/linux/dvb/ca.h
index dffa59e95ebb..c4533a16d93e 100644
--- a/include/uapi/linux/dvb/ca.h
+++ b/include/uapi/linux/dvb/ca.h
@@ -134,9 +134,17 @@ struct ca_descr {
 
 #define CA_RESET          _IO('o', 128)
 #define CA_GET_CAP        _IOR('o', 129, struct ca_caps)
+/*
+ * At least CA_GET_SLOT_INFO and CA_GET_MSG need to be _IOWR not _IOR.
+ * This is wrong on Linux too but there the driver doesn't care.
+ *
 #define CA_GET_SLOT_INFO  _IOR('o', 130, struct ca_slot_info)
 #define CA_GET_DESCR_INFO _IOR('o', 131, struct ca_descr_info)
 #define CA_GET_MSG        _IOR('o', 132, struct ca_msg)
+*/
+#define CA_GET_SLOT_INFO  _IOWR('o', 130, struct ca_slot_info)
+#define CA_GET_DESCR_INFO _IOR('o', 131, struct ca_descr_info)
+#define CA_GET_MSG        _IOWR('o', 132, struct ca_msg)
 #define CA_SEND_MSG       _IOW('o', 133, struct ca_msg)
 #define CA_SET_DESCR      _IOW('o', 134, struct ca_descr)
 
diff --git a/include/uapi/linux/dvb/frontend.h b/include/uapi/linux/dvb/frontend.h
index 4f9b4551c534..a5e950404072 100644
--- a/include/uapi/linux/dvb/frontend.h
+++ b/include/uapi/linux/dvb/frontend.h
@@ -908,7 +908,8 @@ struct dtv_properties {
 #define FE_DISHNETWORK_SEND_LEGACY_CMD _IO('o', 80) /* unsigned int */
 
 #define FE_SET_PROPERTY		   _IOW('o', 82, struct dtv_properties)
-#define FE_GET_PROPERTY		   _IOR('o', 83, struct dtv_properties)
+#define FE_GET_PROPERTY		   _IOW('o', 83, struct dtv_properties)
+#define FE_GET_PROPERTY_OLD	   _IOR('o', 83, struct dtv_properties)
 
 #if defined(__DVB_CORE__) || !defined(__KERNEL__)
 
diff --git a/include/uapi/linux/input.h b/include/uapi/linux/input.h
index ee3127461ee0..047701d44a8c 100644
--- a/include/uapi/linux/input.h
+++ b/include/uapi/linux/input.h
@@ -131,8 +131,12 @@ struct input_mask {
 #define EVIOCGREP		_IOR('E', 0x03, unsigned int[2])	/* get repeat settings */
 #define EVIOCSREP		_IOW('E', 0x03, unsigned int[2])	/* set repeat settings */
 
-#define EVIOCGKEYCODE		_IOR('E', 0x04, unsigned int[2])        /* get keycode */
-#define EVIOCGKEYCODE_V2	_IOR('E', 0x04, struct input_keymap_entry)
+/*
+ * These two need to be _IOWR not _IOR (they're wrong on Linux too but
+ * there the driver doesn't care.)
+ */
+#define EVIOCGKEYCODE		_IOWR('E', 0x04, unsigned int[2])       /* get keycode */
+#define EVIOCGKEYCODE_V2	_IOWR('E', 0x04, struct input_keymap_entry)
 #define EVIOCSKEYCODE		_IOW('E', 0x04, unsigned int[2])        /* set keycode */
 #define EVIOCSKEYCODE_V2	_IOW('E', 0x04, struct input_keymap_entry)
 
@@ -165,7 +169,7 @@ struct input_mask {
  *
  * If the request code is not an ABS_MT value, -EINVAL is returned.
  */
-#define EVIOCGMTSLOTS(len)	_IOC(_IOC_READ, 'E', 0x0a, len)
+#define EVIOCGMTSLOTS(len)	_IOC(_IOC_READ|_IOC_WRITE, 'E', 0x0a, len)
 
 #define EVIOCGKEY(len)		_IOC(_IOC_READ, 'E', 0x18, len)		/* get global key state */
 #define EVIOCGLED(len)		_IOC(_IOC_READ, 'E', 0x19, len)		/* get all LEDs */
@@ -177,11 +181,11 @@ struct input_mask {
 #define EVIOCSABS(abs)		_IOW('E', 0xc0 + (abs), struct input_absinfo)	/* set abs value/limits */
 
 #define EVIOCSFF		_IOW('E', 0x80, struct ff_effect)	/* send a force effect to a force feedback device */
-#define EVIOCRMFF		_IOW('E', 0x81, int)			/* Erase a force effect */
+#define EVIOCRMFF		_IOWINT('E', 0x81)			/* Erase a force effect */
 #define EVIOCGEFFECTS		_IOR('E', 0x84, int)			/* Report number of effects playable at the same time */
 
-#define EVIOCGRAB		_IOW('E', 0x90, int)			/* Grab/Release device */
-#define EVIOCREVOKE		_IOW('E', 0x91, int)			/* Revoke device access */
+#define EVIOCGRAB		_IOWINT('E', 0x90)			/* Grab/Release device */
+#define EVIOCREVOKE		_IOWINT('E', 0x91)			/* Revoke device access */
 
 /**
  * EVIOCGMASK - Retrieve current event mask
@@ -212,7 +216,7 @@ struct input_mask {
  * if the receive-buffer points to invalid memory, or EINVAL if the kernel
  * does not implement the ioctl.
  */
-#define EVIOCGMASK		_IOR('E', 0x92, struct input_mask)	/* Get event-masks */
+#define EVIOCGMASK		_IOW('E', 0x92, struct input_mask)	/* Get event-masks */
 
 /**
  * EVIOCSMASK - Set event mask
diff --git a/drivers/input/touchscreen/sur40.c b/drivers/input/touchscreen/sur40.c
index 12f2562b0141..a56a8349e8dd 100644
--- a/drivers/input/touchscreen/sur40.c
+++ b/drivers/input/touchscreen/sur40.c
@@ -1121,7 +1121,9 @@ static const struct vb2_queue sur40_queue = {
 	.io_modes = VB2_MMAP | VB2_READ | VB2_DMABUF,
 	.buf_struct_size = sizeof(struct sur40_buffer),
 	.ops = &sur40_queue_ops,
+#ifdef __linux__
 	.mem_ops = &vb2_dma_sg_memops,
+#endif
 	.timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC,
 	.min_buffers_needed = 3,
 };
