Sjur Braendeland | b482cd2 | 2010-03-30 13:56:23 +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 | #include <linux/stddef.h> |
| 8 | #include <linux/slab.h> |
| 9 | #include <net/caif/caif_layer.h> |
| 10 | #include <net/caif/cfsrvl.h> |
| 11 | #include <net/caif/cfpkt.h> |
| 12 | |
| 13 | static int cfdbgl_receive(struct cflayer *layr, struct cfpkt *pkt); |
| 14 | static int cfdbgl_transmit(struct cflayer *layr, struct cfpkt *pkt); |
| 15 | |
| 16 | struct cflayer *cfdbgl_create(u8 channel_id, struct dev_info *dev_info) |
| 17 | { |
| 18 | struct cfsrvl *dbg = kmalloc(sizeof(struct cfsrvl), GFP_ATOMIC); |
| 19 | if (!dbg) { |
| 20 | pr_warning("CAIF: %s(): Out of memory\n", __func__); |
| 21 | return NULL; |
| 22 | } |
| 23 | caif_assert(offsetof(struct cfsrvl, layer) == 0); |
| 24 | memset(dbg, 0, sizeof(struct cfsrvl)); |
| 25 | cfsrvl_init(dbg, channel_id, dev_info); |
| 26 | dbg->layer.receive = cfdbgl_receive; |
| 27 | dbg->layer.transmit = cfdbgl_transmit; |
| 28 | snprintf(dbg->layer.name, CAIF_LAYER_NAME_SZ - 1, "dbg%d", channel_id); |
| 29 | return &dbg->layer; |
| 30 | } |
| 31 | |
| 32 | static int cfdbgl_receive(struct cflayer *layr, struct cfpkt *pkt) |
| 33 | { |
| 34 | return layr->up->receive(layr->up, pkt); |
| 35 | } |
| 36 | |
| 37 | static int cfdbgl_transmit(struct cflayer *layr, struct cfpkt *pkt) |
| 38 | { |
| 39 | return layr->dn->transmit(layr->dn, pkt); |
| 40 | } |