Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 89a8607c authored by Lorenzo Bianconi's avatar Lorenzo Bianconi Committed by Felix Fietkau
Browse files

mt76: move mt76x02_mac_setaddr in mt76x02-lib module



Move mt76x02_mac_setaddr utility routine in mt76x02-lib
module and remove duplicated code. This is a preliminary patch
to unify eeprom code between mt76x2 and mt76x0 driver

Signed-off-by: default avatarLorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: default avatarFelix Fietkau <nbd@nbd.name>
parent b27823a7
Loading
Loading
Loading
Loading
+1 −23
Original line number Diff line number Diff line
@@ -131,28 +131,6 @@ mt76x0_set_chip_cap(struct mt76x0_dev *dev, u8 *eeprom)
	dev_dbg(dev->mt76.dev, "PA Type %d\n", dev->ee->pa_type);
}

static int
mt76x0_set_macaddr(struct mt76x0_dev *dev, const u8 *eeprom)
{
	const void *src = eeprom + MT_EE_MAC_ADDR;
	u8 *dst = dev->mt76.macaddr;

	ether_addr_copy(dev->mt76.macaddr, src);

	if (!is_valid_ether_addr(dst)) {
		eth_random_addr(dst);
		dev_info(dev->mt76.dev,
			 "Invalid MAC address, using random address %pM\n",
			 dst);
	}

	mt76_wr(dev, MT_MAC_ADDR_DW0, get_unaligned_le32(dst));
	mt76_wr(dev, MT_MAC_ADDR_DW1, get_unaligned_le16(dst + 4) |
		FIELD_PREP(MT_MAC_ADDR_DW1_U2ME_MASK, 0xff));

	return 0;
}

static void
mt76x0_set_temp_offset(struct mt76x0_dev *dev, u8 *eeprom)
{
@@ -409,7 +387,7 @@ mt76x0_eeprom_init(struct mt76x0_dev *dev)
	dev_info(dev->mt76.dev, "EEPROM ver:%02hhx fae:%02hhx\n",
		 eeprom[MT_EE_VERSION + 1], eeprom[MT_EE_VERSION]);

	mt76x0_set_macaddr(dev, eeprom);
	mt76x02_mac_setaddr(&dev->mt76, eeprom + MT_EE_MAC_ADDR);
	mt76x0_set_chip_cap(dev, eeprom);
	mt76x0_set_country_reg(dev, eeprom);
	mt76x0_set_rf_freq_off(dev, eeprom);
+18 −0
Original line number Diff line number Diff line
@@ -502,3 +502,21 @@ mt76x02_mac_process_rate(struct mt76_rx_status *status, u16 rate)
	return 0;
}
EXPORT_SYMBOL_GPL(mt76x02_mac_process_rate);

void mt76x02_mac_setaddr(struct mt76_dev *dev, u8 *addr)
{
	ether_addr_copy(dev->macaddr, addr);

	if (!is_valid_ether_addr(dev->macaddr)) {
		eth_random_addr(dev->macaddr);
		dev_info(dev->dev,
			 "Invalid MAC address, using random address %pM\n",
			 dev->macaddr);
	}

	__mt76_wr(dev, MT_MAC_ADDR_DW0, get_unaligned_le32(dev->macaddr));
	__mt76_wr(dev, MT_MAC_ADDR_DW1,
		  get_unaligned_le16(dev->macaddr + 4) |
		  FIELD_PREP(MT_MAC_ADDR_DW1_U2ME_MASK, 0xff));
}
EXPORT_SYMBOL_GPL(mt76x02_mac_setaddr);
+1 −0
Original line number Diff line number Diff line
@@ -202,4 +202,5 @@ void mt76x02_send_tx_status(struct mt76_dev *dev,
			   struct mt76x02_tx_status *stat, u8 *update);
int
mt76x02_mac_process_rate(struct mt76_rx_status *status, u16 rate);
void mt76x02_mac_setaddr(struct mt76_dev *dev, u8 *addr);
#endif
+0 −1
Original line number Diff line number Diff line
@@ -36,7 +36,6 @@ int mt76x2u_init_hardware(struct mt76x2_dev *dev);
void mt76x2u_cleanup(struct mt76x2_dev *dev);
void mt76x2u_stop_hw(struct mt76x2_dev *dev);

void mt76x2u_mac_setaddr(struct mt76x2_dev *dev, u8 *addr);
int mt76x2u_mac_reset(struct mt76x2_dev *dev);
void mt76x2u_mac_resume(struct mt76x2_dev *dev);
int mt76x2u_mac_start(struct mt76x2_dev *dev);
+2 −1
Original line number Diff line number Diff line
@@ -212,7 +212,8 @@ int mt76x2u_init_hardware(struct mt76x2_dev *dev)
	if (err < 0)
		return err;

	mt76x2u_mac_setaddr(dev, dev->mt76.eeprom.data + MT_EE_MAC_ADDR);
	mt76x02_mac_setaddr(&dev->mt76,
			    dev->mt76.eeprom.data + MT_EE_MAC_ADDR);
	dev->mt76.rxfilter = mt76_rr(dev, MT_RX_FILTR_CFG);

	mt76x2u_init_beacon_offsets(dev);
Loading