linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mauro Carvalho Chehab <mchehab@kernel.org>
To: unlisted-recipients:; (no To-header on input)
Cc: Mauro Carvalho Chehab <mchehab@kernel.org>,
	linux-kernel@vger.kernel.org, linux-media@vger.kernel.org
Subject: [PATCH 20/26] media: dvb-usb: ttusb2: use an enum for the device number
Date: Mon, 28 Mar 2022 22:41:32 +0200	[thread overview]
Message-ID: <b447d9fd3832da5eff6267e8fe742c431f1133f2.1648499509.git.mchehab@kernel.org> (raw)
In-Reply-To: <cover.1648499509.git.mchehab@kernel.org>

The device number is currently a value that needs to be the same
on two separate tables, but the code doesn't actually enforce it,
leading to errors as boards get added or removed.

Fix it by using an enum.

Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
---

To avoid mailbombing on a large number of people, only mailing lists were C/C on the cover.
See [PATCH 00/26] at: https://lore.kernel.org/all/cover.1648499509.git.mchehab@kernel.org/

 drivers/media/usb/dvb-usb/ttusb2.c | 36 +++++++++++++++++-------------
 include/media/dvb-usb-ids.h        |  4 ++--
 2 files changed, 23 insertions(+), 17 deletions(-)

diff --git a/drivers/media/usb/dvb-usb/ttusb2.c b/drivers/media/usb/dvb-usb/ttusb2.c
index 294274fd8f55..373ffa7f641e 100644
--- a/drivers/media/usb/dvb-usb/ttusb2.c
+++ b/drivers/media/usb/dvb-usb/ttusb2.c
@@ -630,17 +630,23 @@ static int ttusb2_probe(struct usb_interface *intf,
 	return -ENODEV;
 }
 
