Sjur Braendeland | 09009f3 | 2010-03-30 13:56:21 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) ST-Ericsson AB 2010 |
| 3 | * Author: Sjur Brendeland/sjur.brandeland@stericsson.com |
| 4 | * License terms: GNU General Public License (GPL) version 2 |
| 5 | */ |
| 6 | |
| 7 | #ifndef CFSRVL_H_ |
| 8 | #define CFSRVL_H_ |
| 9 | #include <linux/list.h> |
| 10 | #include <linux/stddef.h> |
| 11 | #include <linux/types.h> |
Sjur Braendeland | 5b20865 | 2010-04-28 08:54:36 +0000 | [diff] [blame] | 12 | #include <linux/kref.h> |
| 13 | |
Sjur Braendeland | 09009f3 | 2010-03-30 13:56:21 +0000 | [diff] [blame] | 14 | struct cfsrvl { |
| 15 | struct cflayer layer; |
| 16 | bool open; |
| 17 | bool phy_flow_on; |
| 18 | bool modem_flow_on; |
Sjur Braendeland | b1c7424 | 2010-06-17 06:55:38 +0000 | [diff] [blame] | 19 | bool supports_flowctrl; |
Sjur Braendeland | a7da1f5 | 2010-06-17 06:55:39 +0000 | [diff] [blame] | 20 | void (*release)(struct kref *); |
Sjur Braendeland | 09009f3 | 2010-03-30 13:56:21 +0000 | [diff] [blame] | 21 | struct dev_info dev_info; |
Sjur Braendeland | 5b20865 | 2010-04-28 08:54:36 +0000 | [diff] [blame] | 22 | struct kref ref; |
Sjur Braendeland | 09009f3 | 2010-03-30 13:56:21 +0000 | [diff] [blame] | 23 | }; |
| 24 | |
Sjur Braendeland | 5b20865 | 2010-04-28 08:54:36 +0000 | [diff] [blame] | 25 | void cfsrvl_release(struct kref *kref); |
Sjur Braendeland | 09009f3 | 2010-03-30 13:56:21 +0000 | [diff] [blame] | 26 | struct cflayer *cfvei_create(u8 linkid, struct dev_info *dev_info); |
| 27 | struct cflayer *cfdgml_create(u8 linkid, struct dev_info *dev_info); |
| 28 | struct cflayer *cfutill_create(u8 linkid, struct dev_info *dev_info); |
| 29 | struct cflayer *cfvidl_create(u8 linkid, struct dev_info *dev_info); |
Sjur Braendeland | a7da1f5 | 2010-06-17 06:55:39 +0000 | [diff] [blame] | 30 | struct cflayer *cfrfml_create(u8 linkid, struct dev_info *dev_info, |
| 31 | int mtu_size); |
Sjur Braendeland | 09009f3 | 2010-03-30 13:56:21 +0000 | [diff] [blame] | 32 | struct cflayer *cfdbgl_create(u8 linkid, struct dev_info *dev_info); |
| 33 | bool cfsrvl_phyid_match(struct cflayer *layer, int phyid); |
| 34 | void cfservl_destroy(struct cflayer *layer); |
| 35 | void cfsrvl_init(struct cfsrvl *service, |
Sjur Braendeland | b1c7424 | 2010-06-17 06:55:38 +0000 | [diff] [blame] | 36 | u8 channel_id, |
| 37 | struct dev_info *dev_info, |
| 38 | bool supports_flowctrl); |
Sjur Braendeland | 09009f3 | 2010-03-30 13:56:21 +0000 | [diff] [blame] | 39 | bool cfsrvl_ready(struct cfsrvl *service, int *err); |
| 40 | u8 cfsrvl_getphyid(struct cflayer *layer); |
| 41 | |
Sjur Braendeland | 5b20865 | 2010-04-28 08:54:36 +0000 | [diff] [blame] | 42 | static inline void cfsrvl_get(struct cflayer *layr) |
| 43 | { |
| 44 | struct cfsrvl *s; |
| 45 | if (layr == NULL) |
| 46 | return; |
| 47 | s = container_of(layr, struct cfsrvl, layer); |
| 48 | kref_get(&s->ref); |
| 49 | } |
| 50 | |
| 51 | static inline void cfsrvl_put(struct cflayer *layr) |
| 52 | { |
| 53 | struct cfsrvl *s; |
| 54 | if (layr == NULL) |
| 55 | return; |
| 56 | s = container_of(layr, struct cfsrvl, layer); |
Sjur Braendeland | a7da1f5 | 2010-06-17 06:55:39 +0000 | [diff] [blame] | 57 | |
| 58 | WARN_ON(!s->release); |
| 59 | if (s->release) |
| 60 | kref_put(&s->ref, s->release); |
Sjur Braendeland | 5b20865 | 2010-04-28 08:54:36 +0000 | [diff] [blame] | 61 | } |
| 62 | |
Sjur Braendeland | 09009f3 | 2010-03-30 13:56:21 +0000 | [diff] [blame] | 63 | #endif /* CFSRVL_H_ */ |