hc
2024-10-22 8ac6c7a54ed1b98d142dce24b11c6de6a1e239a5
kernel/drivers/staging/most/net/net.c
....@@ -15,7 +15,7 @@
1515 #include <linux/list.h>
1616 #include <linux/wait.h>
1717 #include <linux/kobject.h>
18
-#include "most/core.h"
18
+#include <linux/most.h>
1919
2020 #define MEP_HDR_LEN 8
2121 #define MDP_HDR_LEN 16
....@@ -69,13 +69,13 @@
6969
7070 static struct list_head net_devices = LIST_HEAD_INIT(net_devices);
7171 static struct mutex probe_disc_mt; /* ch->linked = true, most_nd_open */
72
-static struct spinlock list_lock; /* list_head, ch->linked = false, dev_hold */
73
-static struct core_component comp;
72
+static DEFINE_SPINLOCK(list_lock); /* list_head, ch->linked = false, dev_hold */
73
+static struct most_component comp;
7474
7575 static int skb_to_mamac(const struct sk_buff *skb, struct mbo *mbo)
7676 {
7777 u8 *buff = mbo->virt_address;
78
- const u8 broadcast[] = { 0x03, 0xFF };
78
+ static const u8 broadcast[] = { 0x03, 0xFF };
7979 const u8 *dest_addr = skb->data + 4;
8080 const u8 *eth_type = skb->data + 12;
8181 unsigned int payload_len = skb->len - ETH_HLEN;
....@@ -303,7 +303,8 @@
303303 }
304304
305305 static int comp_probe_channel(struct most_interface *iface, int channel_idx,
306
- struct most_channel_config *ccfg, char *name)
306
+ struct most_channel_config *ccfg, char *name,
307
+ char *args)
307308 {
308309 struct net_dev_context *nd;
309310 struct net_dev_channel *ch;
....@@ -506,7 +507,8 @@
506507 return ret;
507508 }
508509
509
-static struct core_component comp = {
510
+static struct most_component comp = {
511
+ .mod = THIS_MODULE,
510512 .name = "net",
511513 .probe_channel = comp_probe_channel,
512514 .disconnect_channel = comp_disconnect_channel,
....@@ -516,13 +518,23 @@
516518
517519 static int __init most_net_init(void)
518520 {
519
- spin_lock_init(&list_lock);
521
+ int err;
522
+
520523 mutex_init(&probe_disc_mt);
521
- return most_register_component(&comp);
524
+ err = most_register_component(&comp);
525
+ if (err)
526
+ return err;
527
+ err = most_register_configfs_subsys(&comp);
528
+ if (err) {
529
+ most_deregister_component(&comp);
530
+ return err;
531
+ }
532
+ return 0;
522533 }
523534
524535 static void __exit most_net_exit(void)
525536 {
537
+ most_deregister_configfs_subsys(&comp);
526538 most_deregister_component(&comp);
527539 }
528540
....@@ -552,13 +564,11 @@
552564
553565 if (m && is_valid_ether_addr(m)) {
554566 if (!is_valid_ether_addr(dev->dev_addr)) {
555
- netdev_info(dev, "set mac %02x-%02x-%02x-%02x-%02x-%02x\n",
556
- m[0], m[1], m[2], m[3], m[4], m[5]);
567
+ netdev_info(dev, "set mac %pM\n", m);
557568 ether_addr_copy(dev->dev_addr, m);
558569 netif_dormant_off(dev);
559570 } else if (!ether_addr_equal(dev->dev_addr, m)) {
560
- netdev_warn(dev, "reject mac %02x-%02x-%02x-%02x-%02x-%02x\n",
561
- m[0], m[1], m[2], m[3], m[4], m[5]);
571
+ netdev_warn(dev, "reject mac %pM\n", m);
562572 }
563573 }
564574