~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/net/caif/cfveil.c

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 // SPDX-License-Identifier: GPL-2.0-only
  2 /*
  3  * Copyright (C) ST-Ericsson AB 2010
  4  * Author:      Sjur Brendeland
  5  */
  6 
  7 #define pr_fmt(fmt) KBUILD_MODNAME ":%s(): " fmt, __func__
  8 
  9 #include <linux/stddef.h>
 10 #include <linux/slab.h>
 11 #include <net/caif/caif_layer.h>
 12 #include <net/caif/cfsrvl.h>
 13 #include <net/caif/cfpkt.h>
 14 
 15 #define VEI_PAYLOAD  0x00
 16 #define VEI_CMD_BIT  0x80
 17 #define VEI_FLOW_OFF 0x81
 18 #define VEI_FLOW_ON  0x80
 19 #define VEI_SET_PIN  0x82
 20 
 21 #define container_obj(layr) container_of(layr, struct cfsrvl, layer)
 22 
 23 static int cfvei_receive(struct cflayer *layr, struct cfpkt *pkt);
 24 static int cfvei_transmit(struct cflayer *layr, struct cfpkt *pkt);
 25 
 26 struct cflayer *cfvei_create(u8 channel_id, struct dev_info *dev_info)
 27 {
 28         struct cfsrvl *vei = kzalloc(sizeof(struct cfsrvl), GFP_ATOMIC);
 29         if (!vei)
 30                 return NULL;
 31         caif_assert(offsetof(struct cfsrvl, layer) == 0);
 32         cfsrvl_init(vei, channel_id, dev_info, true);
 33         vei->layer.receive = cfvei_receive;
 34         vei->layer.transmit = cfvei_transmit;
 35         snprintf(vei->layer.name, CAIF_LAYER_NAME_SZ, "vei%d", channel_id);
 36         return &vei->layer;
 37 }
 38 
 39 static int cfvei_receive(struct cflayer *layr, struct cfpkt *pkt)
 40 {
 41         u8 cmd;
 42         int ret;
 43         caif_assert(layr->up != NULL);
 44         caif_assert(layr->receive != NULL);
 45         caif_assert(layr->ctrlcmd != NULL);
 46 
 47 
 48         if (cfpkt_extr_head(pkt, &cmd, 1) < 0) {
 49                 pr_err("Packet is erroneous!\n");
 50                 cfpkt_destroy(pkt);
 51                 return -EPROTO;
 52         }
 53         switch (cmd) {
 54         case VEI_PAYLOAD:
 55                 ret = layr->up->receive(layr->up, pkt);
 56                 return ret;
 57         case VEI_FLOW_OFF:
 58                 layr->ctrlcmd(layr, CAIF_CTRLCMD_FLOW_OFF_IND, 0);
 59                 cfpkt_destroy(pkt);
 60                 return 0;
 61         case VEI_FLOW_ON:
 62                 layr->ctrlcmd(layr, CAIF_CTRLCMD_FLOW_ON_IND, 0);
 63                 cfpkt_destroy(pkt);
 64                 return 0;
 65         case VEI_SET_PIN:       /* SET RS232 PIN */
 66                 cfpkt_destroy(pkt);
 67                 return 0;
 68         default:                /* SET RS232 PIN */
 69                 pr_warn("Unknown VEI control packet %d (0x%x)!\n", cmd, cmd);
 70                 cfpkt_destroy(pkt);
 71                 return -EPROTO;
 72         }
 73 }
 74 
 75 static int cfvei_transmit(struct cflayer *layr, struct cfpkt *pkt)
 76 {
 77         u8 tmp = 0;
 78         struct caif_payload_info *info;
 79         int ret;
 80         struct cfsrvl *service = container_obj(layr);
 81         if (!cfsrvl_ready(service, &ret))
 82                 goto err;
 83         caif_assert(layr->dn != NULL);
 84         caif_assert(layr->dn->transmit != NULL);
 85 
 86         if (cfpkt_add_head(pkt, &tmp, 1) < 0) {
 87                 pr_err("Packet is erroneous!\n");
 88                 ret = -EPROTO;
 89                 goto err;
 90         }
 91 
 92         /* Add info-> for MUX-layer to route the packet out. */
 93         info = cfpkt_info(pkt);
 94         info->channel_id = service->layer.id;
 95         info->hdr_len = 1;
 96         info->dev_info = &service->dev_info;
 97         return layr->dn->transmit(layr->dn, pkt);
 98 err:
 99         cfpkt_destroy(pkt);
100         return ret;
101 }
102 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php