From b22da3d8526a935aa31e086e63f60ff3246cb61c Mon Sep 17 00:00:00 2001 From: hc <hc@nodka.com> Date: Sat, 09 Dec 2023 07:24:11 +0000 Subject: [PATCH] add stmac read mac form eeprom --- kernel/drivers/staging/most/net/net.c | 34 ++++++++++++++++++++++------------ 1 files changed, 22 insertions(+), 12 deletions(-) diff --git a/kernel/drivers/staging/most/net/net.c b/kernel/drivers/staging/most/net/net.c index ff80834..b6fecb0 100644 --- a/kernel/drivers/staging/most/net/net.c +++ b/kernel/drivers/staging/most/net/net.c @@ -15,7 +15,7 @@ #include <linux/list.h> #include <linux/wait.h> #include <linux/kobject.h> -#include "most/core.h" +#include <linux/most.h> #define MEP_HDR_LEN 8 #define MDP_HDR_LEN 16 @@ -69,13 +69,13 @@ static struct list_head net_devices = LIST_HEAD_INIT(net_devices); static struct mutex probe_disc_mt; /* ch->linked = true, most_nd_open */ -static struct spinlock list_lock; /* list_head, ch->linked = false, dev_hold */ -static struct core_component comp; +static DEFINE_SPINLOCK(list_lock); /* list_head, ch->linked = false, dev_hold */ +static struct most_component comp; static int skb_to_mamac(const struct sk_buff *skb, struct mbo *mbo) { u8 *buff = mbo->virt_address; - const u8 broadcast[] = { 0x03, 0xFF }; + static const u8 broadcast[] = { 0x03, 0xFF }; const u8 *dest_addr = skb->data + 4; const u8 *eth_type = skb->data + 12; unsigned int payload_len = skb->len - ETH_HLEN; @@ -303,7 +303,8 @@ } static int comp_probe_channel(struct most_interface *iface, int channel_idx, - struct most_channel_config *ccfg, char *name) + struct most_channel_config *ccfg, char *name, + char *args) { struct net_dev_context *nd; struct net_dev_channel *ch; @@ -506,7 +507,8 @@ return ret; } -static struct core_component comp = { +static struct most_component comp = { + .mod = THIS_MODULE, .name = "net", .probe_channel = comp_probe_channel, .disconnect_channel = comp_disconnect_channel, @@ -516,13 +518,23 @@ static int __init most_net_init(void) { - spin_lock_init(&list_lock); + int err; + mutex_init(&probe_disc_mt); - return most_register_component(&comp); + err = most_register_component(&comp); + if (err) + return err; + err = most_register_configfs_subsys(&comp); + if (err) { + most_deregister_component(&comp); + return err; + } + return 0; } static void __exit most_net_exit(void) { + most_deregister_configfs_subsys(&comp); most_deregister_component(&comp); } @@ -552,13 +564,11 @@ if (m && is_valid_ether_addr(m)) { if (!is_valid_ether_addr(dev->dev_addr)) { - netdev_info(dev, "set mac %02x-%02x-%02x-%02x-%02x-%02x\n", - m[0], m[1], m[2], m[3], m[4], m[5]); + netdev_info(dev, "set mac %pM\n", m); ether_addr_copy(dev->dev_addr, m); netif_dormant_off(dev); } else if (!ether_addr_equal(dev->dev_addr, m)) { - netdev_warn(dev, "reject mac %02x-%02x-%02x-%02x-%02x-%02x\n", - m[0], m[1], m[2], m[3], m[4], m[5]); + netdev_warn(dev, "reject mac %pM\n", m); } } -- Gitblit v1.6.2