Em Sat, 26 Mar 2022 15:11:46 -0500
Larry Finger <[email protected]> escreveu:
> On 3/26/22 14:51, Joe Perches wrote:
> > On Sat, 2022-03-26 at 19:27 +0100, Mauro Carvalho Chehab wrote:
> >> Em Sat, 26 Mar 2022 19:24:54 +0100
> >> Mauro Carvalho Chehab <[email protected]> escreveu:
> >>
> >>> Em Sat, 26 Mar 2022 17:59:03 +0100
> >>> Benjamin Stürz <[email protected]> escreveu:
> >>>
> >>>> This replaces comments with C99's designated
> >>>> initializers because the kernel supports them now.
> >>>>
> >>>> Signed-off-by: Benjamin Stürz <[email protected]>
> >>>> ---
> >>>> drivers/media/usb/dvb-usb/dibusb-mb.c | 62 +++++++++++++--------------
> >>>> drivers/media/usb/dvb-usb/dibusb-mc.c | 34 +++++++--------
> >>>> 2 files changed, 48 insertions(+), 48 deletions(-)
> >>>>
> >>>> diff --git a/drivers/media/usb/dvb-usb/dibusb-mb.c b/drivers/media/usb/dvb-usb/dibusb-mb.c
> >>>> index e9dc27f73970..f188e07f518b 100644
> >>>> --- a/drivers/media/usb/dvb-usb/dibusb-mb.c
> >>>> +++ b/drivers/media/usb/dvb-usb/dibusb-mb.c
> >>>> @@ -122,40 +122,40 @@ static int dibusb_probe(struct usb_interface *intf,
> >>>>
> >>>> /* do not change the order of the ID table */
> >>>> static struct usb_device_id dibusb_dib3000mb_table [] = {
> >>>> -/* 00 */ { USB_DEVICE(USB_VID_WIDEVIEW, USB_PID_AVERMEDIA_DVBT_USB_COLD) },
> >>>> -/* 01 */ { USB_DEVICE(USB_VID_WIDEVIEW, USB_PID_AVERMEDIA_DVBT_USB_WARM) },
> >>>> -/* 02 */ { USB_DEVICE(USB_VID_COMPRO, USB_PID_COMPRO_DVBU2000_COLD) },
> >>>> -/* 03 */ { USB_DEVICE(USB_VID_COMPRO, USB_PID_COMPRO_DVBU2000_WARM) },
> >>>> -/* 04 */ { USB_DEVICE(USB_VID_COMPRO_UNK, USB_PID_COMPRO_DVBU2000_UNK_COLD) },
> >>>> -/* 05 */ { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_MOD3000_COLD) },
> >>>> -/* 06 */ { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_MOD3000_WARM) },
> >>>> -/* 07 */ { USB_DEVICE(USB_VID_EMPIA, USB_PID_KWORLD_VSTREAM_COLD) },
> >>>> -/* 08 */ { USB_DEVICE(USB_VID_EMPIA, USB_PID_KWORLD_VSTREAM_WARM) },
> >>>> -/* 09 */ { USB_DEVICE(USB_VID_GRANDTEC, USB_PID_GRANDTEC_DVBT_USB_COLD) },
> >>>> -/* 10 */ { USB_DEVICE(USB_VID_GRANDTEC, USB_PID_GRANDTEC_DVBT_USB_WARM) },
> >>>> -/* 11 */ { USB_DEVICE(USB_VID_GRANDTEC, USB_PID_DIBCOM_MOD3000_COLD) },
> >>>> -/* 12 */ { USB_DEVICE(USB_VID_GRANDTEC, USB_PID_DIBCOM_MOD3000_WARM) },
> >>>> -/* 13 */ { USB_DEVICE(USB_VID_HYPER_PALTEK, USB_PID_UNK_HYPER_PALTEK_COLD) },
> >>>> -/* 14 */ { USB_DEVICE(USB_VID_HYPER_PALTEK, USB_PID_UNK_HYPER_PALTEK_WARM) },
> >>>> -/* 15 */ { USB_DEVICE(USB_VID_VISIONPLUS, USB_PID_TWINHAN_VP7041_COLD) },
> >>>> -/* 16 */ { USB_DEVICE(USB_VID_VISIONPLUS, USB_PID_TWINHAN_VP7041_WARM) },
> >>>> -/* 17 */ { USB_DEVICE(USB_VID_TWINHAN, USB_PID_TWINHAN_VP7041_COLD) },
> >>>> -/* 18 */ { USB_DEVICE(USB_VID_TWINHAN, USB_PID_TWINHAN_VP7041_WARM) },
> >>>> -/* 19 */ { USB_DEVICE(USB_VID_ULTIMA_ELECTRONIC, USB_PID_ULTIMA_TVBOX_COLD) },
> >>>> -/* 20 */ { USB_DEVICE(USB_VID_ULTIMA_ELECTRONIC, USB_PID_ULTIMA_TVBOX_WARM) },
> >>>> -/* 21 */ { USB_DEVICE(USB_VID_ULTIMA_ELECTRONIC, USB_PID_ULTIMA_TVBOX_AN2235_COLD) },
> >>>> -/* 22 */ { USB_DEVICE(USB_VID_ULTIMA_ELECTRONIC, USB_PID_ULTIMA_TVBOX_AN2235_WARM) },
> >>>> -/* 23 */ { USB_DEVICE(USB_VID_ADSTECH, USB_PID_ADSTECH_USB2_COLD) },
> >>>> +[0] = { USB_DEVICE(USB_VID_WIDEVIEW, USB_PID_AVERMEDIA_DVBT_USB_COLD) },
> >>>> +[1] = { USB_DEVICE(USB_VID_WIDEVIEW, USB_PID_AVERMEDIA_DVBT_USB_WARM) },
> >>>
> >>> While here, please properly indent this table, and respect the 80-columns limit,
> >>> e. g.:
> >>>
> >>> static struct usb_device_id dibusb_dib3000mb_table [] = {
> >>> [0] = { USB_DEVICE(USB_VID_WIDEVIEW
> >>> USB_PID_AVERMEDIA_DVBT_USB_COLD)
> >>> },
> >>> [1] = { USB_DEVICE(USB_VID_WIDEVIEW,
> >>> USB_PID_AVERMEDIA_DVBT_USB_WARM)
> >>> },
> >>> ...
> >>
> >> Err.... something went wrong with my space bar and I ended hitting send to
> >> soon... I meant:
> >>
> >> static struct usb_device_id dibusb_dib3000mb_table [] = {
> >> [0] = { USB_DEVICE(USB_VID_WIDEVIEW
> >> USB_PID_AVERMEDIA_DVBT_USB_COLD)
> >> },
> >> [1] = { USB_DEVICE(USB_VID_WIDEVIEW,
> >> USB_PID_AVERMEDIA_DVBT_USB_WARM)
> >> },
> >> ...
> >> };
> >
> > maybe static const too
> >
> > and
> >
> > maybe
> >
> > #define DIB_DEVICE(vid, pid) \
> > { USB_DEVICE(USB_VID_ ## vid, USB_PID_ ## pid) }
> >
> > so maybe
> >
> > static const struct usb_device_id dibusb_dib3000mb_table[] = {
> > [0] = DIB_DEVICE(WIDEVIEW, AVERMEDIA_DVBT_USB_COLD),
> > [1] = DIB_DEVICE(WIDEVIEW, AVERMEDIA_DVBT_USB_WARM),
> > ...
> > };
> >
> > though I _really_ doubt the value of the specific indexing.
> >
> > I think this isn't really worth changing at all.
>
> I agree. For the drivers that I maintain, I try to keep the vendor and device
> ids in numerical order. As this table does not require a special order, adding a
> new one in the middle would require redoing all of then after that point. That
> would be pointless work!
Unfortunately, that's not the case for drivers that use the legacy dvb-usb
core, as it has other tables that reference the device IDs from this table
by number.
The best here would be to do something like:
enum {
AVERMEDIA_DVBT_USB_COLD,
AVERMEDIA_DVBT_USB_WARM,
COMPRO_DVBU2000_COLD,
COMPRO_DVBU2000_WARM,
COMPRO_DVBU2000_UNK_COLD,
DIBCOM_MOD3000_COLD,
DIBCOM_MOD3000_WARM,
KWORLD_VSTREAM_COLD,
KWORLD_VSTREAM_WARM,
GRANDTEC_DVBT_USB_COLD,
GRANDTEC_DVBT_USB_WARM,
DIBCOM_MOD3000_COLD,
DIBCOM_MOD3000_WARM,
UNK_HYPER_PALTEK_COLD,
UNK_HYPER_PALTEK_WARM,
TWINHAN_VP7041_COLD,
TWINHAN_VP7041_WARM,
TWINHAN_VP7041_COLD,
TWINHAN_VP7041_WARM,
ULTIMA_TVBOX_COLD,
ULTIMA_TVBOX_WARM,
ULTIMA_TVBOX_AN2235_COLD,
ULTIMA_TVBOX_AN2235_WARM,
ADSTECH_USB2_COLD,
ADSTECH_USB2_WARM,
KYE_DVB_T_COLD,
KYE_DVB_T_WARM,
KWORLD_VSTREAM_COLD,
ULTIMA_TVBOX_USB2_COLD,
ULTIMA_TVBOX_USB2_WARM,
ULTIMA_TVBOX_ANCHOR_COLD,
};
Then define the table as:
static const struct usb_device_id dibusb_dib3000mb_table[]
{
[AVERMEDIA_DVBT_USB_COLD] = { USB_DEVICE(USB_VID_WIDEVIEW,
USB_PID_AVERMEDIA_DVBT_USB_COLD)
},
[AVERMEDIA_DVBT_USB_WARM] = { USB_DEVICE(USB_VID_WIDEVIEW,
USB_PID_AVERMEDIA_DVBT_USB_WARM)
},
...
}
(eventually, using some macro to help defining them)
Finally, change the other static tables to also use the same name,
e. g.:
static const struct dvb_usb_device_properties dibusb1_1_properties = {
...
.num_device_descs = 9,
.devices = {
{ "AVerMedia AverTV DVBT USB1.1",
{ &dibusb_dib3000mb_table[AVERMEDIA_DVBT_USB_COLD], NULL },
{ &dibusb_dib3000mb_table[AVERMEDIA_DVBT_USB_WARM], NULL },
},
...
};
The same applies to other drivers inside drivers/media/usb/dvb-usb/.
Alternatively, the drivers there should be ported to the newer DVB USB
core (dvb-usb-v2).
Thanks,
Mauro
Replace comments telling the index with explicit designators and make
the array entries more compact to aid in better readability.
It was suggested to make the arrays const, but that didn't compile.
Signed-off-by: Benjamin Stürz <[email protected]>
---
drivers/media/usb/dvb-usb/dibusb-mb.c | 69 ++++++++++++++-------------
drivers/media/usb/dvb-usb/dibusb-mc.c | 39 ++++++++-------
2 files changed, 59 insertions(+), 49 deletions(-)
diff --git a/drivers/media/usb/dvb-usb/dibusb-mb.c
b/drivers/media/usb/dvb-usb/dibusb-mb.c
index e9dc27f73970..ec1fb30c5665 100644
--- a/drivers/media/usb/dvb-usb/dibusb-mb.c
+++ b/drivers/media/usb/dvb-usb/dibusb-mb.c
@@ -120,42 +120,45 @@ static int dibusb_probe(struct usb_interface *intf,
return -EINVAL;
}
+#define DIB_DEVICE(vid, pid) \
+ { USB_DEVICE(USB_VID_##vid, USB_PID_##pid) }
+
/* do not change the order of the ID table */
static struct usb_device_id dibusb_dib3000mb_table [] = {
-/* 00 */ { USB_DEVICE(USB_VID_WIDEVIEW,
USB_PID_AVERMEDIA_DVBT_USB_COLD) },
-/* 01 */ { USB_DEVICE(USB_VID_WIDEVIEW,
USB_PID_AVERMEDIA_DVBT_USB_WARM) },
-/* 02 */ { USB_DEVICE(USB_VID_COMPRO, USB_PID_COMPRO_DVBU2000_COLD) },
-/* 03 */ { USB_DEVICE(USB_VID_COMPRO, USB_PID_COMPRO_DVBU2000_WARM) },
-/* 04 */ { USB_DEVICE(USB_VID_COMPRO_UNK,
USB_PID_COMPRO_DVBU2000_UNK_COLD) },
-/* 05 */ { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_MOD3000_COLD) },
-/* 06 */ { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_MOD3000_WARM) },
-/* 07 */ { USB_DEVICE(USB_VID_EMPIA, USB_PID_KWORLD_VSTREAM_COLD) },
-/* 08 */ { USB_DEVICE(USB_VID_EMPIA, USB_PID_KWORLD_VSTREAM_WARM) },
-/* 09 */ { USB_DEVICE(USB_VID_GRANDTEC, USB_PID_GRANDTEC_DVBT_USB_COLD) },
-/* 10 */ { USB_DEVICE(USB_VID_GRANDTEC, USB_PID_GRANDTEC_DVBT_USB_WARM) },
-/* 11 */ { USB_DEVICE(USB_VID_GRANDTEC, USB_PID_DIBCOM_MOD3000_COLD) },
-/* 12 */ { USB_DEVICE(USB_VID_GRANDTEC, USB_PID_DIBCOM_MOD3000_WARM) },
-/* 13 */ { USB_DEVICE(USB_VID_HYPER_PALTEK,
USB_PID_UNK_HYPER_PALTEK_COLD) },
-/* 14 */ { USB_DEVICE(USB_VID_HYPER_PALTEK,
USB_PID_UNK_HYPER_PALTEK_WARM) },
-/* 15 */ { USB_DEVICE(USB_VID_VISIONPLUS, USB_PID_TWINHAN_VP7041_COLD) },
-/* 16 */ { USB_DEVICE(USB_VID_VISIONPLUS, USB_PID_TWINHAN_VP7041_WARM) },
-/* 17 */ { USB_DEVICE(USB_VID_TWINHAN, USB_PID_TWINHAN_VP7041_COLD) },
-/* 18 */ { USB_DEVICE(USB_VID_TWINHAN, USB_PID_TWINHAN_VP7041_WARM) },
-/* 19 */ { USB_DEVICE(USB_VID_ULTIMA_ELECTRONIC,
USB_PID_ULTIMA_TVBOX_COLD) },
-/* 20 */ { USB_DEVICE(USB_VID_ULTIMA_ELECTRONIC,
USB_PID_ULTIMA_TVBOX_WARM) },
-/* 21 */ { USB_DEVICE(USB_VID_ULTIMA_ELECTRONIC,
USB_PID_ULTIMA_TVBOX_AN2235_COLD) },
-/* 22 */ { USB_DEVICE(USB_VID_ULTIMA_ELECTRONIC,
USB_PID_ULTIMA_TVBOX_AN2235_WARM) },
-/* 23 */ { USB_DEVICE(USB_VID_ADSTECH, USB_PID_ADSTECH_USB2_COLD) },
+ [0] = DIB_DEVICE(WIDEVIEW, AVERMEDIA_DVBT_USB_COLD),
+ [1] = DIB_DEVICE(WIDEVIEW, AVERMEDIA_DVBT_USB_WARM),
+ [2] = DIB_DEVICE(COMPRO, COMPRO_DVBU2000_COLD),
+ [3] = DIB_DEVICE(COMPRO, COMPRO_DVBU2000_WARM),
+ [4] = DIB_DEVICE(COMPRO_UNK, COMPRO_DVBU2000_UNK_COLD),
+ [5] = DIB_DEVICE(DIBCOM, DIBCOM_MOD3000_COLD),
+ [6] = DIB_DEVICE(DIBCOM, DIBCOM_MOD3000_WARM),
+ [7] = DIB_DEVICE(EMPIA, KWORLD_VSTREAM_COLD),
+ [8] = DIB_DEVICE(EMPIA, KWORLD_VSTREAM_WARM),
+ [9] = DIB_DEVICE(GRANDTEC, GRANDTEC_DVBT_USB_COLD),
+ [10] = DIB_DEVICE(GRANDTEC, GRANDTEC_DVBT_USB_WARM),
+ [11] = DIB_DEVICE(GRANDTEC, DIBCOM_MOD3000_COLD),
+ [12] = DIB_DEVICE(GRANDTEC, DIBCOM_MOD3000_WARM),
+ [13] = DIB_DEVICE(HYPER_PALTEK, UNK_HYPER_PALTEK_COLD),
+ [14] = DIB_DEVICE(HYPER_PALTEK, UNK_HYPER_PALTEK_WARM),
+ [15] = DIB_DEVICE(VISIONPLUS, TWINHAN_VP7041_COLD),
+ [16] = DIB_DEVICE(VISIONPLUS, TWINHAN_VP7041_WARM),
+ [17] = DIB_DEVICE(TWINHAN, TWINHAN_VP7041_COLD),
+ [18] = DIB_DEVICE(TWINHAN, TWINHAN_VP7041_WARM),
+ [19] = DIB_DEVICE(ULTIMA_ELECTRONIC, ULTIMA_TVBOX_COLD),
+ [20] = DIB_DEVICE(ULTIMA_ELECTRONIC, ULTIMA_TVBOX_WARM),
+ [21] = DIB_DEVICE(ULTIMA_ELECTRONIC, ULTIMA_TVBOX_AN2235_COLD),
+ [22] = DIB_DEVICE(ULTIMA_ELECTRONIC, ULTIMA_TVBOX_AN2235_WARM),
+ [23] = DIB_DEVICE(ADSTECH, ADSTECH_USB2_COLD),
/* device ID with default DIBUSB2_0-firmware and with the hacked
firmware */
-/* 24 */ { USB_DEVICE(USB_VID_ADSTECH, USB_PID_ADSTECH_USB2_WARM) },
-/* 25 */ { USB_DEVICE(USB_VID_KYE, USB_PID_KYE_DVB_T_COLD) },
-/* 26 */ { USB_DEVICE(USB_VID_KYE, USB_PID_KYE_DVB_T_WARM) },
+ [24] = DIB_DEVICE(ADSTECH, ADSTECH_USB2_WARM),
+ [25] = DIB_DEVICE(KYE, KYE_DVB_T_COLD),
+ [26] = DIB_DEVICE(KYE, KYE_DVB_T_WARM),
-/* 27 */ { USB_DEVICE(USB_VID_KWORLD, USB_PID_KWORLD_VSTREAM_COLD) },
+ [27] = DIB_DEVICE(KWORLD, KWORLD_VSTREAM_COLD),
-/* 28 */ { USB_DEVICE(USB_VID_ULTIMA_ELECTRONIC,
USB_PID_ULTIMA_TVBOX_USB2_COLD) },
-/* 29 */ { USB_DEVICE(USB_VID_ULTIMA_ELECTRONIC,
USB_PID_ULTIMA_TVBOX_USB2_WARM) },
+ [28] = DIB_DEVICE(ULTIMA_ELECTRONIC, ULTIMA_TVBOX_USB2_COLD),
+ [29] = DIB_DEVICE(ULTIMA_ELECTRONIC, ULTIMA_TVBOX_USB2_WARM),
/*
* XXX: As Artec just 'forgot' to program the EEPROM on some Artec T1
devices
@@ -166,13 +169,15 @@ static struct usb_device_id dibusb_dib3000mb_table
[] = {
*/
#ifdef CONFIG_DVB_USB_DIBUSB_MB_FAULTY
-/* 30 */ { USB_DEVICE(USB_VID_ANCHOR, USB_PID_ULTIMA_TVBOX_ANCHOR_COLD) },
+ [30] = DIB_DEVICE(ANCHOR, ULTIMA_TVBOX_ANCHOR_COLD),
#endif
- { } /* Terminating entry */
+ { } /* Terminating entry */
};
MODULE_DEVICE_TABLE (usb, dibusb_dib3000mb_table);
+#undef DIB_DEVICE
+
static struct dvb_usb_device_properties dibusb1_1_properties = {
.caps = DVB_USB_IS_AN_I2C_ADAPTER,
diff --git a/drivers/media/usb/dvb-usb/dibusb-mc.c
b/drivers/media/usb/dvb-usb/dibusb-mc.c
index e2689977c8c8..703c2a7df369 100644
--- a/drivers/media/usb/dvb-usb/dibusb-mc.c
+++ b/drivers/media/usb/dvb-usb/dibusb-mc.c
@@ -23,28 +23,33 @@ static int dibusb_mc_probe(struct usb_interface *intf,
NULL, adapter_nr);
}
+#define DIB_DEVICE(vid, pid) \
+ { USB_DEVICE(USB_VID_##vid, USB_PID_##pid) }
+
/* do not change the order of the ID table */
static struct usb_device_id dibusb_dib3000mc_table [] = {
-/* 00 */ { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_MOD3001_COLD) },
-/* 01 */ { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_MOD3001_WARM) },
-/* 02 */ { USB_DEVICE(USB_VID_ULTIMA_ELECTRONIC,
USB_PID_ULTIMA_TVBOX_USB2_COLD) },
-/* 03 */ { USB_DEVICE(USB_VID_ULTIMA_ELECTRONIC,
USB_PID_ULTIMA_TVBOX_USB2_WARM) }, // ( ? )
-/* 04 */ { USB_DEVICE(USB_VID_LITEON, USB_PID_LITEON_DVB_T_COLD) },
-/* 05 */ { USB_DEVICE(USB_VID_LITEON, USB_PID_LITEON_DVB_T_WARM) },
-/* 06 */ { USB_DEVICE(USB_VID_EMPIA, USB_PID_DIGIVOX_MINI_SL_COLD) },
-/* 07 */ { USB_DEVICE(USB_VID_EMPIA, USB_PID_DIGIVOX_MINI_SL_WARM) },
-/* 08 */ { USB_DEVICE(USB_VID_GRANDTEC,
USB_PID_GRANDTEC_DVBT_USB2_COLD) },
-/* 09 */ { USB_DEVICE(USB_VID_GRANDTEC,
USB_PID_GRANDTEC_DVBT_USB2_WARM) },
-/* 10 */ { USB_DEVICE(USB_VID_ULTIMA_ELECTRONIC, USB_PID_ARTEC_T14_COLD) },
-/* 11 */ { USB_DEVICE(USB_VID_ULTIMA_ELECTRONIC, USB_PID_ARTEC_T14_WARM) },
-/* 12 */ { USB_DEVICE(USB_VID_LEADTEK, USB_PID_WINFAST_DTV_DONGLE_COLD) },
-/* 13 */ { USB_DEVICE(USB_VID_LEADTEK, USB_PID_WINFAST_DTV_DONGLE_WARM) },
-/* 14 */ { USB_DEVICE(USB_VID_HUMAX_COEX,
USB_PID_DVB_T_USB_STICK_HIGH_SPEED_COLD) },
-/* 15 */ { USB_DEVICE(USB_VID_HUMAX_COEX,
USB_PID_DVB_T_USB_STICK_HIGH_SPEED_WARM) },
- { } /* Terminating entry */
+ [0] = DIB_DEVICE(DIBCOM, DIBCOM_MOD3001_COLD),
+ [1] = DIB_DEVICE(DIBCOM, DIBCOM_MOD3001_WARM),
+ [2] = DIB_DEVICE(ULTIMA_ELECTRONIC, ULTIMA_TVBOX_USB2_COLD),
+ [3] = DIB_DEVICE(ULTIMA_ELECTRONIC, ULTIMA_TVBOX_USB2_WARM), // ( ? )
+ [4] = DIB_DEVICE(LITEON, LITEON_DVB_T_COLD),
+ [5] = DIB_DEVICE(LITEON, LITEON_DVB_T_WARM),
+ [6] = DIB_DEVICE(EMPIA, DIGIVOX_MINI_SL_COLD),
+ [7] = DIB_DEVICE(EMPIA, DIGIVOX_MINI_SL_WARM),
+ [8] = DIB_DEVICE(GRANDTEC, GRANDTEC_DVBT_USB2_COLD),
+ [9] = DIB_DEVICE(GRANDTEC, GRANDTEC_DVBT_USB2_WARM),
+ [10] = DIB_DEVICE(ULTIMA_ELECTRONIC, ARTEC_T14_COLD),
+ [11] = DIB_DEVICE(ULTIMA_ELECTRONIC, ARTEC_T14_WARM),
+ [12] = DIB_DEVICE(LEADTEK, WINFAST_DTV_DONGLE_COLD),
+ [13] = DIB_DEVICE(LEADTEK, WINFAST_DTV_DONGLE_WARM),
+ [14] = DIB_DEVICE(HUMAX_COEX, DVB_T_USB_STICK_HIGH_SPEED_COLD),
+ [15] = DIB_DEVICE(HUMAX_COEX, DVB_T_USB_STICK_HIGH_SPEED_WARM),
+ { } /* Terminating entry */
};
MODULE_DEVICE_TABLE (usb, dibusb_dib3000mc_table);
+#undef DIB_DEVICE
+
static struct dvb_usb_device_properties dibusb_mc_properties = {
.caps = DVB_USB_IS_AN_I2C_ADAPTER,
--
2.35.1
Em Mon, 28 Mar 2022 20:08:30 +0200
Benjamin Stürz <[email protected]> escreveu:
> Replace comments telling the index with explicit designators and make
> the array entries more compact to aid in better readability.
Just using designated initializers is not enough for dvb-usb, as the
big issue there is really the fact that the dvb-usb struct needs to point
to the entries inside the USB ID table.
Also, your patch touches only two of the several dvb-usb drivers. So,
I ended taking some time and writing a series:
https://lore.kernel.org/linux-media/[email protected]/T/#t
Giving you credits for suggesting it at the dibusb-* patches.
> It was suggested to make the arrays const, but that didn't compile.
Yeah, the struct that points to it is not marked as const, as there
are a couple of drivers that actually change some things there.
As I said, the real fix would be to just migrate the drivers from
the legacy dvb-usb core to the newer dvb-usb-v2.
But, at least with the newer series, the risk of pointing to the
wrong entry is reduced.
Regards,
Mauro
>
> Signed-off-by: Benjamin Stürz <[email protected]>
> ---
> drivers/media/usb/dvb-usb/dibusb-mb.c | 69 ++++++++++++++-------------
> drivers/media/usb/dvb-usb/dibusb-mc.c | 39 ++++++++-------
> 2 files changed, 59 insertions(+), 49 deletions(-)
>
> diff --git a/drivers/media/usb/dvb-usb/dibusb-mb.c
> b/drivers/media/usb/dvb-usb/dibusb-mb.c
> index e9dc27f73970..ec1fb30c5665 100644
> --- a/drivers/media/usb/dvb-usb/dibusb-mb.c
> +++ b/drivers/media/usb/dvb-usb/dibusb-mb.c
> @@ -120,42 +120,45 @@ static int dibusb_probe(struct usb_interface *intf,
> return -EINVAL;
> }
>
> +#define DIB_DEVICE(vid, pid) \
> + { USB_DEVICE(USB_VID_##vid, USB_PID_##pid) }
> +
> /* do not change the order of the ID table */
> static struct usb_device_id dibusb_dib3000mb_table [] = {
> -/* 00 */ { USB_DEVICE(USB_VID_WIDEVIEW,
> USB_PID_AVERMEDIA_DVBT_USB_COLD) },
> -/* 01 */ { USB_DEVICE(USB_VID_WIDEVIEW,
> USB_PID_AVERMEDIA_DVBT_USB_WARM) },
> -/* 02 */ { USB_DEVICE(USB_VID_COMPRO, USB_PID_COMPRO_DVBU2000_COLD) },
> -/* 03 */ { USB_DEVICE(USB_VID_COMPRO, USB_PID_COMPRO_DVBU2000_WARM) },
> -/* 04 */ { USB_DEVICE(USB_VID_COMPRO_UNK,
> USB_PID_COMPRO_DVBU2000_UNK_COLD) },
> -/* 05 */ { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_MOD3000_COLD) },
> -/* 06 */ { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_MOD3000_WARM) },
> -/* 07 */ { USB_DEVICE(USB_VID_EMPIA, USB_PID_KWORLD_VSTREAM_COLD) },
> -/* 08 */ { USB_DEVICE(USB_VID_EMPIA, USB_PID_KWORLD_VSTREAM_WARM) },
> -/* 09 */ { USB_DEVICE(USB_VID_GRANDTEC, USB_PID_GRANDTEC_DVBT_USB_COLD) },
> -/* 10 */ { USB_DEVICE(USB_VID_GRANDTEC, USB_PID_GRANDTEC_DVBT_USB_WARM) },
> -/* 11 */ { USB_DEVICE(USB_VID_GRANDTEC, USB_PID_DIBCOM_MOD3000_COLD) },
> -/* 12 */ { USB_DEVICE(USB_VID_GRANDTEC, USB_PID_DIBCOM_MOD3000_WARM) },
> -/* 13 */ { USB_DEVICE(USB_VID_HYPER_PALTEK,
> USB_PID_UNK_HYPER_PALTEK_COLD) },
> -/* 14 */ { USB_DEVICE(USB_VID_HYPER_PALTEK,
> USB_PID_UNK_HYPER_PALTEK_WARM) },
> -/* 15 */ { USB_DEVICE(USB_VID_VISIONPLUS, USB_PID_TWINHAN_VP7041_COLD) },
> -/* 16 */ { USB_DEVICE(USB_VID_VISIONPLUS, USB_PID_TWINHAN_VP7041_WARM) },
> -/* 17 */ { USB_DEVICE(USB_VID_TWINHAN, USB_PID_TWINHAN_VP7041_COLD) },
> -/* 18 */ { USB_DEVICE(USB_VID_TWINHAN, USB_PID_TWINHAN_VP7041_WARM) },
> -/* 19 */ { USB_DEVICE(USB_VID_ULTIMA_ELECTRONIC,
> USB_PID_ULTIMA_TVBOX_COLD) },
> -/* 20 */ { USB_DEVICE(USB_VID_ULTIMA_ELECTRONIC,
> USB_PID_ULTIMA_TVBOX_WARM) },
> -/* 21 */ { USB_DEVICE(USB_VID_ULTIMA_ELECTRONIC,
> USB_PID_ULTIMA_TVBOX_AN2235_COLD) },
> -/* 22 */ { USB_DEVICE(USB_VID_ULTIMA_ELECTRONIC,
> USB_PID_ULTIMA_TVBOX_AN2235_WARM) },
> -/* 23 */ { USB_DEVICE(USB_VID_ADSTECH, USB_PID_ADSTECH_USB2_COLD) },
> + [0] = DIB_DEVICE(WIDEVIEW, AVERMEDIA_DVBT_USB_COLD),
> + [1] = DIB_DEVICE(WIDEVIEW, AVERMEDIA_DVBT_USB_WARM),
> + [2] = DIB_DEVICE(COMPRO, COMPRO_DVBU2000_COLD),
> + [3] = DIB_DEVICE(COMPRO, COMPRO_DVBU2000_WARM),
> + [4] = DIB_DEVICE(COMPRO_UNK, COMPRO_DVBU2000_UNK_COLD),
> + [5] = DIB_DEVICE(DIBCOM, DIBCOM_MOD3000_COLD),
> + [6] = DIB_DEVICE(DIBCOM, DIBCOM_MOD3000_WARM),
> + [7] = DIB_DEVICE(EMPIA, KWORLD_VSTREAM_COLD),
> + [8] = DIB_DEVICE(EMPIA, KWORLD_VSTREAM_WARM),
> + [9] = DIB_DEVICE(GRANDTEC, GRANDTEC_DVBT_USB_COLD),
> + [10] = DIB_DEVICE(GRANDTEC, GRANDTEC_DVBT_USB_WARM),
> + [11] = DIB_DEVICE(GRANDTEC, DIBCOM_MOD3000_COLD),
> + [12] = DIB_DEVICE(GRANDTEC, DIBCOM_MOD3000_WARM),
> + [13] = DIB_DEVICE(HYPER_PALTEK, UNK_HYPER_PALTEK_COLD),
> + [14] = DIB_DEVICE(HYPER_PALTEK, UNK_HYPER_PALTEK_WARM),
> + [15] = DIB_DEVICE(VISIONPLUS, TWINHAN_VP7041_COLD),
> + [16] = DIB_DEVICE(VISIONPLUS, TWINHAN_VP7041_WARM),
> + [17] = DIB_DEVICE(TWINHAN, TWINHAN_VP7041_COLD),
> + [18] = DIB_DEVICE(TWINHAN, TWINHAN_VP7041_WARM),
> + [19] = DIB_DEVICE(ULTIMA_ELECTRONIC, ULTIMA_TVBOX_COLD),
> + [20] = DIB_DEVICE(ULTIMA_ELECTRONIC, ULTIMA_TVBOX_WARM),
> + [21] = DIB_DEVICE(ULTIMA_ELECTRONIC, ULTIMA_TVBOX_AN2235_COLD),
> + [22] = DIB_DEVICE(ULTIMA_ELECTRONIC, ULTIMA_TVBOX_AN2235_WARM),
> + [23] = DIB_DEVICE(ADSTECH, ADSTECH_USB2_COLD),
>
> /* device ID with default DIBUSB2_0-firmware and with the hacked
> firmware */
> -/* 24 */ { USB_DEVICE(USB_VID_ADSTECH, USB_PID_ADSTECH_USB2_WARM) },
> -/* 25 */ { USB_DEVICE(USB_VID_KYE, USB_PID_KYE_DVB_T_COLD) },
> -/* 26 */ { USB_DEVICE(USB_VID_KYE, USB_PID_KYE_DVB_T_WARM) },
> + [24] = DIB_DEVICE(ADSTECH, ADSTECH_USB2_WARM),
> + [25] = DIB_DEVICE(KYE, KYE_DVB_T_COLD),
> + [26] = DIB_DEVICE(KYE, KYE_DVB_T_WARM),
>
> -/* 27 */ { USB_DEVICE(USB_VID_KWORLD, USB_PID_KWORLD_VSTREAM_COLD) },
> + [27] = DIB_DEVICE(KWORLD, KWORLD_VSTREAM_COLD),
>
> -/* 28 */ { USB_DEVICE(USB_VID_ULTIMA_ELECTRONIC,
> USB_PID_ULTIMA_TVBOX_USB2_COLD) },
> -/* 29 */ { USB_DEVICE(USB_VID_ULTIMA_ELECTRONIC,
> USB_PID_ULTIMA_TVBOX_USB2_WARM) },
> + [28] = DIB_DEVICE(ULTIMA_ELECTRONIC, ULTIMA_TVBOX_USB2_COLD),
> + [29] = DIB_DEVICE(ULTIMA_ELECTRONIC, ULTIMA_TVBOX_USB2_WARM),
>
> /*
> * XXX: As Artec just 'forgot' to program the EEPROM on some Artec T1
> devices
> @@ -166,13 +169,15 @@ static struct usb_device_id dibusb_dib3000mb_table
> [] = {
> */
>
> #ifdef CONFIG_DVB_USB_DIBUSB_MB_FAULTY
> -/* 30 */ { USB_DEVICE(USB_VID_ANCHOR, USB_PID_ULTIMA_TVBOX_ANCHOR_COLD) },
> + [30] = DIB_DEVICE(ANCHOR, ULTIMA_TVBOX_ANCHOR_COLD),
> #endif
>
> - { } /* Terminating entry */
> + { } /* Terminating entry */
> };
> MODULE_DEVICE_TABLE (usb, dibusb_dib3000mb_table);
>
> +#undef DIB_DEVICE
> +
> static struct dvb_usb_device_properties dibusb1_1_properties = {
> .caps = DVB_USB_IS_AN_I2C_ADAPTER,
>
> diff --git a/drivers/media/usb/dvb-usb/dibusb-mc.c
> b/drivers/media/usb/dvb-usb/dibusb-mc.c
> index e2689977c8c8..703c2a7df369 100644
> --- a/drivers/media/usb/dvb-usb/dibusb-mc.c
> +++ b/drivers/media/usb/dvb-usb/dibusb-mc.c
> @@ -23,28 +23,33 @@ static int dibusb_mc_probe(struct usb_interface *intf,
> NULL, adapter_nr);
> }
>
> +#define DIB_DEVICE(vid, pid) \
> + { USB_DEVICE(USB_VID_##vid, USB_PID_##pid) }
> +
> /* do not change the order of the ID table */
> static struct usb_device_id dibusb_dib3000mc_table [] = {
> -/* 00 */ { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_MOD3001_COLD) },
> -/* 01 */ { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_MOD3001_WARM) },
> -/* 02 */ { USB_DEVICE(USB_VID_ULTIMA_ELECTRONIC,
> USB_PID_ULTIMA_TVBOX_USB2_COLD) },
> -/* 03 */ { USB_DEVICE(USB_VID_ULTIMA_ELECTRONIC,
> USB_PID_ULTIMA_TVBOX_USB2_WARM) }, // ( ? )
> -/* 04 */ { USB_DEVICE(USB_VID_LITEON, USB_PID_LITEON_DVB_T_COLD) },
> -/* 05 */ { USB_DEVICE(USB_VID_LITEON, USB_PID_LITEON_DVB_T_WARM) },
> -/* 06 */ { USB_DEVICE(USB_VID_EMPIA, USB_PID_DIGIVOX_MINI_SL_COLD) },
> -/* 07 */ { USB_DEVICE(USB_VID_EMPIA, USB_PID_DIGIVOX_MINI_SL_WARM) },
> -/* 08 */ { USB_DEVICE(USB_VID_GRANDTEC,
> USB_PID_GRANDTEC_DVBT_USB2_COLD) },
> -/* 09 */ { USB_DEVICE(USB_VID_GRANDTEC,
> USB_PID_GRANDTEC_DVBT_USB2_WARM) },
> -/* 10 */ { USB_DEVICE(USB_VID_ULTIMA_ELECTRONIC, USB_PID_ARTEC_T14_COLD) },
> -/* 11 */ { USB_DEVICE(USB_VID_ULTIMA_ELECTRONIC, USB_PID_ARTEC_T14_WARM) },
> -/* 12 */ { USB_DEVICE(USB_VID_LEADTEK, USB_PID_WINFAST_DTV_DONGLE_COLD) },
> -/* 13 */ { USB_DEVICE(USB_VID_LEADTEK, USB_PID_WINFAST_DTV_DONGLE_WARM) },
> -/* 14 */ { USB_DEVICE(USB_VID_HUMAX_COEX,
> USB_PID_DVB_T_USB_STICK_HIGH_SPEED_COLD) },
> -/* 15 */ { USB_DEVICE(USB_VID_HUMAX_COEX,
> USB_PID_DVB_T_USB_STICK_HIGH_SPEED_WARM) },
> - { } /* Terminating entry */
> + [0] = DIB_DEVICE(DIBCOM, DIBCOM_MOD3001_COLD),
> + [1] = DIB_DEVICE(DIBCOM, DIBCOM_MOD3001_WARM),
> + [2] = DIB_DEVICE(ULTIMA_ELECTRONIC, ULTIMA_TVBOX_USB2_COLD),
> + [3] = DIB_DEVICE(ULTIMA_ELECTRONIC, ULTIMA_TVBOX_USB2_WARM), // ( ? )
> + [4] = DIB_DEVICE(LITEON, LITEON_DVB_T_COLD),
> + [5] = DIB_DEVICE(LITEON, LITEON_DVB_T_WARM),
> + [6] = DIB_DEVICE(EMPIA, DIGIVOX_MINI_SL_COLD),
> + [7] = DIB_DEVICE(EMPIA, DIGIVOX_MINI_SL_WARM),
> + [8] = DIB_DEVICE(GRANDTEC, GRANDTEC_DVBT_USB2_COLD),
> + [9] = DIB_DEVICE(GRANDTEC, GRANDTEC_DVBT_USB2_WARM),
> + [10] = DIB_DEVICE(ULTIMA_ELECTRONIC, ARTEC_T14_COLD),
> + [11] = DIB_DEVICE(ULTIMA_ELECTRONIC, ARTEC_T14_WARM),
> + [12] = DIB_DEVICE(LEADTEK, WINFAST_DTV_DONGLE_COLD),
> + [13] = DIB_DEVICE(LEADTEK, WINFAST_DTV_DONGLE_WARM),
> + [14] = DIB_DEVICE(HUMAX_COEX, DVB_T_USB_STICK_HIGH_SPEED_COLD),
> + [15] = DIB_DEVICE(HUMAX_COEX, DVB_T_USB_STICK_HIGH_SPEED_WARM),
> + { } /* Terminating entry */
> };
> MODULE_DEVICE_TABLE (usb, dibusb_dib3000mc_table);
>
> +#undef DIB_DEVICE
> +
> static struct dvb_usb_device_properties dibusb_mc_properties = {
> .caps = DVB_USB_IS_AN_I2C_ADAPTER,
>
Thanks,
Mauro