On Sat, 13 Mar 2021, Edmundo Carmona Antoranz wrote: > Hello! > > I just found a piece of code that I think can be improved somewhat (in > drivers/staging/vt6655/channel.c) > > switch (priv->byRFType) { > case RF_AIROHA7230: > case RF_UW2452: > case RF_NOTHING: > default: > ch = vnt_channels_5ghz; > > for (i = 0; i < ARRAY_SIZE(vnt_channels_5ghz); i++) { > ch[i].max_power = 0x3f; > ch[i].flags = IEEE80211_CHAN_NO_HT40; > } > > priv->hw->wiphy->bands[NL80211_BAND_5GHZ] = > &vnt_supported_5ghz_band; > fallthrough; > case RF_RFMD2959: > case RF_AIROHA: > case RF_AL2230S: > case RF_UW2451: > case RF_VT3226: > ch = vnt_channels_2ghz; > > for (i = 0; i < ARRAY_SIZE(vnt_channels_2ghz); i++) { > ch[i].max_power = 0x3f; > ch[i].flags = IEEE80211_CHAN_NO_HT40; > } > > priv->hw->wiphy->bands[NL80211_BAND_2GHZ] = > &vnt_supported_2ghz_band; > break; > } > > There are two sections of code that could be turned into a function or > macro so that duplication can be avoided. Is it within our "Scope of > Work" as janitors to make this kind of proposal or it's better if we > avoid it and start easy at first? In principle, you can do whatever you like in staging. If the maintainer doesn't like your suggestion, they can reject it. This looks not entirely trivial, because the thing you want to abstract over is used once as a variable and once for its address. I guess you can pass in the address and then dereference it, but you would have to check that that works ok with ARRAY_SIZE, which is also a macro. You would also need to understand the code well enough to give this new function a resonable name. julia