IgH EtherCAT Master  1.5.3
flag.c
Go to the documentation of this file.
1 /*****************************************************************************
2  *
3  * Copyright (C) 2021 Florian Pose, Ingenieurgemeinschaft IgH
4  *
5  * This file is part of the IgH EtherCAT Master.
6  *
7  * The IgH EtherCAT Master is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License version 2, as
9  * published by the Free Software Foundation.
10  *
11  * The IgH EtherCAT Master is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
14  * Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License along
17  * with the IgH EtherCAT Master; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19  *
20  ****************************************************************************/
21 
26 /****************************************************************************/
27 
28 #include <linux/slab.h>
29 
30 #include "flag.h"
31 
32 /*****************************************************************************/
33 
37  ec_flag_t *flag,
38  const char *key,
39  int32_t value
40  )
41 {
42  if (!key || strlen(key) == 0) {
43  return -EINVAL;
44  }
45 
46  if (!(flag->key = (uint8_t *) kmalloc(strlen(key) + 1, GFP_KERNEL))) {
47  return -ENOMEM;
48  }
49 
50  strcpy(flag->key, key);
51  flag->value = value;
52  return 0;
53 }
54 
55 /*****************************************************************************/
56 
60  ec_flag_t *flag
61  )
62 {
63  if (flag->key) {
64  kfree(flag->key);
65  flag->key = NULL;
66  }
67 }
68 
69 /*****************************************************************************/
char * key
Flag key (null-terminated ASCII string.
Definition: flag.h:40
void ec_flag_clear(ec_flag_t *flag)
SDO request destructor.
Definition: flag.c:59
Slave configutation feature flag.
Definition: flag.h:38
EtherCAT Slave Configuration Feature Flag.
int32_t value
Flag value (meaning depends on key).
Definition: flag.h:41
int ec_flag_init(ec_flag_t *flag, const char *key, int32_t value)
SDO request constructor.
Definition: flag.c:36