On 28.03.2025 11:10:23, Geert Uytterhoeven wrote: > > Gen4 has 8 channels (GENMASK(16, 23) > > G3E has 6 channels (GENMASK(16, 21) > > V4M has 4 channels (GENMASK(16, 19) > > V3H_2 has 3 channels (GENMASK(16,18) > > All other SoCs has 2 channels (GENMASK(16,17) > > > > So you mean, I should replace RCANFD_GERFL_EEF0_7 with a > > > > Generic one RCANFD_GERFL_EEF(x) GENMASK(16, 16 + (x) - 1) to handle > > this differences > > > > Where x is the number of supported channels(info->max_channels) > > > > and then use > > > > FIELD_PREP(RCANFD_GERFL_EEF(x), gpriv->channels_mask) > > Just use > > #define RCANFD_GERFL_EEF GENMASK(23, 16) > > and > > FIELD_PREP(RCANFD_GERFL_EEF, gpriv->channels_mask) > > As channels_mask can never have bits set for non-existing channels, > all reserved bits above EEF in the GERFL register will be zero. That's even better than computing the mask at runtime! Marc -- Pengutronix e.K. | Marc Kleine-Budde | Embedded Linux | https://www.pengutronix.de | Vertretung Nürnberg | Phone: +49-5121-206917-129 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-9 |
Attachment:
signature.asc
Description: PGP signature