[PATCH] wifi: mt76: mt7915: add chip id condition in mt7915_check_eeprom()

Julian Calaby julian.calaby at gmail.com
Thu Dec 8 15:14:50 PST 2022


Hi Shayne,

On Fri, Dec 9, 2022 at 3:06 AM Shayne Chen <shayne.chen at mediatek.com> wrote:
>
> When flash mode is enabled, and the eeprom data in the flash is not for
> the current chipset, it'll still be checked valid, and the default
> eeprom bin won't be loaded.
> (e.g., mt7915 NIC inserted with mt7916 eeprom data in the flash.)
>
> Fix this kind of case by adding chip id into consideration in
> mt7915_check_eeprom().
>
> Reported-by: Cheng-Ji Li <cheng-ji.li at mediatek.com>
> Signed-off-by: Shayne Chen <shayne.chen at mediatek.com>
> ---
>  drivers/net/wireless/mediatek/mt76/mt7915/eeprom.c | 12 +++++-------
>  1 file changed, 5 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/eeprom.c b/drivers/net/wireless/mediatek/mt76/mt7915/eeprom.c
> index 59069fb86414..e21aa03c85b1 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt7915/eeprom.c
> +++ b/drivers/net/wireless/mediatek/mt76/mt7915/eeprom.c
> @@ -33,14 +33,12 @@ static int mt7915_check_eeprom(struct mt7915_dev *dev)
>         u8 *eeprom = dev->mt76.eeprom.data;
>         u16 val = get_unaligned_le16(eeprom);
>
> -       switch (val) {
> -       case 0x7915:
> -       case 0x7916:
> -       case 0x7986:
> +       if ((is_mt7915(&dev->mt76) && val == 0x7915) ||
> +           (is_mt7916(&dev->mt76) && val == 0x7916) ||
> +           (is_mt7986(&dev->mt76) && val == 0x7986))
>                 return 0;
> -       default:
> -               return -EINVAL;
> -       }
> +
> +       return -EINVAL;

If this returned a bool, you could write this as:

switch (val) {
        case 0x7915:
                return is_mt7915(&dev->mt76);
}

Thanks,

-- 
Julian Calaby

Email: julian.calaby at gmail.com
Profile: http://www.google.com/profiles/julian.calaby/



More information about the Linux-mediatek mailing list