diff --git a/sys/fs/devfs/Makefile b/sys/fs/devfs/Makefile index 67d6ef1eb3..a218490ff0 100644 --- a/sys/fs/devfs/Makefile +++ b/sys/fs/devfs/Makefile @@ -1,2 +1,4 @@ MODULE=devfs +SRC = devfs.c auto_init_devfs.c +SUBMODULES = 1 include $(RIOTBASE)/Makefile.base diff --git a/sys/fs/devfs/random-vfs.c b/sys/fs/devfs/hwrng.c similarity index 62% rename from sys/fs/devfs/random-vfs.c rename to sys/fs/devfs/hwrng.c index d5be014193..c174e8f016 100644 --- a/sys/fs/devfs/random-vfs.c +++ b/sys/fs/devfs/hwrng.c @@ -21,8 +21,6 @@ #include "vfs.h" -#ifdef MODULE_DEVFS_HWRNG - #include "periph/hwrng.h" static ssize_t hwrng_vfs_read(vfs_file_t *filp, void *dest, size_t nbytes); @@ -39,23 +37,3 @@ static ssize_t hwrng_vfs_read(vfs_file_t *filp, void *dest, size_t nbytes) return nbytes; } -#endif /* MODULE_PERIPH_HWRNG */ - -#ifdef MODULE_DEVFS_RANDOM - -#include "random.h" - -static ssize_t random_vfs_read(vfs_file_t *filp, void *dest, size_t nbytes); - -const vfs_file_ops_t random_vfs_ops = { - .read = random_vfs_read, -}; - -static ssize_t random_vfs_read(vfs_file_t *filp, void *dest, size_t nbytes) -{ - (void)filp; - random_bytes(dest, nbytes); - - return nbytes; -} -#endif /* MODULE_RANDOM */ diff --git a/sys/fs/devfs/random.c b/sys/fs/devfs/random.c new file mode 100644 index 0000000000..3eb3be7cea --- /dev/null +++ b/sys/fs/devfs/random.c @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2017 OTA keys S.A. + * + * This file is subject to the terms and conditions of the GNU Lesser + * General Public License v2.1. See the file LICENSE in the top level + * directory for more details. + * + */ + +/** + * @ingroup sys_fs_devfs + * @{ + * + * @file + * @brief Random backends for devfs implementation + * + * @author Vincent Dupont + * + * @} + */ + +#include "vfs.h" +#include "random.h" + +static ssize_t random_vfs_read(vfs_file_t *filp, void *dest, size_t nbytes); + +const vfs_file_ops_t random_vfs_ops = { + .read = random_vfs_read, +}; + +static ssize_t random_vfs_read(vfs_file_t *filp, void *dest, size_t nbytes) +{ + (void)filp; + random_bytes(dest, nbytes); + + return nbytes; +}