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 v2 05/10] ubi: Expose max erase counter for data in sysfs
Date: Fri, 11 Oct 2024 11:21:29 +0200	[thread overview]
Message-ID: <20241011092134.2909496-5-rickard.andersson@axis.com> (raw)
In-Reply-To: <20241011092134.2909496-1-rickard.andersson@axis.com>

Expose max erase counter for data area in sysfs. Data area includes
all blocks except for the fastmap area.

This value can be used in order to estimate life expectancy of the
flash.

Signed-off-by: Rickard Andersson <rickard.andersson@axis.com>
---
 drivers/mtd/ubi/build.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c
index b253dcf849c7..f3649afbc777 100644
--- a/drivers/mtd/ubi/build.c
+++ b/drivers/mtd/ubi/build.c
@@ -138,6 +138,8 @@ static struct device_attribute dev_max_ec_fastmap =
 	__ATTR(max_ec_fastmap, S_IRUGO, dev_attribute_show, NULL);
 static struct device_attribute dev_mean_ec_fastmap =
 	__ATTR(mean_ec_fastmap, S_IRUGO, dev_attribute_show, NULL);
+static struct device_attribute dev_max_ec_data =
+	__ATTR(max_ec_data, S_IRUGO, dev_attribute_show, NULL);
 static struct device_attribute dev_mean_ec_data =
 	__ATTR(mean_ec_data, S_IRUGO, dev_attribute_show, NULL);
 #endif
@@ -465,6 +467,8 @@ static ssize_t dev_attribute_show(struct device *dev,
 		ret = sprintf(buf, "%d\n", ubi_calc_max_ec(ubi, 0, UBI_FM_MAX_START));
 	else if (attr == &dev_mean_ec_fastmap)
 		ret = sprintf(buf, "%d\n", ubi_calc_mean_ec(ubi, 0, UBI_FM_MAX_START));
+	else if (attr == &dev_max_ec_data)
+		ret = sprintf(buf, "%d\n", ubi_calc_max_ec(ubi, UBI_FM_MAX_START, ubi->peb_count));
 	else if (attr == &dev_mean_ec_data)
 		ret = sprintf(buf, "%d\n", ubi_calc_mean_ec(ubi, UBI_FM_MAX_START, ubi->peb_count));
 #endif
@@ -498,6 +502,7 @@ static struct attribute *ubi_dev_attrs[] = {
 #ifdef CONFIG_MTD_UBI_FASTMAP
 	&dev_max_ec_fastmap.attr,
 	&dev_mean_ec_fastmap.attr,
+	&dev_max_ec_data.attr,
 	&dev_mean_ec_data.attr,
 #endif
 	&dev_reserved_for_bad.attr,
-- 
2.30.2


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

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

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-11  9:21 [PATCH v2 01/10] ubi: Expose mean erase counter in sysfs Rickard Andersson
2024-10-11  9:21 ` [PATCH v2 02/10] ubi: Expose mean erase counter for fastmap " Rickard Andersson
2024-10-11 12:02   ` Zhihao Cheng
2024-10-11  9:21 ` [PATCH v2 03/10] ubi: Expose max " Rickard Andersson
2024-10-11 12:03   ` Zhihao Cheng
2024-10-11  9:21 ` [PATCH v2 04/10] ubi: Expose mean erase counter for data " Rickard Andersson
2024-10-11 12:04   ` Zhihao Cheng
2024-10-11  9:21 ` Rickard Andersson [this message]
2024-10-11 12:04   ` [PATCH v2 05/10] ubi: Expose max " Zhihao Cheng
2024-10-11  9:21 ` [PATCH v2 06/10] ubi: Add mean erase counter sysfs attribute Rickard Andersson
2024-10-11 12:06   ` Zhihao Cheng
2024-10-11  9:21 ` [PATCH v2 07/10] ubi: Add mean erase counter sysfs attribute for fastmap area Rickard Andersson
2024-10-11 12:06   ` Zhihao Cheng
2024-10-11  9:21 ` [PATCH v2 08/10] ubi: Add max " Rickard Andersson
2024-10-11 12:06   ` Zhihao Cheng
2024-10-11  9:21 ` [PATCH v2 09/10] ubi: Add mean erase counter sysfs attribute for data area Rickard Andersson
2024-10-11 12:08   ` Zhihao Cheng
2024-10-11  9:21 ` [PATCH v2 10/10] ubi: Add max " Rickard Andersson
2024-10-11 12:08   ` Zhihao Cheng
2024-10-11 12:01 ` [PATCH v2 01/10] ubi: Expose mean erase counter in sysfs Zhihao Cheng

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=20241011092134.2909496-5-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