V4L/DVB (9752): Remove duplicated fields on em28xx_board and em28xx structs

Several fields are duplicated on both structs. Let's just copy em28xx_board instead.

A later cleanup could just copy the fields that are changed, in order to keep em28xx_board
const.

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
diff --git a/drivers/media/video/em28xx/em28xx-cards.c b/drivers/media/video/em28xx/em28xx-cards.c
index 0d489ca..11308eb 100644
--- a/drivers/media/video/em28xx/em28xx-cards.c
+++ b/drivers/media/video/em28xx/em28xx-cards.c
@@ -1262,19 +1262,9 @@
 }
 EXPORT_SYMBOL_GPL(em28xx_tuner_callback);
 
-static void em28xx_set_model(struct em28xx *dev)
+static void inline em28xx_set_model(struct em28xx *dev)
 {
-	dev->is_em2800 = em28xx_boards[dev->model].is_em2800;
-	dev->has_msp34xx = em28xx_boards[dev->model].has_msp34xx;
-	dev->tda9887_conf = em28xx_boards[dev->model].tda9887_conf;
-	dev->decoder = em28xx_boards[dev->model].decoder;
-	dev->xclk = em28xx_boards[dev->model].xclk;
-	dev->i2c_speed = em28xx_boards[dev->model].i2c_speed;
-	dev->max_range_640_480 = em28xx_boards[dev->model].max_range_640_480;
-	dev->has_dvb = em28xx_boards[dev->model].has_dvb;
-	dev->has_snapshot_button = em28xx_boards[dev->model].has_snapshot_button;
-	dev->ir_codes = em28xx_boards[dev->model].ir_codes;
-	dev->valid = em28xx_boards[dev->model].valid;
+	memcpy(&dev->board, &em28xx_boards[dev->model], sizeof(dev->board));
 }
 
 /* Since em28xx_pre_card_setup() requires a proper dev->model,
@@ -1331,16 +1321,16 @@
 	/* Those are the default values for the majority of boards
 	   Use those values if not specified otherwise at boards entry
 	 */
-	if (!dev->xclk)
-		dev->xclk = EM28XX_XCLK_IR_RC5_MODE |
-			    EM28XX_XCLK_FREQUENCY_12MHZ;
+	if (!dev->board.xclk)
+		dev->board.xclk = EM28XX_XCLK_IR_RC5_MODE |
+				  EM28XX_XCLK_FREQUENCY_12MHZ;
 
-	if (!dev->i2c_speed)
-		dev->i2c_speed = EM28XX_I2C_CLK_WAIT_ENABLE |
-				 EM28XX_I2C_FREQ_100_KHZ;
+	if (!dev->board.i2c_speed)
+		dev->board.i2c_speed = EM28XX_I2C_CLK_WAIT_ENABLE |
+				       EM28XX_I2C_FREQ_100_KHZ;
 
-	em28xx_write_reg(dev, EM28XX_R0F_XCLK, dev->xclk & 0x7f);
-	em28xx_write_reg(dev, EM28XX_R06_I2C_CLK, dev->i2c_speed);
+	em28xx_write_reg(dev, EM28XX_R0F_XCLK, dev->board.xclk & 0x7f);
+	em28xx_write_reg(dev, EM28XX_R06_I2C_CLK, dev->board.i2c_speed);
 	msleep(50);
 
 	/* request some modules */
@@ -1694,7 +1684,7 @@
 
 		if (tv.audio_processor == V4L2_IDENT_MSPX4XX) {
 			dev->i2s_speed = 2048000;
-			dev->has_msp34xx = 1;
+			dev->board.has_msp34xx = 1;
 		}
 #ifdef CONFIG_MODULES
 		if (tv.has_ir)
@@ -1727,10 +1717,10 @@
 		break;
 	}
 
-	if (dev->has_snapshot_button)
+	if (dev->board.has_snapshot_button)
 		em28xx_register_snapshot_button(dev);
 
