Inaky Perez-Gonzalez | 60fa9ca | 2008-12-20 16:57:34 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Linux WiMAX |
| 3 | * Internal API for kernel space WiMAX stack |
| 4 | * |
| 5 | * |
| 6 | * Copyright (C) 2007 Intel Corporation <linux-wimax@intel.com> |
| 7 | * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com> |
| 8 | * |
| 9 | * This program is free software; you can redistribute it and/or |
| 10 | * modify it under the terms of the GNU General Public License version |
| 11 | * 2 as published by the Free Software Foundation. |
| 12 | * |
| 13 | * This program is distributed in the hope that it will be useful, |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | * GNU General Public License for more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU General Public License |
| 19 | * along with this program; if not, write to the Free Software |
| 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
| 21 | * 02110-1301, USA. |
| 22 | * |
| 23 | * |
| 24 | * This header file is for declarations and definitions internal to |
| 25 | * the WiMAX stack. For public APIs and documentation, see |
| 26 | * include/net/wimax.h and include/linux/wimax.h. |
| 27 | */ |
| 28 | |
| 29 | #ifndef __WIMAX_INTERNAL_H__ |
| 30 | #define __WIMAX_INTERNAL_H__ |
| 31 | #ifdef __KERNEL__ |
| 32 | |
Fabian Frederick | 28b7dea | 2014-10-07 22:12:03 +0200 | [diff] [blame] | 33 | #ifdef pr_fmt |
| 34 | #undef pr_fmt |
| 35 | #endif |
| 36 | |
| 37 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
| 38 | |
Inaky Perez-Gonzalez | 60fa9ca | 2008-12-20 16:57:34 -0800 | [diff] [blame] | 39 | #include <linux/device.h> |
| 40 | #include <net/wimax.h> |
| 41 | |
| 42 | |
| 43 | /* |
| 44 | * Decide if a (locked) device is ready for use |
| 45 | * |
| 46 | * Before using the device structure, it must be locked |
| 47 | * (wimax_dev->mutex). As well, most operations need to call this |
| 48 | * function to check if the state is the right one. |
| 49 | * |
| 50 | * An error value will be returned if the state is not the right |
| 51 | * one. In that case, the caller should not attempt to use the device |
| 52 | * and just unlock it. |
| 53 | */ |
| 54 | static inline __must_check |
| 55 | int wimax_dev_is_ready(struct wimax_dev *wimax_dev) |
| 56 | { |
| 57 | if (wimax_dev->state == __WIMAX_ST_NULL) |
| 58 | return -EINVAL; /* Device is not even registered! */ |
| 59 | if (wimax_dev->state == WIMAX_ST_DOWN) |
| 60 | return -ENOMEDIUM; |
| 61 | if (wimax_dev->state == __WIMAX_ST_QUIESCING) |
| 62 | return -ESHUTDOWN; |
| 63 | return 0; |
| 64 | } |
| 65 | |
| 66 | |
| 67 | static inline |
| 68 | void __wimax_state_set(struct wimax_dev *wimax_dev, enum wimax_st state) |
| 69 | { |
| 70 | wimax_dev->state = state; |
| 71 | } |
Joe Perches | c1b1203 | 2013-10-18 13:48:25 -0700 | [diff] [blame] | 72 | void __wimax_state_change(struct wimax_dev *, enum wimax_st); |
Inaky Perez-Gonzalez | 60fa9ca | 2008-12-20 16:57:34 -0800 | [diff] [blame] | 73 | |
| 74 | #ifdef CONFIG_DEBUG_FS |
Joe Perches | c1b1203 | 2013-10-18 13:48:25 -0700 | [diff] [blame] | 75 | int wimax_debugfs_add(struct wimax_dev *); |
| 76 | void wimax_debugfs_rm(struct wimax_dev *); |
Inaky Perez-Gonzalez | 60fa9ca | 2008-12-20 16:57:34 -0800 | [diff] [blame] | 77 | #else |
| 78 | static inline int wimax_debugfs_add(struct wimax_dev *wimax_dev) |
| 79 | { |
| 80 | return 0; |
| 81 | } |
| 82 | static inline void wimax_debugfs_rm(struct wimax_dev *wimax_dev) {} |
| 83 | #endif |
| 84 | |
Joe Perches | c1b1203 | 2013-10-18 13:48:25 -0700 | [diff] [blame] | 85 | void wimax_id_table_add(struct wimax_dev *); |
| 86 | struct wimax_dev *wimax_dev_get_by_genl_info(struct genl_info *, int); |
| 87 | void wimax_id_table_rm(struct wimax_dev *); |
| 88 | void wimax_id_table_release(void); |
Inaky Perez-Gonzalez | 60fa9ca | 2008-12-20 16:57:34 -0800 | [diff] [blame] | 89 | |
Joe Perches | c1b1203 | 2013-10-18 13:48:25 -0700 | [diff] [blame] | 90 | int wimax_rfkill_add(struct wimax_dev *); |
| 91 | void wimax_rfkill_rm(struct wimax_dev *); |
Inaky Perez-Gonzalez | 60fa9ca | 2008-12-20 16:57:34 -0800 | [diff] [blame] | 92 | |
Johannes Berg | b61a5ee | 2013-11-14 17:14:42 +0100 | [diff] [blame] | 93 | /* generic netlink */ |
Inaky Perez-Gonzalez | 60fa9ca | 2008-12-20 16:57:34 -0800 | [diff] [blame] | 94 | extern struct genl_family wimax_gnl_family; |
Inaky Perez-Gonzalez | 60fa9ca | 2008-12-20 16:57:34 -0800 | [diff] [blame] | 95 | |
Johannes Berg | b61a5ee | 2013-11-14 17:14:42 +0100 | [diff] [blame] | 96 | /* ops */ |
| 97 | int wimax_gnl_doit_msg_from_user(struct sk_buff *skb, struct genl_info *info); |
| 98 | int wimax_gnl_doit_reset(struct sk_buff *skb, struct genl_info *info); |
| 99 | int wimax_gnl_doit_rfkill(struct sk_buff *skb, struct genl_info *info); |
| 100 | int wimax_gnl_doit_state_get(struct sk_buff *skb, struct genl_info *info); |
| 101 | |
Inaky Perez-Gonzalez | 60fa9ca | 2008-12-20 16:57:34 -0800 | [diff] [blame] | 102 | #endif /* #ifdef __KERNEL__ */ |
| 103 | #endif /* #ifndef __WIMAX_INTERNAL_H__ */ |