hc
2024-01-03 2f7c68cb55ecb7331f2381deb497c27155f32faf
kernel/arch/xtensa/platforms/iss/network.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 *
34 * arch/xtensa/platforms/iss/network.c
....@@ -8,12 +9,6 @@
89 * Based on work form the UML team.
910 *
1011 * Copyright 2005 Tensilica Inc.
11
- *
12
- * This program is free software; you can redistribute it and/or modify it
13
- * under the terms of the GNU General Public License as published by the
14
- * Free Software Foundation; either version 2 of the License, or (at your
15
- * option) any later version.
16
- *
1712 */
1813
1914 #define pr_fmt(fmt) "%s: " fmt, __func__
....@@ -30,7 +25,7 @@
3025 #include <linux/etherdevice.h>
3126 #include <linux/interrupt.h>
3227 #include <linux/ioctl.h>
33
-#include <linux/bootmem.h>
28
+#include <linux/memblock.h>
3429 #include <linux/ethtool.h>
3530 #include <linux/rtnetlink.h>
3631 #include <linux/platform_device.h>
....@@ -209,7 +204,7 @@
209204 return simc_write(lp->tp.info.tuntap.fd, (*skb)->data, (*skb)->len);
210205 }
211206
212
-unsigned short tuntap_protocol(struct sk_buff *skb)
207
+static unsigned short tuntap_protocol(struct sk_buff *skb)
213208 {
214209 return eth_type_trans(skb, skb->dev);
215210 }
....@@ -236,7 +231,7 @@
236231
237232 init += sizeof(TRANSPORT_TUNTAP_NAME) - 1;
238233 if (*init == ',') {
239
- rem = split_if_spec(init + 1, &mac_str, &dev_name);
234
+ rem = split_if_spec(init + 1, &mac_str, &dev_name, NULL);
240235 if (rem != NULL) {
241236 pr_err("%s: extra garbage on specification : '%s'\n",
242237 dev->name, rem);
....@@ -460,7 +455,7 @@
460455 {
461456 }
462457
463
-static void iss_net_tx_timeout(struct net_device *dev)
458
+static void iss_net_tx_timeout(struct net_device *dev, unsigned int txqueue)
464459 {
465460 }
466461
....@@ -482,7 +477,7 @@
482477 return -EINVAL;
483478 }
484479
485
-void iss_net_user_timer_expire(struct timer_list *unused)
480
+static void iss_net_user_timer_expire(struct timer_list *unused)
486481 {
487482 }
488483
....@@ -507,16 +502,24 @@
507502 .ndo_set_rx_mode = iss_net_set_multicast_list,
508503 };
509504
510
-static int iss_net_configure(int index, char *init)
505
+static void iss_net_pdev_release(struct device *dev)
506
+{
507
+ struct platform_device *pdev = to_platform_device(dev);
508
+ struct iss_net_private *lp =
509
+ container_of(pdev, struct iss_net_private, pdev);
510
+
511
+ free_netdev(lp->dev);
512
+}
513
+
514
+static void iss_net_configure(int index, char *init)
511515 {
512516 struct net_device *dev;
513517 struct iss_net_private *lp;
514
- int err;
515518
516519 dev = alloc_etherdev(sizeof(*lp));
517520 if (dev == NULL) {
518521 pr_err("eth_configure: failed to allocate device\n");
519
- return 1;
522
+ return;
520523 }
521524
522525 /* Initialize private element. */
....@@ -545,7 +548,7 @@
545548 if (!tuntap_probe(lp, index, init)) {
546549 pr_err("%s: invalid arguments. Skipping device!\n",
547550 dev->name);
548
- goto errout;
551
+ goto err_free_netdev;
549552 }
550553
551554 pr_info("Netdevice %d (%pM)\n", index, dev->dev_addr);
....@@ -553,7 +556,8 @@
553556 /* sysfs register */
554557
555558 if (!driver_registered) {
556
- platform_driver_register(&iss_net_driver);
559
+ if (platform_driver_register(&iss_net_driver))
560
+ goto err_free_netdev;
557561 driver_registered = 1;
558562 }
559563
....@@ -563,7 +567,9 @@
563567
564568 lp->pdev.id = index;
565569 lp->pdev.name = DRIVER_NAME;
566
- platform_device_register(&lp->pdev);
570
+ lp->pdev.dev.release = iss_net_pdev_release;
571
+ if (platform_device_register(&lp->pdev))
572
+ goto err_free_netdev;
567573 SET_NETDEV_DEV(dev, &lp->pdev.dev);
568574
569575 dev->netdev_ops = &iss_netdev_ops;
....@@ -572,23 +578,20 @@
572578 dev->irq = -1;
573579
574580 rtnl_lock();
575
- err = register_netdevice(dev);
576
- rtnl_unlock();
577
-
578
- if (err) {
581
+ if (register_netdevice(dev)) {
582
+ rtnl_unlock();
579583 pr_err("%s: error registering net device!\n", dev->name);
580
- /* XXX: should we call ->remove() here? */
581
- free_netdev(dev);
582
- return 1;
584
+ platform_device_unregister(&lp->pdev);
585
+ return;
583586 }
587
+ rtnl_unlock();
584588
585589 timer_setup(&lp->tl, iss_net_user_timer_expire, 0);
586590
587
- return 0;
591
+ return;
588592
589
-errout:
590
- /* FIXME: unregister; free, etc.. */
591
- return -EIO;
593
+err_free_netdev:
594
+ free_netdev(dev);
592595 }
593596
594597 /* ------------------------------------------------------------------------- */
....@@ -646,7 +649,7 @@
646649 return 1;
647650 }
648651
649
- new = alloc_bootmem(sizeof(*new));
652
+ new = memblock_alloc(sizeof(*new), SMP_CACHE_BYTES);
650653 if (new == NULL) {
651654 pr_err("Alloc_bootmem failed\n");
652655 return 1;