public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
From: Rickard Andersson <rickard.andersson@axis.com>
To: <richard@nod.at>, <chengzhihao1@huawei.com>,
	<linux-mtd@lists.infradead.org>, <rickard314.andersson@gmail.com>
Cc: <rickard.andersson@axis.com>, <kernel@axis.com>
Subject: [PATCH 1/2] ubi: Expose interface for reading erase counters
Date: Thu, 21 Nov 2024 11:21:56 +0100	[thread overview]
Message-ID: <20241121102157.3498056-1-rickard.andersson@axis.com> (raw)

Using the ioctl command 'UBI_IOCECNFO' user space can obtain mean
and max erase counters of a device. If fastmap is enabled also erase
counter information of that area and its complementary area is
provided.

Signed-off-by: Rickard Andersson <rickard.andersson@axis.com>
---
 include/uapi/mtd/ubi-user.h | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/include/uapi/mtd/ubi-user.h b/include/uapi/mtd/ubi-user.h
index e1571603175e..00cc8a083675 100644
--- a/include/uapi/mtd/ubi-user.h
+++ b/include/uapi/mtd/ubi-user.h
@@ -175,6 +175,8 @@
 #define UBI_IOCRPEB _IOW(UBI_IOC_MAGIC, 4, __s32)
 /* Force scrubbing on the specified PEB */
 #define UBI_IOCSPEB _IOW(UBI_IOC_MAGIC, 5, __s32)
+/* Read detailed device information */
+#define UBI_IOCECNFO _IOR(UBI_IOC_MAGIC, 6, struct ubi_ecinfo_res)
 
 /* ioctl commands of the UBI control character device */
 
@@ -470,4 +472,27 @@ struct ubi_blkcreate_req {
 	__s8  padding[128];
 }  __packed;
 
+/**
+ * struct ubi_ecinfo_res - a data structure used in UBI device erase count
+ * information responses.
+ *
+ * @max_ec: Max physical erase block erase counter value of whole UBI device
+ * @mean_ec: Mean physical erase block erase counter value of whole UBI device
+ * @max_ec_fastmap: Max physical erase block erase counter value of fastmap area
+ * @mean_ec_fastmap: Mean physical erase block erase counter value of fastmap area
+ * @max_ec_data: Max physical erase block erase counter value of data area
+ * @mean_ec_data: Mean physical erase block erase counter value of data area
+ *
+ * @padding: reserved for future, not used, has to be zeroed
+ */
+struct ubi_ecinfo_res {
+	__s32 max_ec;
+	__s32 mean_ec;
+	__s32 max_ec_fastmap;
+	__s32 mean_ec_fastmap;
+	__s32 max_ec_data;
+	__s32 mean_ec_data;
+	__s8  padding[64];
+}  __packed;
+
 #endif /* __UBI_USER_H__ */
-- 
2.30.2


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

             reply	other threads:[~2024-11-21 10:22 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-21 10:21 Rickard Andersson [this message]
2024-11-21 10:21 ` [PATCH 2/2] ubi: Implement 'UBI_IOCECNFO' for reading erase counters Rickard Andersson
2024-11-21 10:37 ` [PATCH 1/2] ubi: Expose interface " Richard Weinberger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20241121102157.3498056-1-rickard.andersson@axis.com \
    --to=rickard.andersson@axis.com \
    --cc=chengzhihao1@huawei.com \
    --cc=kernel@axis.com \
    --cc=linux-mtd@lists.infradead.org \
    --cc=richard@nod.at \
    --cc=rickard314.andersson@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox