[rtems commit] libblock: Split file

Joel Sherrill joel at rtems.org
Thu Mar 29 14:14:30 UTC 2012


Module:    rtems
Branch:    master
Commit:    424177418125deb0be7696f5fb0bcb7632286080
Changeset: http://git.rtems.org/rtems/commit/?id=424177418125deb0be7696f5fb0bcb7632286080

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Mon Mar  5 10:02:52 2012 +0100

libblock: Split file

---

 cpukit/libblock/Makefile.am            |    1 +
 cpukit/libblock/src/ramdisk-init.c     |   69 +++------------------------
 cpukit/libblock/src/ramdisk-register.c |   80 ++++++++++++++++++++++++++++++++
 3 files changed, 89 insertions(+), 61 deletions(-)

diff --git a/cpukit/libblock/Makefile.am b/cpukit/libblock/Makefile.am
index 15c3852..04eca6f 100644
--- a/cpukit/libblock/Makefile.am
+++ b/cpukit/libblock/Makefile.am
@@ -14,6 +14,7 @@ libblock_a_SOURCES = src/bdbuf.c \
     src/ramdisk-driver.c \
     src/ramdisk-init.c \
     src/ramdisk-config.c \
+    src/ramdisk-register.c \
     src/ide_part_table.c \
     src/nvdisk.c \
     src/nvdisk-sram.c \
diff --git a/cpukit/libblock/src/ramdisk-init.c b/cpukit/libblock/src/ramdisk-init.c
index fb8def0..d5dc1e7 100644
--- a/cpukit/libblock/src/ramdisk-init.c
+++ b/cpukit/libblock/src/ramdisk-init.c
@@ -7,22 +7,21 @@
  */
 
 /*
- * Copyright (c) 2009
- * embedded brains GmbH
- * Obere Lagerstr. 30
- * D-82178 Puchheim
- * Germany
- * <rtems at embedded-brains.de>
+ * Copyright (c) 2009-2012 embedded brains GmbH.  All rights reserved.
+ *
+ *  embedded brains GmbH
+ *  Obere Lagerstr. 30
+ *  82178 Puchheim
+ *  Germany
+ *  <rtems at embedded-brains.de>
  *
  * The license and distribution terms for this file may be
  * found in the file LICENSE in this distribution or at
  * http://www.rtems.com/license/LICENSE.
- *
- * $Id$
  */
 
 #ifdef HAVE_CONFIG_H
-#include "config.h"
+  #include "config.h"
 #endif
 
 #include <stdlib.h>
@@ -30,11 +29,6 @@
 #include <rtems.h>
 #include <rtems/ramdisk.h>
 
-const rtems_driver_address_table ramdisk_ops = {
-  .initialization_entry = NULL,
-  RTEMS_GENERIC_BLOCK_DEVICE_DRIVER_ENTRIES
-};
-
 ramdisk *ramdisk_allocate(
   void *area_begin,
   uint32_t block_size,
@@ -77,50 +71,3 @@ void ramdisk_free(ramdisk *rd)
     free(rd);
   }
 }
-
-rtems_status_code ramdisk_register(
-  uint32_t block_size,
-  rtems_blkdev_bnum block_count,
-  bool trace,
-  const char *disk,
-  dev_t *dev_ptr
-)
-{
-  rtems_status_code sc = RTEMS_SUCCESSFUL;
-  rtems_device_major_number major = 0;
-  ramdisk *rd = NULL;
-  dev_t dev = 0;
-
-  sc = rtems_io_register_driver(0, &ramdisk_ops, &major);
-  if (sc != RTEMS_SUCCESSFUL) {
-    return RTEMS_UNSATISFIED;
-  }
-
-  rd = ramdisk_allocate(NULL, block_size, block_count, trace);
-  if (rd == NULL) {
-    rtems_io_unregister_driver(major);
-
-    return RTEMS_UNSATISFIED;
-  }
-
-  dev = rtems_filesystem_make_dev_t(major, 0);
-
-  sc = rtems_disk_create_phys(
-    dev,
-    block_size,
-    block_count,
-    ramdisk_ioctl,
-    rd,
-    disk
-  );
-  if (sc != RTEMS_SUCCESSFUL) {
-    ramdisk_free(rd);
-    rtems_io_unregister_driver(major);
-
-    return RTEMS_UNSATISFIED;
-  }
-
-  *dev_ptr = dev;
-
-  return RTEMS_SUCCESSFUL;
-}
diff --git a/cpukit/libblock/src/ramdisk-register.c b/cpukit/libblock/src/ramdisk-register.c
new file mode 100644
index 0000000..c720a2c
--- /dev/null
+++ b/cpukit/libblock/src/ramdisk-register.c
@@ -0,0 +1,80 @@
+/**
+ * @file
+ *
+ * @ingroup rtems_ramdisk
+ *
+ * @brief RAM disk block device implementation.
+ */
+
+/*
+ * Copyright (c) 2009-2012 embedded brains GmbH.  All rights reserved.
+ *
+ *  embedded brains GmbH
+ *  Obere Lagerstr. 30
+ *  82178 Puchheim
+ *  Germany
+ *  <rtems at embedded-brains.de>
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.com/license/LICENSE.
+ */
+
+#ifdef HAVE_CONFIG_H
+  #include "config.h"
+#endif
+
+#include <rtems.h>
+#include <rtems/ramdisk.h>
+
+const rtems_driver_address_table ramdisk_ops = {
+  .initialization_entry = NULL,
+  RTEMS_GENERIC_BLOCK_DEVICE_DRIVER_ENTRIES
+};
+
+rtems_status_code ramdisk_register(
+  uint32_t block_size,
+  rtems_blkdev_bnum block_count,
+  bool trace,
+  const char *disk,
+  dev_t *dev_ptr
+)
+{
+  rtems_status_code sc = RTEMS_SUCCESSFUL;
+  rtems_device_major_number major = 0;
+  ramdisk *rd = NULL;
+  dev_t dev = 0;
+
+  sc = rtems_io_register_driver(0, &ramdisk_ops, &major);
+  if (sc != RTEMS_SUCCESSFUL) {
+    return RTEMS_UNSATISFIED;
+  }
+
+  rd = ramdisk_allocate(NULL, block_size, block_count, trace);
+  if (rd == NULL) {
+    rtems_io_unregister_driver(major);
+
+    return RTEMS_UNSATISFIED;
+  }
+
+  dev = rtems_filesystem_make_dev_t(major, 0);
+
+  sc = rtems_disk_create_phys(
+    dev,
+    block_size,
+    block_count,
+    ramdisk_ioctl,
+    rd,
+    disk
+  );
+  if (sc != RTEMS_SUCCESSFUL) {
+    ramdisk_free(rd);
+    rtems_io_unregister_driver(major);
+
+    return RTEMS_UNSATISFIED;
+  }
+
+  *dev_ptr = dev;
+
+  return RTEMS_SUCCESSFUL;
+}




More information about the vc mailing list