-	if (dev->valid == EM28XX_BOARD_NOT_VALIDATED) {
+	if (dev->board.valid == EM28XX_BOARD_NOT_VALIDATED) {
 		em28xx_errdev("\n\n");
 		em28xx_errdev("The support for this board weren't "
 			      "valid yet.\n");
@@ -1745,13 +1735,13 @@
 
 #ifdef CONFIG_MODULES
 	/* request some modules */
-	if (dev->has_msp34xx)
+	if (dev->board.has_msp34xx)
 		request_module("msp3400");
-	if (dev->decoder == EM28XX_SAA7113 || dev->decoder == EM28XX_SAA7114)
+	if (dev->board.decoder == EM28XX_SAA7113 || dev->board.decoder == EM28XX_SAA7114)
 		request_module("saa7115");
-	if (dev->decoder == EM28XX_TVP5150)
+	if (dev->board.decoder == EM28XX_TVP5150)
 		request_module("tvp5150");
-	if (dev->tuner_type != TUNER_ABSENT)
+	if (dev->board.tuner_type != TUNER_ABSENT)
 		request_module("tuner");
 #endif
 
diff --git a/drivers/media/video/em28xx/em28xx-core.c b/drivers/media/video/em28xx/em28xx-core.c
index 53c7252..164f9b3 100644
--- a/drivers/media/video/em28xx/em28xx-core.c
+++ b/drivers/media/video/em28xx/em28xx-core.c
@@ -349,7 +349,7 @@
 	int ret;
 	u8 input;
 
-	if (dev->is_em2800) {
+	if (dev->board.is_em2800) {
 		if (dev->ctl_ainput == EM28XX_AMUX_VIDEO)
 			input = EM2800_AUDIO_SRC_TUNER;
 		else
@@ -360,7 +360,7 @@
 			return ret;
 	}
 
-	if (dev->has_msp34xx)
+	if (dev->board.has_msp34xx)
 		input = EM28XX_AUDIO_SRC_TUNER;
 	else {
 		switch (dev->ctl_ainput) {
@@ -417,7 +417,7 @@
 		}
 	}
 
-	xclk = dev->xclk & 0x7f;
+	xclk = dev->board.xclk & 0x7f;
 	if (!dev->mute)
 		xclk |= 0x80;
 
@@ -658,7 +658,7 @@
 {
 	u8 mode;
 	/* the em2800 scaler only supports scaling down to 50% */
-	if (dev->is_em2800)
+	if (dev->board.is_em2800)
 		mode = (v ? 0x20 : 0x00) | (h ? 0x10 : 0x00);
 	else {
 		u8 buf[2];
diff --git a/drivers/media/video/em28xx/em28xx-dvb.c b/drivers/media/video/em28xx/em28xx-dvb.c
index c99e238..09c15cc 100644
--- a/drivers/media/video/em28xx/em28xx-dvb.c
+++ b/drivers/media/video/em28xx/em28xx-dvb.c
@@ -393,7 +393,7 @@
 	int result = 0;
 	struct em28xx_dvb *dvb;
 
-	if (!dev->has_dvb) {
+	if (!dev->board.has_dvb) {
 		/* This device does not support the extension */
 		return 0;
 	}
@@ -479,7 +479,7 @@
 
 static int dvb_fini(struct em28xx *dev)
 {
-	if (!dev->has_dvb) {
+	if (!dev->board.has_dvb) {
 		/* This device does not support the extension */
 		return 0;
 	}
diff --git a/drivers/media/video/em28xx/em28xx-i2c.c b/drivers/media/video/em28xx/em28xx-i2c.c
index ec3e3b1..78d6023 100644
--- a/drivers/media/video/em28xx/em28xx-i2c.c
+++ b/drivers/media/video/em28xx/em28xx-i2c.c
@@ -250,7 +250,7 @@
 			 (msgs[i].flags & I2C_M_RD) ? "read" : "write",
 			 i == num - 1 ? "stop" : "nonstop", addr, msgs[i].len);
 		if (!msgs[i].len) { /* no len: check only for device presence */
-			if (dev->is_em2800)
+			if (dev->board.is_em2800)
 				rc = em2800_i2c_check_for_device(dev, addr);
 			else
 				rc = em28xx_i2c_check_for_device(dev, addr);
@@ -261,7 +261,7 @@
 
 		} else if (msgs[i].flags & I2C_M_RD) {
 			/* read bytes */
-			if (dev->is_em2800)
+			if (dev->board.is_em2800)
 				rc = em2800_i2c_recv_bytes(dev, addr,
 							   msgs[i].buf,
 							   msgs[i].len);
@@ -279,7 +279,7 @@
 				for (byte = 0; byte < msgs[i].len; byte++)
 					printk(" %02x", msgs[i].buf[byte]);
 			}
-			if (dev->is_em2800)
+			if (dev->board.is_em2800)
 				rc = em2800_i2c_send_bytes(dev, addr,
 							   msgs[i].buf,
 							   msgs[i].len);
diff --git a/drivers/media/video/em28xx/em28xx-input.c b/drivers/media/video/em28xx/em28xx-input.c
index 07edd40..42bbaf6 100644
--- a/drivers/media/video/em28xx/em28xx-input.c
+++ b/drivers/media/video/em28xx/em28xx-input.c
@@ -327,7 +327,7 @@
 	u8 ir_config;
 	int err = -ENOMEM;
 
-	if (dev->ir_codes == NULL) {
+	if (dev->board.ir_codes == NULL) {
 		/* No remote control support */
 		return 0;
 	}
@@ -366,7 +366,7 @@
 	usb_make_path(dev->udev, ir->phys, sizeof(ir->phys));
 	strlcat(ir->phys, "/input0", sizeof(ir->phys));
 
-	ir_input_init(input_dev, &ir->ir, IR_TYPE_OTHER, dev->ir_codes);
+	ir_input_init(input_dev, &ir->ir, IR_TYPE_OTHER, dev->board.ir_codes);
 	input_dev->name = ir->name;
 	input_dev->phys = ir->phys;
 	input_dev->id.bustype = BUS_USB;
diff --git a/drivers/media/video/em28xx/em28xx-video.c b/drivers/media/video/em28xx/em28xx-video.c
index 5cf32ae..845253c 100644
--- a/drivers/media/video/em28xx/em28xx-video.c
+++ b/drivers/media/video/em28xx/em28xx-video.c
@@ -517,7 +517,7 @@
 	int retval;
 
 	/* Sets I2C speed to 100 KHz */
-	if (!dev->is_em2800) {
+	if (!dev->board.is_em2800) {
 		retval = em28xx_write_regs_req(dev, 0x00, 0x06, "\x40", 1);
 		if (retval < 0) {
 			em28xx_errdev("%s: em28xx_write_regs_req failed! retval [%d]\n",
@@ -573,7 +573,7 @@
 
 	em28xx_i2c_call_clients(dev, VIDIOC_INT_S_VIDEO_ROUTING, &route);
 
-	if (dev->has_msp34xx) {
+	if (dev->board.has_msp34xx) {
 		if (dev->i2s_speed) {
 			em28xx_i2c_call_clients(dev, VIDIOC_INT_I2S_CLOCK_FREQ,
 				&dev->i2s_speed);
@@ -747,7 +747,7 @@
 
 	mutex_lock(&dev->lock);
 
-	if (dev->is_em2800) {
+	if (dev->board.is_em2800) {
 		/* the em2800 can only scale down to 50% */
 		if (height % (maxh / 2))
 			height = maxh;
@@ -998,7 +998,7 @@
 
 	qc->id = id;
 
-	if (!dev->has_msp34xx) {
+	if (!dev->board.has_msp34xx) {
 		for (i = 0; i < ARRAY_SIZE(em28xx_qctrl); i++) {
 			if (qc->id && qc->id == em28xx_qctrl[i].id) {
 				memcpy(qc, &(em28xx_qctrl[i]), sizeof(*qc));
@@ -1028,7 +1028,7 @@
 		return rc;
 	mutex_lock(&dev->lock);
 
-	if (!dev->has_msp34xx)
+	if (!dev->board.has_msp34xx)
 		rc = em28xx_get_ctrl(dev, ctrl);
 	else
 		rc = -EINVAL;
@@ -1056,7 +1056,7 @@
 
 	mutex_lock(&dev->lock);
 
-	if (dev->has_msp34xx)
+	if (dev->board.has_msp34xx)
 		em28xx_i2c_call_clients(dev, VIDIOC_S_CTRL, ctrl);
 	else {
 		rc = 1;
@@ -2035,7 +2035,7 @@
 	dev->em28xx_read_reg_req_len = em28xx_read_reg_req_len;
 	dev->em28xx_write_regs_req = em28xx_write_regs_req;
 	dev->em28xx_read_reg_req = em28xx_read_reg_req;
-	dev->is_em2800 = em28xx_boards[dev->model].is_em2800;
+	dev->board.is_em2800 = em28xx_boards[dev->model].is_em2800;
 
 	em28xx_pre_card_setup(dev);
 
@@ -2092,7 +2092,7 @@
 	INIT_LIST_HEAD(&dev->vidq.queued);
 
 
-	if (dev->has_msp34xx) {
+	if (dev->board.has_msp34xx) {
 		/* Send a reset to other chips via gpio */
 		errCode = em28xx_write_regs_req(dev, 0x00, 0x08, "\xf7", 1);
 		if (errCode < 0) {
@@ -2150,7 +2150,7 @@
 	else if (dev->has_alsa_audio)
 		request_module("em28xx-alsa");
 
-	if (dev->has_dvb)
+	if (dev->board.has_dvb)
 		request_module("em28xx-dvb");
 }
 
diff --git a/drivers/media/video/em28xx/em28xx.h b/drivers/media/video/em28xx/em28xx.h
index 059cc7f..e33aa54 100644
--- a/drivers/media/video/em28xx/em28xx.h
+++ b/drivers/media/video/em28xx/em28xx.h
@@ -328,6 +328,7 @@
 
 struct em28xx_board {
 	char *name;
+	int vchannels;
 	int tuner_type;
 	int tuner_addr;
 
@@ -416,18 +417,12 @@
 	int model;		/* index in the device_data struct */
 	int devno;		/* marks the number of this device */
 	enum em28xx_chip_id chip_id;
-	unsigned int is_em2800:1;
-	unsigned int has_msp34xx:1;
-	unsigned int has_tda9887:1;
+
+	struct em28xx_board board;
+
 	unsigned int stream_on:1;	/* Locks streams */
 	unsigned int has_audio_class:1;
 	unsigned int has_alsa_audio:1;
-	unsigned int max_range_640_480:1;
-	unsigned int has_dvb:1;
-	unsigned int has_snapshot_button:1;
-	unsigned int valid:1;		/* report for validated boards */
-
-	unsigned char xclk, i2c_speed;
 
 	struct em28xx_IR *ir;
 
@@ -444,7 +439,6 @@
 
 	u32 i2s_speed;		/* I2S speed for audio digital stream */
 
-	enum em28xx_decoder decoder;
 	struct em28xx_audio_mode audio_mode;
 
 	int tuner_type;		/* type of the tuner */
@@ -527,9 +521,6 @@
 	/* Caches GPO and GPIO registers */
 	unsigned char	reg_gpo, reg_gpio;
 
-	/* Infrared remote control support */
-	IR_KEYTAB_TYPE *ir_codes;
-
 	/* Snapshot button */
 	char snapshot_button_path[30];	/* path of the input dev */
 	struct input_dev *sbutton_input_dev;
@@ -699,7 +690,7 @@
 /*FIXME: maxw should be dependent of alt mode */
 static inline unsigned int norm_maxw(struct em28xx *dev)
 {
-	if (dev->max_range_640_480)
+	if (dev->board.max_range_640_480)
 		return 640;
 	else
 		return 720;
@@ -707,7 +698,7 @@
 
 static inline unsigned int norm_maxh(struct em28xx *dev)
 {
-	if (dev->max_range_640_480)
+	if (dev->board.max_range_640_480)
 		return 480;
 	else
 		return (dev->norm & V4L2_STD_625_50) ? 576 : 480;