diff mbox series

[v2,02/10] ubi: Expose mean erase counter for fastmap in sysfs

Message ID 20241011092134.2909496-2-rickard.andersson@axis.com
State New
Headers show
Series [v2,01/10] ubi: Expose mean erase counter in sysfs | expand

Commit Message

Rickard Andersson Oct. 11, 2024, 9:21 a.m. UTC
Since the fastmap area has its own wear levelling it is valuable to
provide a mean value for that 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 | 11 +++++++++++
 1 file changed, 11 insertions(+)

Comments

Zhihao Cheng Oct. 11, 2024, 12:02 p.m. UTC | #1
在 2024/10/11 17:21, Rickard Andersson 写道:
> Since the fastmap area has its own wear levelling it is valuable to
> provide a mean value for that 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 | 11 +++++++++++
>   1 file changed, 11 insertions(+)
> 

Reviewed-by: Zhihao Cheng <chengzhihao1@huawei.com>
> diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c
> index fa38c434e447..3633c743e7d1 100644
> --- a/drivers/mtd/ubi/build.c
> +++ b/drivers/mtd/ubi/build.c
> @@ -133,6 +133,10 @@ static struct device_attribute dev_max_ec =
>   	__ATTR(max_ec, S_IRUGO, dev_attribute_show, NULL);
>   static struct device_attribute dev_mean_ec =
>   	__ATTR(mean_ec, S_IRUGO, dev_attribute_show, NULL);
> +#ifdef CONFIG_MTD_UBI_FASTMAP
> +static struct device_attribute dev_mean_ec_fastmap =
> +	__ATTR(mean_ec_fastmap, S_IRUGO, dev_attribute_show, NULL);
> +#endif
>   static struct device_attribute dev_reserved_for_bad =
>   	__ATTR(reserved_for_bad, S_IRUGO, dev_attribute_show, NULL);
>   static struct device_attribute dev_bad_peb_count =
> @@ -413,6 +417,10 @@ static ssize_t dev_attribute_show(struct device *dev,
>   		ret = sprintf(buf, "%d\n", ubi->max_ec);
>   	else if (attr == &dev_mean_ec)
>   		ret = sprintf(buf, "%d\n", ubi_calc_mean_ec(ubi, 0, ubi->peb_count));
> +#ifdef CONFIG_MTD_UBI_FASTMAP
> +	else if (attr == &dev_mean_ec_fastmap)
> +		ret = sprintf(buf, "%d\n", ubi_calc_mean_ec(ubi, 0, UBI_FM_MAX_START));
> +#endif
>   	else if (attr == &dev_reserved_for_bad)
>   		ret = sprintf(buf, "%d\n", ubi->beb_rsvd_pebs);
>   	else if (attr == &dev_bad_peb_count)
> @@ -440,6 +448,9 @@ static struct attribute *ubi_dev_attrs[] = {
>   	&dev_volumes_count.attr,
>   	&dev_max_ec.attr,
>   	&dev_mean_ec.attr,
> +#ifdef CONFIG_MTD_UBI_FASTMAP
> +	&dev_mean_ec_fastmap.attr,
> +#endif
>   	&dev_reserved_for_bad.attr,
>   	&dev_bad_peb_count.attr,
>   	&dev_max_vol_count.attr,
>
diff mbox series

Patch

diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c
index fa38c434e447..3633c743e7d1 100644
--- a/drivers/mtd/ubi/build.c
+++ b/drivers/mtd/ubi/build.c
@@ -133,6 +133,10 @@  static struct device_attribute dev_max_ec =
 	__ATTR(max_ec, S_IRUGO, dev_attribute_show, NULL);
 static struct device_attribute dev_mean_ec =
 	__ATTR(mean_ec, S_IRUGO, dev_attribute_show, NULL);
+#ifdef CONFIG_MTD_UBI_FASTMAP
+static struct device_attribute dev_mean_ec_fastmap =
+	__ATTR(mean_ec_fastmap, S_IRUGO, dev_attribute_show, NULL);
+#endif
 static struct device_attribute dev_reserved_for_bad =
 	__ATTR(reserved_for_bad, S_IRUGO, dev_attribute_show, NULL);
 static struct device_attribute dev_bad_peb_count =
@@ -413,6 +417,10 @@  static ssize_t dev_attribute_show(struct device *dev,
 		ret = sprintf(buf, "%d\n", ubi->max_ec);
 	else if (attr == &dev_mean_ec)
 		ret = sprintf(buf, "%d\n", ubi_calc_mean_ec(ubi, 0, ubi->peb_count));
+#ifdef CONFIG_MTD_UBI_FASTMAP
+	else if (attr == &dev_mean_ec_fastmap)
+		ret = sprintf(buf, "%d\n", ubi_calc_mean_ec(ubi, 0, UBI_FM_MAX_START));
+#endif
 	else if (attr == &dev_reserved_for_bad)
 		ret = sprintf(buf, "%d\n", ubi->beb_rsvd_pebs);
 	else if (attr == &dev_bad_peb_count)
@@ -440,6 +448,9 @@  static struct attribute *ubi_dev_attrs[] = {
 	&dev_volumes_count.attr,
 	&dev_max_ec.attr,
 	&dev_mean_ec.attr,
+#ifdef CONFIG_MTD_UBI_FASTMAP
+	&dev_mean_ec_fastmap.attr,
+#endif
 	&dev_reserved_for_bad.attr,
 	&dev_bad_peb_count.attr,
 	&dev_max_vol_count.attr,