2022-03-28 21:26:40

by Mauro Carvalho Chehab

[permalink] [raw]
Subject: [PATCH 07/26] media: dvb-usb: az6027: use an enum for the device number

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 <[email protected]>
---

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/[email protected]/

drivers/media/usb/dvb-usb/az6027.c | 45 +++++++++++++++++++-----------
1 file changed, 28 insertions(+), 17 deletions(-)

diff --git a/drivers/media/usb/dvb-usb/az6027.c b/drivers/media/usb/dvb-usb/az6027.c
index 86788771175b..cf15988dfb51 100644
--- a/drivers/media/usb/dvb-usb/az6027.c
+++ b/drivers/media/usb/dvb-usb/az6027.c
@@ -1080,16 +1080,27 @@ static int az6027_identify_state(struct usb_device *udev,
}


+enum {
+ AZUREWAVE_AZ6027,
+ TERRATEC_DVBS2CI_V1,
+ TERRATEC_DVBS2CI_V2,
+ TECHNISAT_USB2_HDCI_V1,
+ TECHNISAT_USB2_HDCI_V2,
+ ELGATO_EYETV_SAT,
+ ELGATO_EYETV_SAT_V2,
+ ELGATO_EYETV_SAT_V3,
+};
+
static struct usb_device_id az6027_usb_table[] = {
- { USB_DEVICE(USB_VID_AZUREWAVE, USB_PID_AZUREWAVE_AZ6027) },
- { USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_DVBS2CI_V1) },
- { USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_DVBS2CI_V2) },
- { USB_DEVICE(USB_VID_TECHNISAT, USB_PID_TECHNISAT_USB2_HDCI_V1) },
- { USB_DEVICE(USB_VID_TECHNISAT, USB_PID_TECHNISAT_USB2_HDCI_V2) },
- { USB_DEVICE(USB_VID_ELGATO, USB_PID_ELGATO_EYETV_SAT) },
- { USB_DEVICE(USB_VID_ELGATO, USB_PID_ELGATO_EYETV_SAT_V2) },
- { USB_DEVICE(USB_VID_ELGATO, USB_PID_ELGATO_EYETV_SAT_V3) },
- { },
+ DVB_USB_DEV(AZUREWAVE, AZUREWAVE_AZ6027),
+ DVB_USB_DEV(TERRATEC, TERRATEC_DVBS2CI_V1),
+ DVB_USB_DEV(TERRATEC, TERRATEC_DVBS2CI_V2),
+ DVB_USB_DEV(TECHNISAT, TECHNISAT_USB2_HDCI_V1),
+ DVB_USB_DEV(TECHNISAT, TECHNISAT_USB2_HDCI_V2),
+ DVB_USB_DEV(ELGATO, ELGATO_EYETV_SAT),
+ DVB_USB_DEV(ELGATO, ELGATO_EYETV_SAT_V2),
+ DVB_USB_DEV(ELGATO, ELGATO_EYETV_SAT_V3),
+ { }
};

MODULE_DEVICE_TABLE(usb, az6027_usb_table);
@@ -1141,35 +1152,35 @@ static struct dvb_usb_device_properties az6027_properties = {
.devices = {
{
.name = "AZUREWAVE DVB-S/S2 USB2.0 (AZ6027)",
- .cold_ids = { &az6027_usb_table[0], NULL },
+ .cold_ids = { &az6027_usb_table[AZUREWAVE_AZ6027], NULL },
.warm_ids = { NULL },
}, {
.name = "TERRATEC S7",
- .cold_ids = { &az6027_usb_table[1], NULL },
+ .cold_ids = { &az6027_usb_table[TERRATEC_DVBS2CI_V1], NULL },
.warm_ids = { NULL },
}, {
.name = "TERRATEC S7 MKII",
- .cold_ids = { &az6027_usb_table[2], NULL },
+ .cold_ids = { &az6027_usb_table[TERRATEC_DVBS2CI_V2], NULL },
.warm_ids = { NULL },
}, {
.name = "Technisat SkyStar USB 2 HD CI",
- .cold_ids = { &az6027_usb_table[3], NULL },
+ .cold_ids = { &az6027_usb_table[TECHNISAT_USB2_HDCI_V1], NULL },
.warm_ids = { NULL },
}, {
.name = "Technisat SkyStar USB 2 HD CI",
- .cold_ids = { &az6027_usb_table[4], NULL },
+ .cold_ids = { &az6027_usb_table[TECHNISAT_USB2_HDCI_V2], NULL },
.warm_ids = { NULL },
}, {
.name = "Elgato EyeTV Sat",
- .cold_ids = { &az6027_usb_table[5], NULL },
+ .cold_ids = { &az6027_usb_table[ELGATO_EYETV_SAT], NULL },
.warm_ids = { NULL },
}, {
.name = "Elgato EyeTV Sat",
- .cold_ids = { &az6027_usb_table[6], NULL },
+ .cold_ids = { &az6027_usb_table[ELGATO_EYETV_SAT_V2], NULL },
.warm_ids = { NULL },
}, {
.name = "Elgato EyeTV Sat",
- .cold_ids = { &az6027_usb_table[7], NULL },
+ .cold_ids = { &az6027_usb_table[ELGATO_EYETV_SAT_V3], NULL },
.warm_ids = { NULL },
},
{ NULL },
--
2.35.1