alex.bluesman.smirnov@gmail.com | e1e49b6 | 2012-05-15 20:50:30 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Loopback IEEE 802.15.4 interface |
| 3 | * |
| 4 | * Copyright 2007-2012 Siemens AG |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License version 2 |
| 8 | * as published by the Free Software Foundation. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
alex.bluesman.smirnov@gmail.com | e1e49b6 | 2012-05-15 20:50:30 +0000 | [diff] [blame] | 15 | * Written by: |
| 16 | * Sergey Lapin <slapin@ossfans.org> |
| 17 | * Dmitry Eremin-Solenikov <dbaryshkov@gmail.com> |
| 18 | * Alexander Smirnov <alex.bluesman.smirnov@gmail.com> |
| 19 | */ |
| 20 | |
| 21 | #include <linux/module.h> |
| 22 | #include <linux/timer.h> |
| 23 | #include <linux/platform_device.h> |
| 24 | #include <linux/netdevice.h> |
Himangi Saraogi | 12b5c38 | 2014-05-19 22:25:11 +0530 | [diff] [blame] | 25 | #include <linux/device.h> |
alex.bluesman.smirnov@gmail.com | e1e49b6 | 2012-05-15 20:50:30 +0000 | [diff] [blame] | 26 | #include <linux/spinlock.h> |
| 27 | #include <net/mac802154.h> |
Alexander Aring | 5ad60d3 | 2014-10-25 09:41:02 +0200 | [diff] [blame] | 28 | #include <net/cfg802154.h> |
alex.bluesman.smirnov@gmail.com | e1e49b6 | 2012-05-15 20:50:30 +0000 | [diff] [blame] | 29 | |
Alexander Aring | 7e57905 | 2015-05-17 21:44:58 +0200 | [diff] [blame] | 30 | static int numlbs = 2; |
Alexander Aring | 3335d98 | 2015-05-17 21:45:02 +0200 | [diff] [blame^] | 31 | static DEFINE_RWLOCK(fakelb_lock); |
alex.bluesman.smirnov@gmail.com | e1e49b6 | 2012-05-15 20:50:30 +0000 | [diff] [blame] | 32 | |
Alexander Aring | db3f5d0 | 2015-05-17 21:45:00 +0200 | [diff] [blame] | 33 | struct fakelb_phy { |
Alexander Aring | 5a50439 | 2014-10-25 17:16:34 +0200 | [diff] [blame] | 34 | struct ieee802154_hw *hw; |
alex.bluesman.smirnov@gmail.com | e1e49b6 | 2012-05-15 20:50:30 +0000 | [diff] [blame] | 35 | |
| 36 | struct list_head list; |
| 37 | struct fakelb_priv *fake; |
| 38 | |
| 39 | spinlock_t lock; |
| 40 | bool working; |
| 41 | }; |
| 42 | |
| 43 | struct fakelb_priv { |
| 44 | struct list_head list; |
alex.bluesman.smirnov@gmail.com | e1e49b6 | 2012-05-15 20:50:30 +0000 | [diff] [blame] | 45 | }; |
| 46 | |
| 47 | static int |
Alexander Aring | 5a50439 | 2014-10-25 17:16:34 +0200 | [diff] [blame] | 48 | fakelb_hw_ed(struct ieee802154_hw *hw, u8 *level) |
alex.bluesman.smirnov@gmail.com | e1e49b6 | 2012-05-15 20:50:30 +0000 | [diff] [blame] | 49 | { |
alex.bluesman.smirnov@gmail.com | e1e49b6 | 2012-05-15 20:50:30 +0000 | [diff] [blame] | 50 | BUG_ON(!level); |
| 51 | *level = 0xbe; |
| 52 | |
| 53 | return 0; |
| 54 | } |
| 55 | |
| 56 | static int |
Alexander Aring | e37d2ec | 2014-10-28 18:21:19 +0100 | [diff] [blame] | 57 | fakelb_hw_channel(struct ieee802154_hw *hw, u8 page, u8 channel) |
alex.bluesman.smirnov@gmail.com | e1e49b6 | 2012-05-15 20:50:30 +0000 | [diff] [blame] | 58 | { |
| 59 | pr_debug("set channel to %d\n", channel); |
| 60 | |
alex.bluesman.smirnov@gmail.com | e1e49b6 | 2012-05-15 20:50:30 +0000 | [diff] [blame] | 61 | return 0; |
| 62 | } |
| 63 | |
| 64 | static void |
Alexander Aring | db3f5d0 | 2015-05-17 21:45:00 +0200 | [diff] [blame] | 65 | fakelb_hw_deliver(struct fakelb_phy *phy, struct sk_buff *skb) |
alex.bluesman.smirnov@gmail.com | e1e49b6 | 2012-05-15 20:50:30 +0000 | [diff] [blame] | 66 | { |
| 67 | struct sk_buff *newskb; |
| 68 | |
Alexander Aring | db3f5d0 | 2015-05-17 21:45:00 +0200 | [diff] [blame] | 69 | spin_lock(&phy->lock); |
| 70 | if (phy->working) { |
alex.bluesman.smirnov@gmail.com | e1e49b6 | 2012-05-15 20:50:30 +0000 | [diff] [blame] | 71 | newskb = pskb_copy(skb, GFP_ATOMIC); |
Martin Townsend | cb97d9a | 2015-05-17 21:44:54 +0200 | [diff] [blame] | 72 | if (newskb) |
Alexander Aring | db3f5d0 | 2015-05-17 21:45:00 +0200 | [diff] [blame] | 73 | ieee802154_rx_irqsafe(phy->hw, newskb, 0xcc); |
alex.bluesman.smirnov@gmail.com | e1e49b6 | 2012-05-15 20:50:30 +0000 | [diff] [blame] | 74 | } |
Alexander Aring | db3f5d0 | 2015-05-17 21:45:00 +0200 | [diff] [blame] | 75 | spin_unlock(&phy->lock); |
alex.bluesman.smirnov@gmail.com | e1e49b6 | 2012-05-15 20:50:30 +0000 | [diff] [blame] | 76 | } |
| 77 | |
| 78 | static int |
Alexander Aring | 5a50439 | 2014-10-25 17:16:34 +0200 | [diff] [blame] | 79 | fakelb_hw_xmit(struct ieee802154_hw *hw, struct sk_buff *skb) |
alex.bluesman.smirnov@gmail.com | e1e49b6 | 2012-05-15 20:50:30 +0000 | [diff] [blame] | 80 | { |
Alexander Aring | db3f5d0 | 2015-05-17 21:45:00 +0200 | [diff] [blame] | 81 | struct fakelb_phy *current_phy = hw->priv; |
Alexander Aring | 9f8b97f | 2015-05-17 21:45:01 +0200 | [diff] [blame] | 82 | struct fakelb_phy *phy; |
alex.bluesman.smirnov@gmail.com | e1e49b6 | 2012-05-15 20:50:30 +0000 | [diff] [blame] | 83 | |
Alexander Aring | 3335d98 | 2015-05-17 21:45:02 +0200 | [diff] [blame^] | 84 | read_lock_bh(&fakelb_lock); |
Alexander Aring | 9f8b97f | 2015-05-17 21:45:01 +0200 | [diff] [blame] | 85 | list_for_each_entry(phy, ¤t_phy->fake->list, list) { |
| 86 | if (current_phy == phy) |
| 87 | continue; |
Alexander Aring | db3f5d0 | 2015-05-17 21:45:00 +0200 | [diff] [blame] | 88 | |
Alexander Aring | 9f8b97f | 2015-05-17 21:45:01 +0200 | [diff] [blame] | 89 | if (phy->hw->phy->current_channel == |
| 90 | current_phy->hw->phy->current_channel) |
| 91 | fakelb_hw_deliver(phy, skb); |
alex.bluesman.smirnov@gmail.com | e1e49b6 | 2012-05-15 20:50:30 +0000 | [diff] [blame] | 92 | } |
Alexander Aring | 3335d98 | 2015-05-17 21:45:02 +0200 | [diff] [blame^] | 93 | read_unlock_bh(&fakelb_lock); |
alex.bluesman.smirnov@gmail.com | e1e49b6 | 2012-05-15 20:50:30 +0000 | [diff] [blame] | 94 | |
| 95 | return 0; |
| 96 | } |
| 97 | |
| 98 | static int |
Alexander Aring | 5a50439 | 2014-10-25 17:16:34 +0200 | [diff] [blame] | 99 | fakelb_hw_start(struct ieee802154_hw *hw) { |
Alexander Aring | db3f5d0 | 2015-05-17 21:45:00 +0200 | [diff] [blame] | 100 | struct fakelb_phy *phy = hw->priv; |
alex.bluesman.smirnov@gmail.com | e1e49b6 | 2012-05-15 20:50:30 +0000 | [diff] [blame] | 101 | int ret = 0; |
| 102 | |
Alexander Aring | db3f5d0 | 2015-05-17 21:45:00 +0200 | [diff] [blame] | 103 | spin_lock(&phy->lock); |
| 104 | if (phy->working) |
alex.bluesman.smirnov@gmail.com | e1e49b6 | 2012-05-15 20:50:30 +0000 | [diff] [blame] | 105 | ret = -EBUSY; |
| 106 | else |
Alexander Aring | db3f5d0 | 2015-05-17 21:45:00 +0200 | [diff] [blame] | 107 | phy->working = 1; |
| 108 | spin_unlock(&phy->lock); |
alex.bluesman.smirnov@gmail.com | e1e49b6 | 2012-05-15 20:50:30 +0000 | [diff] [blame] | 109 | |
| 110 | return ret; |
| 111 | } |
| 112 | |
| 113 | static void |
Alexander Aring | 5a50439 | 2014-10-25 17:16:34 +0200 | [diff] [blame] | 114 | fakelb_hw_stop(struct ieee802154_hw *hw) { |
Alexander Aring | db3f5d0 | 2015-05-17 21:45:00 +0200 | [diff] [blame] | 115 | struct fakelb_phy *phy = hw->priv; |
alex.bluesman.smirnov@gmail.com | e1e49b6 | 2012-05-15 20:50:30 +0000 | [diff] [blame] | 116 | |
Alexander Aring | db3f5d0 | 2015-05-17 21:45:00 +0200 | [diff] [blame] | 117 | spin_lock(&phy->lock); |
| 118 | phy->working = 0; |
| 119 | spin_unlock(&phy->lock); |
alex.bluesman.smirnov@gmail.com | e1e49b6 | 2012-05-15 20:50:30 +0000 | [diff] [blame] | 120 | } |
| 121 | |
Alexander Aring | 1630186 | 2014-10-28 18:21:18 +0100 | [diff] [blame] | 122 | static const struct ieee802154_ops fakelb_ops = { |
alex.bluesman.smirnov@gmail.com | e1e49b6 | 2012-05-15 20:50:30 +0000 | [diff] [blame] | 123 | .owner = THIS_MODULE, |
Alexander Aring | ed0a5dc | 2014-10-26 09:37:08 +0100 | [diff] [blame] | 124 | .xmit_sync = fakelb_hw_xmit, |
alex.bluesman.smirnov@gmail.com | e1e49b6 | 2012-05-15 20:50:30 +0000 | [diff] [blame] | 125 | .ed = fakelb_hw_ed, |
| 126 | .set_channel = fakelb_hw_channel, |
| 127 | .start = fakelb_hw_start, |
| 128 | .stop = fakelb_hw_stop, |
| 129 | }; |
| 130 | |
| 131 | /* Number of dummy devices to be set up by this module. */ |
| 132 | module_param(numlbs, int, 0); |
| 133 | MODULE_PARM_DESC(numlbs, " number of pseudo devices"); |
| 134 | |
| 135 | static int fakelb_add_one(struct device *dev, struct fakelb_priv *fake) |
| 136 | { |
Alexander Aring | db3f5d0 | 2015-05-17 21:45:00 +0200 | [diff] [blame] | 137 | struct fakelb_phy *phy; |
alex.bluesman.smirnov@gmail.com | e1e49b6 | 2012-05-15 20:50:30 +0000 | [diff] [blame] | 138 | int err; |
Alexander Aring | 5a50439 | 2014-10-25 17:16:34 +0200 | [diff] [blame] | 139 | struct ieee802154_hw *hw; |
alex.bluesman.smirnov@gmail.com | e1e49b6 | 2012-05-15 20:50:30 +0000 | [diff] [blame] | 140 | |
Alexander Aring | db3f5d0 | 2015-05-17 21:45:00 +0200 | [diff] [blame] | 141 | hw = ieee802154_alloc_hw(sizeof(*phy), &fakelb_ops); |
Alexander Aring | 5a50439 | 2014-10-25 17:16:34 +0200 | [diff] [blame] | 142 | if (!hw) |
alex.bluesman.smirnov@gmail.com | e1e49b6 | 2012-05-15 20:50:30 +0000 | [diff] [blame] | 143 | return -ENOMEM; |
| 144 | |
Alexander Aring | db3f5d0 | 2015-05-17 21:45:00 +0200 | [diff] [blame] | 145 | phy = hw->priv; |
| 146 | phy->hw = hw; |
alex.bluesman.smirnov@gmail.com | e1e49b6 | 2012-05-15 20:50:30 +0000 | [diff] [blame] | 147 | |
| 148 | /* 868 MHz BPSK 802.15.4-2003 */ |
Alexander Aring | 72f655e | 2015-05-17 21:44:42 +0200 | [diff] [blame] | 149 | hw->phy->supported.channels[0] |= 1; |
alex.bluesman.smirnov@gmail.com | e1e49b6 | 2012-05-15 20:50:30 +0000 | [diff] [blame] | 150 | /* 915 MHz BPSK 802.15.4-2003 */ |
Alexander Aring | 72f655e | 2015-05-17 21:44:42 +0200 | [diff] [blame] | 151 | hw->phy->supported.channels[0] |= 0x7fe; |
alex.bluesman.smirnov@gmail.com | e1e49b6 | 2012-05-15 20:50:30 +0000 | [diff] [blame] | 152 | /* 2.4 GHz O-QPSK 802.15.4-2003 */ |
Alexander Aring | 72f655e | 2015-05-17 21:44:42 +0200 | [diff] [blame] | 153 | hw->phy->supported.channels[0] |= 0x7FFF800; |
alex.bluesman.smirnov@gmail.com | e1e49b6 | 2012-05-15 20:50:30 +0000 | [diff] [blame] | 154 | /* 868 MHz ASK 802.15.4-2006 */ |
Alexander Aring | 72f655e | 2015-05-17 21:44:42 +0200 | [diff] [blame] | 155 | hw->phy->supported.channels[1] |= 1; |
alex.bluesman.smirnov@gmail.com | e1e49b6 | 2012-05-15 20:50:30 +0000 | [diff] [blame] | 156 | /* 915 MHz ASK 802.15.4-2006 */ |
Alexander Aring | 72f655e | 2015-05-17 21:44:42 +0200 | [diff] [blame] | 157 | hw->phy->supported.channels[1] |= 0x7fe; |
alex.bluesman.smirnov@gmail.com | e1e49b6 | 2012-05-15 20:50:30 +0000 | [diff] [blame] | 158 | /* 868 MHz O-QPSK 802.15.4-2006 */ |
Alexander Aring | 72f655e | 2015-05-17 21:44:42 +0200 | [diff] [blame] | 159 | hw->phy->supported.channels[2] |= 1; |
alex.bluesman.smirnov@gmail.com | e1e49b6 | 2012-05-15 20:50:30 +0000 | [diff] [blame] | 160 | /* 915 MHz O-QPSK 802.15.4-2006 */ |
Alexander Aring | 72f655e | 2015-05-17 21:44:42 +0200 | [diff] [blame] | 161 | hw->phy->supported.channels[2] |= 0x7fe; |
alex.bluesman.smirnov@gmail.com | e1e49b6 | 2012-05-15 20:50:30 +0000 | [diff] [blame] | 162 | /* 2.4 GHz CSS 802.15.4a-2007 */ |
Alexander Aring | 72f655e | 2015-05-17 21:44:42 +0200 | [diff] [blame] | 163 | hw->phy->supported.channels[3] |= 0x3fff; |
alex.bluesman.smirnov@gmail.com | e1e49b6 | 2012-05-15 20:50:30 +0000 | [diff] [blame] | 164 | /* UWB Sub-gigahertz 802.15.4a-2007 */ |
Alexander Aring | 72f655e | 2015-05-17 21:44:42 +0200 | [diff] [blame] | 165 | hw->phy->supported.channels[4] |= 1; |
alex.bluesman.smirnov@gmail.com | e1e49b6 | 2012-05-15 20:50:30 +0000 | [diff] [blame] | 166 | /* UWB Low band 802.15.4a-2007 */ |
Alexander Aring | 72f655e | 2015-05-17 21:44:42 +0200 | [diff] [blame] | 167 | hw->phy->supported.channels[4] |= 0x1e; |
alex.bluesman.smirnov@gmail.com | e1e49b6 | 2012-05-15 20:50:30 +0000 | [diff] [blame] | 168 | /* UWB High band 802.15.4a-2007 */ |
Alexander Aring | 72f655e | 2015-05-17 21:44:42 +0200 | [diff] [blame] | 169 | hw->phy->supported.channels[4] |= 0xffe0; |
alex.bluesman.smirnov@gmail.com | e1e49b6 | 2012-05-15 20:50:30 +0000 | [diff] [blame] | 170 | /* 750 MHz O-QPSK 802.15.4c-2009 */ |
Alexander Aring | 72f655e | 2015-05-17 21:44:42 +0200 | [diff] [blame] | 171 | hw->phy->supported.channels[5] |= 0xf; |
alex.bluesman.smirnov@gmail.com | e1e49b6 | 2012-05-15 20:50:30 +0000 | [diff] [blame] | 172 | /* 750 MHz MPSK 802.15.4c-2009 */ |
Alexander Aring | 72f655e | 2015-05-17 21:44:42 +0200 | [diff] [blame] | 173 | hw->phy->supported.channels[5] |= 0xf0; |
alex.bluesman.smirnov@gmail.com | e1e49b6 | 2012-05-15 20:50:30 +0000 | [diff] [blame] | 174 | /* 950 MHz BPSK 802.15.4d-2009 */ |
Alexander Aring | 72f655e | 2015-05-17 21:44:42 +0200 | [diff] [blame] | 175 | hw->phy->supported.channels[6] |= 0x3ff; |
alex.bluesman.smirnov@gmail.com | e1e49b6 | 2012-05-15 20:50:30 +0000 | [diff] [blame] | 176 | /* 950 MHz GFSK 802.15.4d-2009 */ |
Alexander Aring | 72f655e | 2015-05-17 21:44:42 +0200 | [diff] [blame] | 177 | hw->phy->supported.channels[6] |= 0x3ffc00; |
alex.bluesman.smirnov@gmail.com | e1e49b6 | 2012-05-15 20:50:30 +0000 | [diff] [blame] | 178 | |
Alexander Aring | db3f5d0 | 2015-05-17 21:45:00 +0200 | [diff] [blame] | 179 | INIT_LIST_HEAD(&phy->list); |
| 180 | phy->fake = fake; |
alex.bluesman.smirnov@gmail.com | e1e49b6 | 2012-05-15 20:50:30 +0000 | [diff] [blame] | 181 | |
Alexander Aring | db3f5d0 | 2015-05-17 21:45:00 +0200 | [diff] [blame] | 182 | spin_lock_init(&phy->lock); |
alex.bluesman.smirnov@gmail.com | e1e49b6 | 2012-05-15 20:50:30 +0000 | [diff] [blame] | 183 | |
Alexander Aring | 5a50439 | 2014-10-25 17:16:34 +0200 | [diff] [blame] | 184 | hw->parent = dev; |
alex.bluesman.smirnov@gmail.com | e1e49b6 | 2012-05-15 20:50:30 +0000 | [diff] [blame] | 185 | |
Alexander Aring | 5a50439 | 2014-10-25 17:16:34 +0200 | [diff] [blame] | 186 | err = ieee802154_register_hw(hw); |
alex.bluesman.smirnov@gmail.com | e1e49b6 | 2012-05-15 20:50:30 +0000 | [diff] [blame] | 187 | if (err) |
| 188 | goto err_reg; |
| 189 | |
Alexander Aring | 3335d98 | 2015-05-17 21:45:02 +0200 | [diff] [blame^] | 190 | write_lock_bh(&fakelb_lock); |
Alexander Aring | db3f5d0 | 2015-05-17 21:45:00 +0200 | [diff] [blame] | 191 | list_add_tail(&phy->list, &fake->list); |
Alexander Aring | 3335d98 | 2015-05-17 21:45:02 +0200 | [diff] [blame^] | 192 | write_unlock_bh(&fakelb_lock); |
alex.bluesman.smirnov@gmail.com | e1e49b6 | 2012-05-15 20:50:30 +0000 | [diff] [blame] | 193 | |
| 194 | return 0; |
| 195 | |
| 196 | err_reg: |
Alexander Aring | db3f5d0 | 2015-05-17 21:45:00 +0200 | [diff] [blame] | 197 | ieee802154_free_hw(phy->hw); |
alex.bluesman.smirnov@gmail.com | e1e49b6 | 2012-05-15 20:50:30 +0000 | [diff] [blame] | 198 | return err; |
| 199 | } |
| 200 | |
Alexander Aring | db3f5d0 | 2015-05-17 21:45:00 +0200 | [diff] [blame] | 201 | static void fakelb_del(struct fakelb_phy *phy) |
alex.bluesman.smirnov@gmail.com | e1e49b6 | 2012-05-15 20:50:30 +0000 | [diff] [blame] | 202 | { |
Alexander Aring | 3335d98 | 2015-05-17 21:45:02 +0200 | [diff] [blame^] | 203 | write_lock_bh(&fakelb_lock); |
Alexander Aring | db3f5d0 | 2015-05-17 21:45:00 +0200 | [diff] [blame] | 204 | list_del(&phy->list); |
Alexander Aring | 3335d98 | 2015-05-17 21:45:02 +0200 | [diff] [blame^] | 205 | write_unlock_bh(&fakelb_lock); |
alex.bluesman.smirnov@gmail.com | e1e49b6 | 2012-05-15 20:50:30 +0000 | [diff] [blame] | 206 | |
Alexander Aring | db3f5d0 | 2015-05-17 21:45:00 +0200 | [diff] [blame] | 207 | ieee802154_unregister_hw(phy->hw); |
| 208 | ieee802154_free_hw(phy->hw); |
alex.bluesman.smirnov@gmail.com | e1e49b6 | 2012-05-15 20:50:30 +0000 | [diff] [blame] | 209 | } |
| 210 | |
Bill Pemberton | bb1f460 | 2012-12-03 09:24:12 -0500 | [diff] [blame] | 211 | static int fakelb_probe(struct platform_device *pdev) |
alex.bluesman.smirnov@gmail.com | e1e49b6 | 2012-05-15 20:50:30 +0000 | [diff] [blame] | 212 | { |
| 213 | struct fakelb_priv *priv; |
Alexander Aring | db3f5d0 | 2015-05-17 21:45:00 +0200 | [diff] [blame] | 214 | struct fakelb_phy *phy, *tmp; |
alex.bluesman.smirnov@gmail.com | e1e49b6 | 2012-05-15 20:50:30 +0000 | [diff] [blame] | 215 | int err = -ENOMEM; |
| 216 | int i; |
| 217 | |
Himangi Saraogi | 12b5c38 | 2014-05-19 22:25:11 +0530 | [diff] [blame] | 218 | priv = devm_kzalloc(&pdev->dev, sizeof(struct fakelb_priv), |
| 219 | GFP_KERNEL); |
alex.bluesman.smirnov@gmail.com | e1e49b6 | 2012-05-15 20:50:30 +0000 | [diff] [blame] | 220 | if (!priv) |
| 221 | goto err_alloc; |
| 222 | |
| 223 | INIT_LIST_HEAD(&priv->list); |
alex.bluesman.smirnov@gmail.com | e1e49b6 | 2012-05-15 20:50:30 +0000 | [diff] [blame] | 224 | |
| 225 | for (i = 0; i < numlbs; i++) { |
| 226 | err = fakelb_add_one(&pdev->dev, priv); |
| 227 | if (err < 0) |
| 228 | goto err_slave; |
| 229 | } |
| 230 | |
| 231 | platform_set_drvdata(pdev, priv); |
| 232 | dev_info(&pdev->dev, "added ieee802154 hardware\n"); |
| 233 | return 0; |
| 234 | |
| 235 | err_slave: |
Alexander Aring | db3f5d0 | 2015-05-17 21:45:00 +0200 | [diff] [blame] | 236 | list_for_each_entry_safe(phy, tmp, &priv->list, list) |
| 237 | fakelb_del(phy); |
alex.bluesman.smirnov@gmail.com | e1e49b6 | 2012-05-15 20:50:30 +0000 | [diff] [blame] | 238 | err_alloc: |
| 239 | return err; |
| 240 | } |
| 241 | |
Bill Pemberton | bb1f460 | 2012-12-03 09:24:12 -0500 | [diff] [blame] | 242 | static int fakelb_remove(struct platform_device *pdev) |
alex.bluesman.smirnov@gmail.com | e1e49b6 | 2012-05-15 20:50:30 +0000 | [diff] [blame] | 243 | { |
| 244 | struct fakelb_priv *priv = platform_get_drvdata(pdev); |
Alexander Aring | db3f5d0 | 2015-05-17 21:45:00 +0200 | [diff] [blame] | 245 | struct fakelb_phy *phy, *temp; |
alex.bluesman.smirnov@gmail.com | e1e49b6 | 2012-05-15 20:50:30 +0000 | [diff] [blame] | 246 | |
Alexander Aring | db3f5d0 | 2015-05-17 21:45:00 +0200 | [diff] [blame] | 247 | list_for_each_entry_safe(phy, temp, &priv->list, list) |
| 248 | fakelb_del(phy); |
alex.bluesman.smirnov@gmail.com | e1e49b6 | 2012-05-15 20:50:30 +0000 | [diff] [blame] | 249 | |
| 250 | return 0; |
| 251 | } |
| 252 | |
| 253 | static struct platform_device *ieee802154fake_dev; |
| 254 | |
| 255 | static struct platform_driver ieee802154fake_driver = { |
| 256 | .probe = fakelb_probe, |
Bill Pemberton | bb1f460 | 2012-12-03 09:24:12 -0500 | [diff] [blame] | 257 | .remove = fakelb_remove, |
alex.bluesman.smirnov@gmail.com | e1e49b6 | 2012-05-15 20:50:30 +0000 | [diff] [blame] | 258 | .driver = { |
| 259 | .name = "ieee802154fakelb", |
alex.bluesman.smirnov@gmail.com | e1e49b6 | 2012-05-15 20:50:30 +0000 | [diff] [blame] | 260 | }, |
| 261 | }; |
| 262 | |
| 263 | static __init int fakelb_init_module(void) |
| 264 | { |
| 265 | ieee802154fake_dev = platform_device_register_simple( |
| 266 | "ieee802154fakelb", -1, NULL, 0); |
| 267 | return platform_driver_register(&ieee802154fake_driver); |
| 268 | } |
| 269 | |
| 270 | static __exit void fake_remove_module(void) |
| 271 | { |
| 272 | platform_driver_unregister(&ieee802154fake_driver); |
| 273 | platform_device_unregister(ieee802154fake_dev); |
| 274 | } |
| 275 | |
| 276 | module_init(fakelb_init_module); |
| 277 | module_exit(fake_remove_module); |
| 278 | MODULE_LICENSE("GPL"); |