Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1599826
| From | Alban <albeu@free.fr> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH 4/7] ath9k: Add support for reading the MAC address with nvmem |
| Date | 2017-03-13 22:10 +0100 |
| Message-ID | <tkFo8-6nZ-49@gated-at.bofh.it> (permalink) |
| References | <tkFo6-6nZ-5@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On embedded platforms the MAC address is often stored in flash,
use nvmem to read it if the platform data or DT didn't specify one.
Signed-off-by: Alban <albeu@free.fr>
---
drivers/net/wireless/ath/ath9k/init.c | 33 +++++++++++++++++++++++++++++++++
1 file changed, 33 insertions(+)
diff --git a/drivers/net/wireless/ath/ath9k/init.c b/drivers/net/wireless/ath/ath9k/init.c
index 054f254..36b51a5 100644
--- a/drivers/net/wireless/ath/ath9k/init.c
+++ b/drivers/net/wireless/ath/ath9k/init.c
@@ -594,6 +594,35 @@ static int ath9k_of_init(struct ath_softc *sc)
return 0;
}
+static int ath9k_get_nvmem_address(struct ath_softc *sc)
+{
+ struct ath_common *common = ath9k_hw_common(sc->sc_ah);
+ struct nvmem_cell *cell;
+ size_t cell_size;
+ int err = 0;
+ void *mac;
+
+ cell = nvmem_cell_get(sc->dev, "address");
+ if (IS_ERR(cell))
+ return PTR_ERR(cell);
+
+ mac = nvmem_cell_read(cell, &cell_size);
+ nvmem_cell_put(cell);
+
+ if (IS_ERR(mac))
+ return PTR_ERR(mac);
+
+ if (cell_size == 6) {
+ ether_addr_copy(common->macaddr, mac);
+ } else {
+ dev_err(sc->dev, "nvmem 'address' cell has invalid size\n");
+ err = -EINVAL;
+ }
+
+ kfree(mac);
+ return err;
+}
+
static int ath9k_init_softc(u16 devid, struct ath_softc *sc,
const struct ath_bus_ops *bus_ops)
{
@@ -656,6 +685,10 @@ static int ath9k_init_softc(u16 devid, struct ath_softc *sc,
if (ret)
return ret;
+ /* If no MAC address has been set yet try to use nvmem */
+ if (!is_valid_ether_addr(common->macaddr))
+ ath9k_get_nvmem_address(sc);
+
/* If the EEPROM hasn't been retrieved via firmware request
* use the nvmem API insted.
*/
--
2.7.4
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH 1/7] Documentation: dt: net: Update the ath9k binding for SoC devices Alban <albeu@free.fr> - 2017-03-13 22:10 +0100
[PATCH 5/7] ath9k: of: Use the clk API to get the reference clock rate Alban <albeu@free.fr> - 2017-03-13 22:10 +0100
Re: [PATCH 5/7] ath9k: of: Use the clk API to get the reference clock rate Rafał Miłecki <zajec5@gmail.com> - 2017-03-13 23:20 +0100
[PATCH 2/7] ath9k: ahb: Add OF support Alban <albeu@free.fr> - 2017-03-13 22:10 +0100
Re: [PATCH 2/7] ath9k: ahb: Add OF support Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> - 2017-03-14 12:20 +0100
[PATCH 3/7] ath9k: Add support for reading the EEPROM data using the nvmem API Alban <albeu@free.fr> - 2017-03-13 22:10 +0100
Re: [PATCH 3/7] ath9k: Add support for reading the EEPROM data using the nvmem API Rafał Miłecki <zajec5@gmail.com> - 2017-03-13 23:20 +0100
Re: [PATCH 3/7] ath9k: Add support for reading the EEPROM data using the nvmem API Christian Lamparter <chunkeey@googlemail.com> - 2017-03-14 01:00 +0100
Re: [PATCH 3/7] ath9k: Add support for reading the EEPROM data using the nvmem API Alban <albeu@free.fr> - 2017-03-23 15:50 +0100
Re: [PATCH 3/7] ath9k: Add support for reading the EEPROM data using the nvmem API Christian Lamparter <chunkeey@googlemail.com> - 2017-03-24 17:30 +0100
[PATCH 4/7] ath9k: Add support for reading the MAC address with nvmem Alban <albeu@free.fr> - 2017-03-13 22:10 +0100
Re: [PATCH 1/7] Documentation: dt: net: Update the ath9k binding for SoC devices Rob Herring <robh@kernel.org> - 2017-03-20 23:10 +0100
Re: [PATCH 1/7] Documentation: dt: net: Update the ath9k binding for SoC devices Christian Lamparter <chunkeey@googlemail.com> - 2017-03-27 18:20 +0200
csiph-web