mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-02 01:37:17 -04:00
wifi: mt76: split get_of_eeprom in subfunction
In preparation for NVMEM support, split get_of_eeprom() in subfunction to tidy the code and facilitate the addition of alternative method to get eeprom data. No behaviour change intended. While at it also drop OF ifdef checks as OF have stubs and calling of_get_property would result in the same error returned. Signed-off-by: Christian Marangi <ansuelsmth@gmail.com> Reviewed-by: Daniel Golle <daniel@makrotopia.org> Tested-by: Daniel Golle <daniel@makrotopia.org> Signed-off-by: Felix Fietkau <nbd@nbd.name>
This commit is contained in:
committed by
Felix Fietkau
parent
02a894046d
commit
7d424a990e
@@ -9,32 +9,36 @@
|
||||
#include <linux/etherdevice.h>
|
||||
#include "mt76.h"
|
||||
|
||||
int mt76_get_of_eeprom(struct mt76_dev *dev, void *eep, int offset, int len)
|
||||
static int mt76_get_of_eeprom_data(struct mt76_dev *dev, void *eep, int len)
|
||||
{
|
||||
#if defined(CONFIG_OF) && defined(CONFIG_MTD)
|
||||
struct device_node *np = dev->dev->of_node;
|
||||
const void *data;
|
||||
int size;
|
||||
|
||||
data = of_get_property(np, "mediatek,eeprom-data", &size);
|
||||
if (!data)
|
||||
return -ENOENT;
|
||||
|
||||
if (size > len)
|
||||
return -EINVAL;
|
||||
|
||||
memcpy(eep, data, size);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int mt76_get_of_epprom_from_mtd(struct mt76_dev *dev, void *eep, int offset, int len)
|
||||
{
|
||||
#ifdef CONFIG_MTD
|
||||
struct device_node *np = dev->dev->of_node;
|
||||
struct mtd_info *mtd;
|
||||
const __be32 *list;
|
||||
const void *data;
|
||||
const char *part;
|
||||
phandle phandle;
|
||||
int size;
|
||||
size_t retlen;
|
||||
int size;
|
||||
int ret;
|
||||
|
||||
if (!np)
|
||||
return -ENOENT;
|
||||
|
||||
data = of_get_property(np, "mediatek,eeprom-data", &size);
|
||||
if (data) {
|
||||
if (size > len)
|
||||
return -EINVAL;
|
||||
|
||||
memcpy(eep, data, size);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
list = of_get_property(np, "mediatek,mtd-eeprom", &size);
|
||||
if (!list)
|
||||
return -ENOENT;
|
||||
@@ -100,6 +104,21 @@ int mt76_get_of_eeprom(struct mt76_dev *dev, void *eep, int offset, int len)
|
||||
return -ENOENT;
|
||||
#endif
|
||||
}
|
||||
|
||||
int mt76_get_of_eeprom(struct mt76_dev *dev, void *eep, int offset, int len)
|
||||
{
|
||||
struct device_node *np = dev->dev->of_node;
|
||||
int ret;
|
||||
|
||||
if (!np)
|
||||
return -ENOENT;
|
||||
|
||||
ret = mt76_get_of_eeprom_data(dev, eep, len);
|
||||
if (!ret)
|
||||
return 0;
|
||||
|
||||
return mt76_get_of_epprom_from_mtd(dev, eep, offset, len);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(mt76_get_of_eeprom);
|
||||
|
||||
void
|
||||
|
||||
Reference in New Issue
Block a user