brcm_nvram.c (9a87ffc99ec8eb8d35eed7c4f816d75f5cc9662e) | brcm_nvram.c (73bcd133c910bff3b6d3b3834d0d14be9444e90a) |
---|---|
1// SPDX-License-Identifier: GPL-2.0-only 2/* 3 * Copyright (C) 2021 Rafał Miłecki <rafal@milecki.pl> 4 */ 5 6#include <linux/bcm47xx_nvram.h> | 1// SPDX-License-Identifier: GPL-2.0-only 2/* 3 * Copyright (C) 2021 Rafał Miłecki <rafal@milecki.pl> 4 */ 5 6#include <linux/bcm47xx_nvram.h> |
7#include <linux/etherdevice.h> 8#include <linux/if_ether.h> |
|
7#include <linux/io.h> 8#include <linux/mod_devicetable.h> 9#include <linux/module.h> 10#include <linux/nvmem-consumer.h> 11#include <linux/nvmem-provider.h> 12#include <linux/of.h> 13#include <linux/platform_device.h> 14#include <linux/slab.h> --- 22 unchanged lines hidden (view full) --- 37 u8 *dst = val; 38 39 while (bytes--) 40 *dst++ = readb(priv->base + offset++); 41 42 return 0; 43} 44 | 9#include <linux/io.h> 10#include <linux/mod_devicetable.h> 11#include <linux/module.h> 12#include <linux/nvmem-consumer.h> 13#include <linux/nvmem-provider.h> 14#include <linux/of.h> 15#include <linux/platform_device.h> 16#include <linux/slab.h> --- 22 unchanged lines hidden (view full) --- 39 u8 *dst = val; 40 41 while (bytes--) 42 *dst++ = readb(priv->base + offset++); 43 44 return 0; 45} 46 |
47static int brcm_nvram_read_post_process_macaddr(void *context, const char *id, int index, 48 unsigned int offset, void *buf, size_t bytes) 49{ 50 u8 mac[ETH_ALEN]; 51 52 if (bytes != 3 * ETH_ALEN - 1) 53 return -EINVAL; 54 55 if (!mac_pton(buf, mac)) 56 return -EINVAL; 57 58 if (index) 59 eth_addr_add(mac, index); 60 61 ether_addr_copy(buf, mac); 62 63 return 0; 64} 65 |
|
45static int brcm_nvram_add_cells(struct brcm_nvram *priv, uint8_t *data, 46 size_t len) 47{ 48 struct device *dev = priv->dev; 49 char *var, *value, *eq; 50 int idx; 51 52 priv->ncells = 0; --- 17 unchanged lines hidden (view full) --- 70 value = eq + 1; 71 72 priv->cells[idx].name = devm_kstrdup(dev, var, GFP_KERNEL); 73 if (!priv->cells[idx].name) 74 return -ENOMEM; 75 priv->cells[idx].offset = value - (char *)data; 76 priv->cells[idx].bytes = strlen(value); 77 priv->cells[idx].np = of_get_child_by_name(dev->of_node, priv->cells[idx].name); | 66static int brcm_nvram_add_cells(struct brcm_nvram *priv, uint8_t *data, 67 size_t len) 68{ 69 struct device *dev = priv->dev; 70 char *var, *value, *eq; 71 int idx; 72 73 priv->ncells = 0; --- 17 unchanged lines hidden (view full) --- 91 value = eq + 1; 92 93 priv->cells[idx].name = devm_kstrdup(dev, var, GFP_KERNEL); 94 if (!priv->cells[idx].name) 95 return -ENOMEM; 96 priv->cells[idx].offset = value - (char *)data; 97 priv->cells[idx].bytes = strlen(value); 98 priv->cells[idx].np = of_get_child_by_name(dev->of_node, priv->cells[idx].name); |
99 if (!strcmp(var, "et0macaddr") || 100 !strcmp(var, "et1macaddr") || 101 !strcmp(var, "et2macaddr")) { 102 priv->cells[idx].raw_len = strlen(value); 103 priv->cells[idx].bytes = ETH_ALEN; 104 priv->cells[idx].read_post_process = brcm_nvram_read_post_process_macaddr; 105 } |
|
78 } 79 80 return 0; 81} 82 83static int brcm_nvram_parse(struct brcm_nvram *priv) 84{ 85 struct device *dev = priv->dev; --- 91 unchanged lines hidden --- | 106 } 107 108 return 0; 109} 110 111static int brcm_nvram_parse(struct brcm_nvram *priv) 112{ 113 struct device *dev = priv->dev; --- 91 unchanged lines hidden --- |