]> granicus.if.org Git - strace/blobdiff - mtd.c
Remove linux/ptp_clock.h
[strace] / mtd.c
diff --git a/mtd.c b/mtd.c
index eea030056027eda17aeab523cbe1edabe22876d1..52957f9d36746046efe74625147d8190e52d6276 100644 (file)
--- a/mtd.c
+++ b/mtd.c
@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2012 Mike Frysinger <vapier@gentoo.org>
+ * Copyright (c) 2012-2017 The strace developers.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
 
 #include "defs.h"
 
-#include DEF_MPERS_TYPE(struct_mtd_oob_buf)
+#ifdef HAVE_STRUCT_MTD_WRITE_REQ
 
-#include <linux/ioctl.h>
+# include DEF_MPERS_TYPE(struct_mtd_oob_buf)
 
-/* The mtd api changes quickly, so we have to keep a local copy */
-#include <linux/version.h>
-#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 3, 0)
-# include "mtd-abi.h"
-#else
+# include <linux/ioctl.h>
 # include <mtd/mtd-abi.h>
-#endif
 
 typedef struct mtd_oob_buf struct_mtd_oob_buf;
 
+#endif /* HAVE_STRUCT_MTD_WRITE_REQ */
+
 #include MPERS_DEFS
 
-#include "xlat/mtd_mode_options.h"
-#include "xlat/mtd_file_mode_options.h"
-#include "xlat/mtd_type_options.h"
-#include "xlat/mtd_flags_options.h"
-#include "xlat/mtd_otp_options.h"
-#include "xlat/mtd_nandecc_options.h"
+#ifdef HAVE_STRUCT_MTD_WRITE_REQ
+
+# include "xlat/mtd_mode_options.h"
+# include "xlat/mtd_file_mode_options.h"
+# include "xlat/mtd_type_options.h"
+# include "xlat/mtd_flags_options.h"
+# include "xlat/mtd_otp_options.h"
+# include "xlat/mtd_nandecc_options.h"
 
 static void
-decode_erase_info_user(struct tcb *const tcp, const kernel_ureg_t addr)
+decode_erase_info_user(struct tcb *const tcp, const kernel_ulong_t addr)
 {
        struct erase_info_user einfo;
 
@@ -62,7 +62,7 @@ decode_erase_info_user(struct tcb *const tcp, const kernel_ureg_t addr)
 }
 
 static void
-decode_erase_info_user64(struct tcb *const tcp, const kernel_ureg_t addr)
+decode_erase_info_user64(struct tcb *const tcp, const kernel_ulong_t addr)
 {
        struct erase_info_user64 einfo64;
 
@@ -75,7 +75,7 @@ decode_erase_info_user64(struct tcb *const tcp, const kernel_ureg_t addr)
 }
 
 static void
-decode_mtd_oob_buf(struct tcb *const tcp, const kernel_ureg_t addr)
+decode_mtd_oob_buf(struct tcb *const tcp, const kernel_ulong_t addr)
 {
        struct_mtd_oob_buf mbuf;
 
@@ -84,12 +84,12 @@ decode_mtd_oob_buf(struct tcb *const tcp, const kernel_ureg_t addr)
                return;
 
        tprintf("{start=%#x, length=%#x, ptr=", mbuf.start, mbuf.length);
-       printaddr((kernel_ureg_t) mbuf.ptr);
+       printaddr(ptr_to_kulong(mbuf.ptr));
        tprints("}");
 }
 
 static void
-decode_mtd_oob_buf64(struct tcb *const tcp, const kernel_ureg_t addr)
+decode_mtd_oob_buf64(struct tcb *const tcp, const kernel_ulong_t addr)
 {
        struct mtd_oob_buf64 mbuf64;
 
@@ -103,7 +103,7 @@ decode_mtd_oob_buf64(struct tcb *const tcp, const kernel_ureg_t addr)
 }
 
 static void
-decode_otp_info(struct tcb *const tcp, const kernel_ureg_t addr)
+decode_otp_info(struct tcb *const tcp, const kernel_ulong_t addr)
 {
        struct otp_info oinfo;
 
@@ -116,7 +116,7 @@ decode_otp_info(struct tcb *const tcp, const kernel_ureg_t addr)
 }
 
 static void
-decode_otp_select(struct tcb *const tcp, const kernel_ureg_t addr)
+decode_otp_select(struct tcb *const tcp, const kernel_ulong_t addr)
 {
        unsigned int i;
 
@@ -130,7 +130,7 @@ decode_otp_select(struct tcb *const tcp, const kernel_ureg_t addr)
 }
 
 static void
-decode_mtd_write_req(struct tcb *const tcp, const kernel_ureg_t addr)
+decode_mtd_write_req(struct tcb *const tcp, const kernel_ulong_t addr)
 {
        struct mtd_write_req mreq;
 
@@ -149,7 +149,7 @@ decode_mtd_write_req(struct tcb *const tcp, const kernel_ureg_t addr)
 }
 
 static void
-decode_mtd_info_user(struct tcb *const tcp, const kernel_ureg_t addr)
+decode_mtd_info_user(struct tcb *const tcp, const kernel_ulong_t addr)
 {
        struct mtd_info_user minfo;
 
@@ -168,7 +168,7 @@ decode_mtd_info_user(struct tcb *const tcp, const kernel_ureg_t addr)
 }
 
 static void
-decode_nand_oobinfo(struct tcb *const tcp, const kernel_ureg_t addr)
+decode_nand_oobinfo(struct tcb *const tcp, const kernel_ulong_t addr)
 {
        struct nand_oobinfo ninfo;
        unsigned int i, j;
@@ -204,7 +204,7 @@ decode_nand_oobinfo(struct tcb *const tcp, const kernel_ureg_t addr)
 }
 
 static void
-decode_nand_ecclayout_user(struct tcb *const tcp, const kernel_ureg_t addr)
+decode_nand_ecclayout_user(struct tcb *const tcp, const kernel_ulong_t addr)
 {
        struct nand_ecclayout_user nlay;
        unsigned int i;
@@ -230,7 +230,7 @@ decode_nand_ecclayout_user(struct tcb *const tcp, const kernel_ureg_t addr)
 }
 
 static void
-decode_mtd_ecc_stats(struct tcb *const tcp, const kernel_ureg_t addr)
+decode_mtd_ecc_stats(struct tcb *const tcp, const kernel_ulong_t addr)
 {
        struct mtd_ecc_stats es;
 
@@ -243,7 +243,7 @@ decode_mtd_ecc_stats(struct tcb *const tcp, const kernel_ureg_t addr)
 }
 
 MPERS_PRINTER_DECL(int, mtd_ioctl, struct tcb *const tcp,
-                  const unsigned int code, const kernel_ureg_t arg)
+                  const unsigned int code, const kernel_ulong_t arg)
 {
        switch (code) {
        case MEMERASE:
@@ -285,7 +285,7 @@ MPERS_PRINTER_DECL(int, mtd_ioctl, struct tcb *const tcp,
 
        case MTDFILEMODE:
                tprints(", ");
-               printxval_long(mtd_file_mode_options, arg, "MTD_FILE_MODE_???");
+               printxval64(mtd_file_mode_options, arg, "MTD_FILE_MODE_???");
                break;
 
        case MEMGETBADBLOCK:
@@ -359,5 +359,7 @@ MPERS_PRINTER_DECL(int, mtd_ioctl, struct tcb *const tcp,
                return RVAL_DECODED;
        }
 
-       return RVAL_DECODED | 1;
+       return RVAL_IOCTL_DECODED;
 }
+
+#endif /* HAVE_STRUCT_MTD_WRITE_REQ */