-static struct usb_device_id ttusb2_table [] = {
-	{ USB_DEVICE(USB_VID_PINNACLE, USB_PID_PCTV_400E) },
-	{ USB_DEVICE(USB_VID_PINNACLE, USB_PID_PCTV_450E) },
-	{ USB_DEVICE(USB_VID_TECHNOTREND,
-		USB_PID_TECHNOTREND_CONNECT_S2400) },
-	{ USB_DEVICE(USB_VID_TECHNOTREND,
-		USB_PID_TECHNOTREND_CONNECT_CT3650) },
-	{ USB_DEVICE(USB_VID_TECHNOTREND,
-		USB_PID_TECHNOTREND_CONNECT_S2400_8KEEPROM) },
-	{}		/* Terminating entry */
+enum {
+	PINNACLE_PCTV_400E,
+	PINNACLE_PCTV_450E,
+	TECHNOTREND_CONNECT_S2400,
+	TECHNOTREND_CONNECT_CT3650,
+	TECHNOTREND_CONNECT_S2400_8KEEPROM,
 };
+
+static struct usb_device_id ttusb2_table[] = {
+	DVB_USB_DEV(PINNACLE, PINNACLE_PCTV_400E),
+	DVB_USB_DEV(PINNACLE, PINNACLE_PCTV_450E),
+	DVB_USB_DEV(TECHNOTREND, TECHNOTREND_CONNECT_S2400),
+	DVB_USB_DEV(TECHNOTREND, TECHNOTREND_CONNECT_CT3650),
+	DVB_USB_DEV(TECHNOTREND, TECHNOTREND_CONNECT_S2400_8KEEPROM),
+	{ }
+};
+
 MODULE_DEVICE_TABLE (usb, ttusb2_table);
 
 static struct dvb_usb_device_properties ttusb2_properties = {
@@ -688,11 +694,11 @@ static struct dvb_usb_device_properties ttusb2_properties = {
 	.num_device_descs = 2,
 	.devices = {
 		{   "Pinnacle 400e DVB-S USB2.0",
-			{ &ttusb2_table[0], NULL },
+			{ &ttusb2_table[PINNACLE_PCTV_400E], NULL },
 			{ NULL },
 		},
 		{   "Pinnacle 450e DVB-S USB2.0",
-			{ &ttusb2_table[1], NULL },
+			{ &ttusb2_table[PINNACLE_PCTV_450E], NULL },
 			{ NULL },
 		},
 	}
@@ -743,11 +749,11 @@ static struct dvb_usb_device_properties ttusb2_properties_s2400 = {
 	.num_device_descs = 2,
 	.devices = {
 		{   "Technotrend TT-connect S-2400",
-			{ &ttusb2_table[2], NULL },
+			{ &ttusb2_table[TECHNOTREND_CONNECT_S2400], NULL },
 			{ NULL },
 		},
 		{   "Technotrend TT-connect S-2400 (8kB EEPROM)",
-			{ &ttusb2_table[4], NULL },
+			{ &ttusb2_table[TECHNOTREND_CONNECT_S2400_8KEEPROM], NULL },
 			{ NULL },
 		},
 	}
@@ -823,7 +829,7 @@ static struct dvb_usb_device_properties ttusb2_properties_ct3650 = {
 	.num_device_descs = 1,
 	.devices = {
 		{   "Technotrend TT-connect CT-3650",
-			.warm_ids = { &ttusb2_table[3], NULL },
+			.warm_ids = { &ttusb2_table[TECHNOTREND_CONNECT_CT3650], NULL },
 		},
 	}
 };
diff --git a/include/media/dvb-usb-ids.h b/include/media/dvb-usb-ids.h
index ed6e37f23cbc..0fad68bfe6f9 100644
--- a/include/media/dvb-usb-ids.h
+++ b/include/media/dvb-usb-ids.h
@@ -312,8 +312,6 @@
 #define USB_PID_PCTV_2002E				0x025c
 #define USB_PID_PCTV_2002E_SE				0x025d
 #define USB_PID_PCTV_200E				0x020e
-#define USB_PID_PCTV_400E				0x020f
-#define USB_PID_PCTV_450E				0x0222
 #define USB_PID_PCTV_78E				0x025a
 #define USB_PID_PCTV_79E				0x0262
 #define USB_PID_PINNACLE_EXPRESSCARD_320CX		0x022e
@@ -329,6 +327,8 @@
 #define USB_PID_PINNACLE_PCTV74E			0x0246
 #define USB_PID_PINNACLE_PCTV801E			0x023a
 #define USB_PID_PINNACLE_PCTV801E_SE			0x023b
+#define USB_PID_PINNACLE_PCTV_400E			0x020f
+#define USB_PID_PINNACLE_PCTV_450E			0x0222
 #define USB_PID_PINNACLE_PCTV_452E			0x021f
 #define USB_PID_PINNACLE_PCTV_DUAL_DIVERSITY_DVB_T	0x0229
 #define USB_PID_PINNACLE_PCTV_DVB_T_FLASH		0x0228
-- 
2.35.1


  parent reply	other threads:[~2022-03-28 20:48 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-28 20:41 [PATCH 00/26] dvb-usb: use designated initializers Mauro Carvalho Chehab
2022-03-28 20:41 ` [PATCH 01/26] media: dvb-usb-ids.h: sort entries Mauro Carvalho Chehab
2022-03-28 20:41 ` [PATCH 02/26] media: dvb-usb: move USB IDs to dvb-usb-ids.h Mauro Carvalho Chehab
2022-03-28 20:41 ` [PATCH 03/26] media: dvb-usb: vp702x: reference to usb ID table Mauro Carvalho Chehab
2022-03-28 20:41 ` [PATCH 04/26] media: dvb-usb: Add helper macros for using USB VID/PID Mauro Carvalho Chehab
2022-03-28 20:41 ` [PATCH 05/26] media: dvb-usb: a800: use an enum for the device number Mauro Carvalho Chehab
2022-03-28 20:41 ` [PATCH 06/26] media: af9005: use the newer dvb-usb macros for USB device Mauro Carvalho Chehab
2022-03-28 20:41 ` [PATCH 07/26] media: dvb-usb: az6027: use an enum for the device number Mauro Carvalho Chehab
2022-03-28 20:41 ` [PATCH 08/26] media: cinergyT2-core: use the newer dvb-usb macros for USB device Mauro Carvalho Chehab
2022-03-28 20:41 ` [PATCH 09/26] media: cxusb: " Mauro Carvalho Chehab
2022-03-28 20:41 ` [PATCH 10/26] media: digitv: " Mauro Carvalho Chehab
2022-03-28 20:41 ` [PATCH 11/26] media: dvb-usb: dtt200u: use an enum for the device number Mauro Carvalho Chehab
2022-03-28 20:41 ` [PATCH 12/26] media: dtv5100: use the newer dvb-usb macros for USB device Mauro Carvalho Chehab
2022-03-28 20:41 ` [PATCH 13/26] media: dw2102: " Mauro Carvalho Chehab
2022-03-28 20:41 ` [PATCH 14/26] media: dvb-usb: gp8psk: use an enum for the device number Mauro Carvalho Chehab
2022-03-28 20:41 ` [PATCH 15/26] media: dvb-usb: m920x: " Mauro Carvalho Chehab
2022-03-28 20:41 ` [PATCH 16/26] media: dvb-usb: nova-t-usb2: " Mauro Carvalho Chehab
2022-03-28 20:41 ` [PATCH 17/26] media: dvb-usb: opera1: " Mauro Carvalho Chehab
2022-03-28 20:41 ` [PATCH 18/26] media: dvb-usb: pctv452e: " Mauro Carvalho Chehab
2022-03-28 20:41 ` [PATCH 19/26] media: technisat-usb2: use the newer dvb-usb macros for USB device Mauro Carvalho Chehab
2022-03-28 20:41 ` Mauro Carvalho Chehab [this message]
2022-03-28 20:41 ` [PATCH 21/26] media: dvb-usb: umt-010: use an enum for the device number Mauro Carvalho Chehab
2022-03-28 20:41 ` [PATCH 22/26] media: dvb-usb: vp702x: " Mauro Carvalho Chehab
2022-03-28 20:41 ` [PATCH 23/26] media: dvb-usb: vp7045: " Mauro Carvalho Chehab
2022-03-28 20:41 ` [PATCH 24/26] media: dvb-usb: dibusb-mb: " Mauro Carvalho Chehab
2022-03-28 20:41 ` [PATCH 25/26] media: dvb-usb: dibusb-mc: " Mauro Carvalho Chehab
2022-03-28 20:41 ` [PATCH 26/26] media: dvb-usb: dib0700_devices: " Mauro Carvalho Chehab
2022-03-28 21:02 ` [PATCH 00/26] dvb-usb: use designated initializers Joe Perches

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b447d9fd3832da5eff6267e8fe742c431f1133f2.1648499509.git.mchehab@kernel.org \
    --to=mchehab@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).