Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) // SPDX-License-Identifier: GPL-2.0-only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  * Loopback IEEE 802.15.4 interface
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  * Copyright 2007-2012 Siemens AG
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  * Written by:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  * Sergey Lapin <slapin@ossfans.org>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9)  * Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10)  * Alexander Smirnov <alex.bluesman.smirnov@gmail.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #include <linux/timer.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) #include <linux/platform_device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) #include <linux/netdevice.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) #include <linux/device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) #include <linux/spinlock.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) #include <net/mac802154.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) #include <net/cfg802154.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) static int numlbs = 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) static LIST_HEAD(fakelb_phys);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) static DEFINE_MUTEX(fakelb_phys_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) static LIST_HEAD(fakelb_ifup_phys);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) static DEFINE_RWLOCK(fakelb_ifup_phys_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) struct fakelb_phy {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 	struct ieee802154_hw *hw;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 	u8 page;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 	u8 channel;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 	bool suspended;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 	struct list_head list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 	struct list_head list_ifup;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) static int fakelb_hw_ed(struct ieee802154_hw *hw, u8 *level)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 	WARN_ON(!level);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 	*level = 0xbe;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) static int fakelb_hw_channel(struct ieee802154_hw *hw, u8 page, u8 channel)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 	struct fakelb_phy *phy = hw->priv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 	write_lock_bh(&fakelb_ifup_phys_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 	phy->page = page;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 	phy->channel = channel;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 	write_unlock_bh(&fakelb_ifup_phys_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) static int fakelb_hw_xmit(struct ieee802154_hw *hw, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 	struct fakelb_phy *current_phy = hw->priv, *phy;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 	read_lock_bh(&fakelb_ifup_phys_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 	WARN_ON(current_phy->suspended);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 	list_for_each_entry(phy, &fakelb_ifup_phys, list_ifup) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 		if (current_phy == phy)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 			continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 		if (current_phy->page == phy->page &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 		    current_phy->channel == phy->channel) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 			struct sk_buff *newskb = pskb_copy(skb, GFP_ATOMIC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 			if (newskb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 				ieee802154_rx_irqsafe(phy->hw, newskb, 0xcc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 	read_unlock_bh(&fakelb_ifup_phys_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 	ieee802154_xmit_complete(hw, skb, false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) static int fakelb_hw_start(struct ieee802154_hw *hw)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 	struct fakelb_phy *phy = hw->priv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 	write_lock_bh(&fakelb_ifup_phys_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 	phy->suspended = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 	list_add(&phy->list_ifup, &fakelb_ifup_phys);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 	write_unlock_bh(&fakelb_ifup_phys_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) static void fakelb_hw_stop(struct ieee802154_hw *hw)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 	struct fakelb_phy *phy = hw->priv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 	write_lock_bh(&fakelb_ifup_phys_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 	phy->suspended = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 	list_del(&phy->list_ifup);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 	write_unlock_bh(&fakelb_ifup_phys_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) fakelb_set_promiscuous_mode(struct ieee802154_hw *hw, const bool on)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) static const struct ieee802154_ops fakelb_ops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 	.owner = THIS_MODULE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 	.xmit_async = fakelb_hw_xmit,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 	.ed = fakelb_hw_ed,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 	.set_channel = fakelb_hw_channel,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 	.start = fakelb_hw_start,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 	.stop = fakelb_hw_stop,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 	.set_promiscuous_mode = fakelb_set_promiscuous_mode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) /* Number of dummy devices to be set up by this module. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) module_param(numlbs, int, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) MODULE_PARM_DESC(numlbs, " number of pseudo devices");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) static int fakelb_add_one(struct device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 	struct ieee802154_hw *hw;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 	struct fakelb_phy *phy;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 	int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 	hw = ieee802154_alloc_hw(sizeof(*phy), &fakelb_ops);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 	if (!hw)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 		return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 	phy = hw->priv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 	phy->hw = hw;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 	/* 868 MHz BPSK	802.15.4-2003 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 	hw->phy->supported.channels[0] |= 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 	/* 915 MHz BPSK	802.15.4-2003 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 	hw->phy->supported.channels[0] |= 0x7fe;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 	/* 2.4 GHz O-QPSK 802.15.4-2003 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 	hw->phy->supported.channels[0] |= 0x7FFF800;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 	/* 868 MHz ASK 802.15.4-2006 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 	hw->phy->supported.channels[1] |= 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 	/* 915 MHz ASK 802.15.4-2006 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 	hw->phy->supported.channels[1] |= 0x7fe;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 	/* 868 MHz O-QPSK 802.15.4-2006 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 	hw->phy->supported.channels[2] |= 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 	/* 915 MHz O-QPSK 802.15.4-2006 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 	hw->phy->supported.channels[2] |= 0x7fe;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 	/* 2.4 GHz CSS 802.15.4a-2007 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 	hw->phy->supported.channels[3] |= 0x3fff;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 	/* UWB Sub-gigahertz 802.15.4a-2007 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 	hw->phy->supported.channels[4] |= 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 	/* UWB Low band 802.15.4a-2007 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 	hw->phy->supported.channels[4] |= 0x1e;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 	/* UWB High band 802.15.4a-2007 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 	hw->phy->supported.channels[4] |= 0xffe0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 	/* 750 MHz O-QPSK 802.15.4c-2009 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 	hw->phy->supported.channels[5] |= 0xf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 	/* 750 MHz MPSK 802.15.4c-2009 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 	hw->phy->supported.channels[5] |= 0xf0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 	/* 950 MHz BPSK 802.15.4d-2009 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 	hw->phy->supported.channels[6] |= 0x3ff;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 	/* 950 MHz GFSK 802.15.4d-2009 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 	hw->phy->supported.channels[6] |= 0x3ffc00;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 	ieee802154_random_extended_addr(&hw->phy->perm_extended_addr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 	/* fake phy channel 13 as default */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 	hw->phy->current_channel = 13;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 	phy->channel = hw->phy->current_channel;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 	hw->flags = IEEE802154_HW_PROMISCUOUS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 	hw->parent = dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 	err = ieee802154_register_hw(hw);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 	if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 		goto err_reg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 	mutex_lock(&fakelb_phys_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 	list_add_tail(&phy->list, &fakelb_phys);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 	mutex_unlock(&fakelb_phys_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) err_reg:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 	ieee802154_free_hw(phy->hw);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 	return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) static void fakelb_del(struct fakelb_phy *phy)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 	list_del(&phy->list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 	ieee802154_unregister_hw(phy->hw);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 	ieee802154_free_hw(phy->hw);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) static int fakelb_probe(struct platform_device *pdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 	struct fakelb_phy *phy, *tmp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 	int err, i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 	for (i = 0; i < numlbs; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 		err = fakelb_add_one(&pdev->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 		if (err < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 			goto err_slave;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 	dev_info(&pdev->dev, "added %i fake ieee802154 hardware devices\n", numlbs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) err_slave:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 	mutex_lock(&fakelb_phys_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 	list_for_each_entry_safe(phy, tmp, &fakelb_phys, list)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 		fakelb_del(phy);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 	mutex_unlock(&fakelb_phys_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 	return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) static int fakelb_remove(struct platform_device *pdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 	struct fakelb_phy *phy, *tmp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 	mutex_lock(&fakelb_phys_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 	list_for_each_entry_safe(phy, tmp, &fakelb_phys, list)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 		fakelb_del(phy);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 	mutex_unlock(&fakelb_phys_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) static struct platform_device *ieee802154fake_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) static struct platform_driver ieee802154fake_driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 	.probe = fakelb_probe,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 	.remove = fakelb_remove,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 	.driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 			.name = "ieee802154fakelb",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) static __init int fakelb_init_module(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) 	ieee802154fake_dev = platform_device_register_simple(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 			     "ieee802154fakelb", -1, NULL, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) 	pr_warn("fakelb driver is marked as deprecated, please use mac802154_hwsim!\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) 	return platform_driver_register(&ieee802154fake_driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) static __exit void fake_remove_module(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) 	platform_driver_unregister(&ieee802154fake_driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) 	platform_device_unregister(ieee802154fake_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) module_init(fakelb_init_module);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) module_exit(fake_remove_module);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) MODULE_LICENSE("GPL");