<feed xmlns='http://www.w3.org/2005/Atom'>
<title>mtd-utils.git/lib/libmtd.c, branch v2.3.1</title>
<subtitle>A mirror of http://git.infradead.org/mtd-utils.git</subtitle>
<id>https://git.infraroot.at/mtd-utils.git/atom?h=v2.3.1</id>
<link rel='self' href='https://git.infraroot.at/mtd-utils.git/atom?h=v2.3.1'/>
<link rel='alternate' type='text/html' href='https://git.infraroot.at/mtd-utils.git/'/>
<updated>2023-05-30T09:12:12+00:00</updated>
<entry>
<title>libmtd: Add function to get MTD info by device name</title>
<updated>2023-05-30T09:12:12+00:00</updated>
<author>
<name>Brandon Maier</name>
<email>brandon.maier@collins.com</email>
</author>
<published>2022-12-12T18:01:57+00:00</published>
<link rel='alternate' type='text/html' href='https://git.infraroot.at/mtd-utils.git/commit/?id=a527b22f0a30d66d4674624d16f4bb0ffe2e94d0'/>
<id>urn:sha1:a527b22f0a30d66d4674624d16f4bb0ffe2e94d0</id>
<content type='text'>
This is a convenience function for end users. In some situations it's
easier to reference MTD device's by their name then by MTD number, as
the name may be more reliable if device partitioning is dynamic or for
porting between systems.

Signed-off-by: Brandon Maier &lt;brandon.maier@collins.com&gt;
Signed-off-by: David Oberhollenzer &lt;david.oberhollenzer@sigma-star.at&gt;
</content>
</entry>
<entry>
<title>libmtd: do not ignore non-zero eraseblock size when MTD_NO_ERASE is set</title>
<updated>2022-09-27T06:32:46+00:00</updated>
<author>
<name>Enrico Jorns</name>
<email>ejo@pengutronix.de</email>
</author>
<published>2022-08-19T12:32:13+00:00</published>
<link rel='alternate' type='text/html' href='https://git.infraroot.at/mtd-utils.git/commit/?id=b83c64f7a12538417649accc1269c22d5ff074bb'/>
<id>urn:sha1:b83c64f7a12538417649accc1269c22d5ff074bb</id>
<content type='text'>
In 54d68799, mtd-&gt;eb_cnt was enforced to be '1' if MTD_NO_ERASE is set.
This was done with the aim of preventing divisions by zero.

However, even if MTD_NO_ERASE is set, mtd-&gt;eb_size (eraseblock size) can
still be set to a non-zero value which would not cause a division by
zero.

Instead, enforcing an eraseblock count of '1' here even leads to
inconsistent eraseblock counting in mtd-utils and lets for example a
'flash_erase' on an mtdnand device fail:

| # flash_erase /dev/mtd0 0 0
| Erasing 32768 Kibyte @ 0 --  0 % complete libmtd: error!: bad eraseblock number 255, mtd0 has 1 eraseblocks
| flash_erase: error!: /dev/mtd0: MTD Erase entire chip failureTrying one by one each sector.
|              error 22 (Invalid argument)
| Erasing 128 Kibyte @ 0 --  0 % complete libmtd: error!: bad eraseblock number 1, mtd0 has 1 eraseblocks
| flash_erase: error!: /dev/mtd0: MTD get bad block failed
|              error 22 (Invalid argument)

Also mtdinfo would look inconsistent (eraseblock size vs amount):

| # mtdinfo /dev/mtd0
| mtd0
| Name:                           mtdram test device
| Type:                           ram
| Eraseblock size:                131072 bytes, 128.0 KiB
| Amount of eraseblocks:          1 (33554432 bytes, 32.0 MiB)
| Minimum input/output unit size: 1 byte
| Sub-page size:                  1 byte
| Character device major/minor:   90:0
| Bad blocks are allowed:         false
| Device is writable:             true

Fix this by enforcing mtd-&gt;eb_cnt to be '1' only when mtd-&gt;eb_size is
actually zero and would lead to a division by zero otherwise.

Fixes: 54d68799 ("libmtd: avoid divide by zero")

Signed-off-by: Enrico Jorns &lt;ejo@pengutronix.de&gt;
Signed-off-by: David Oberhollenzer &lt;david.oberhollenzer@sigma-star.at&gt;
</content>
</entry>
<entry>
<title>mtd-utils: flash_erase: Add flash erase chip</title>
<updated>2021-05-05T06:29:50+00:00</updated>
<author>
<name>Larisa Ileana Grigore</name>
<email>larisa.grigore@nxp.com</email>
</author>
<published>2021-04-23T15:07:04+00:00</published>
<link rel='alternate' type='text/html' href='https://git.infraroot.at/mtd-utils.git/commit/?id=2ca0bbf296d6f7ce51b8255347c7fd08afa33651'/>
<id>urn:sha1:2ca0bbf296d6f7ce51b8255347c7fd08afa33651</id>
<content type='text'>
Some flash types support full erase chip command which can reduce the
flash erase time. Try first to erase the entire flash and fall back
to the old method if the operation fails.

Signed-off-by: Larisa Ileana Grigore &lt;larisa.grigore@nxp.com&gt;
Signed-off-by: David Oberhollenzer &lt;david.oberhollenzer@sigma-star.at&gt;
</content>
</entry>
<entry>
<title>libmtd: avoid divide by zero</title>
<updated>2020-11-29T22:39:41+00:00</updated>
<author>
<name>Chris Packham</name>
<email>chris.packham@alliedtelesis.co.nz</email>
</author>
<published>2020-11-27T00:07:08+00:00</published>
<link rel='alternate' type='text/html' href='https://git.infraroot.at/mtd-utils.git/commit/?id=54d68799b73e755923def1306b4da607ad45bd60'/>
<id>urn:sha1:54d68799b73e755923def1306b4da607ad45bd60</id>
<content type='text'>
The concept of erase blocks doesn't apply to mtd-ram devices. Such
devices set MTD_NO_ERASE to indicate this and some report 0 for the
erase block size. Avoid a divide by zero when calculating the erase
block count for such devices.

Signed-off-by: Chris Packham &lt;chris.packham@alliedtelesis.co.nz&gt;
Acked-by: Richard Weinberger &lt;richard@nod.at&gt;
Signed-off-by: David Oberhollenzer &lt;david.oberhollenzer@sigma-star.at&gt;
</content>
</entry>
<entry>
<title>mtd-utils: Fix some simple cases of uninitialized value reads</title>
<updated>2020-02-09T21:13:18+00:00</updated>
<author>
<name>David Oberhollenzer</name>
<email>david.oberhollenzer@sigma-star.at</email>
</author>
<published>2020-01-24T22:40:45+00:00</published>
<link rel='alternate' type='text/html' href='https://git.infraroot.at/mtd-utils.git/commit/?id=24b0e6277b36c46075e2e23896aa9ec43729efab'/>
<id>urn:sha1:24b0e6277b36c46075e2e23896aa9ec43729efab</id>
<content type='text'>
This patch modifies the internal helpers to read and parse integers
from sysfs files by initializing them first and removes turns an
obscure "a = open(...) if (a &gt;= 0) {...} if (a == -1) {...}" inside
recv_image into a more straight forward if/else branch.

Signed-off-by: David Oberhollenzer &lt;david.oberhollenzer@sigma-star.at&gt;
</content>
</entry>
<entry>
<title>libmtd: don't leak temporary buffers</title>
<updated>2019-11-10T14:30:04+00:00</updated>
<author>
<name>David Oberhollenzer</name>
<email>david.oberhollenzer@sigma-star.at</email>
</author>
<published>2019-11-10T13:48:53+00:00</published>
<link rel='alternate' type='text/html' href='https://git.infraroot.at/mtd-utils.git/commit/?id=fcf6efdf03a827544739e6d1cc66dfb42f27a8b1'/>
<id>urn:sha1:fcf6efdf03a827544739e6d1cc66dfb42f27a8b1</id>
<content type='text'>
Signed-off-by: David Oberhollenzer &lt;david.oberhollenzer@sigma-star.at&gt;
</content>
</entry>
<entry>
<title>mtd-utils: Instead of doing preprocessor magic, just output off_t as long long</title>
<updated>2018-10-02T12:00:28+00:00</updated>
<author>
<name>Thorsten Glaser</name>
<email>tg@mirbsd.org</email>
</author>
<published>2018-09-20T23:22:11+00:00</published>
<link rel='alternate' type='text/html' href='https://git.infraroot.at/mtd-utils.git/commit/?id=64667fe63ba9dd78adb9c4abf04bc3e4e25a0fd7'/>
<id>urn:sha1:64667fe63ba9dd78adb9c4abf04bc3e4e25a0fd7</id>
<content type='text'>
Fix warnings abot PRIdoff_t in libmtd.c, in mtd_read (and mtd_write):

In file included from ../git/lib/libmtd.c:40:0:
../git/lib/libmtd.c: In function 'mtd_read':
../git/include/common.h:110:18: warning: format '%ld' expects argument of
 type 'long int', but argument 5 has type 'off_t {aka long long int}'
 [-Wformat=]

../git/include/common.h:120:2: note: in expansion of macro 'errmsg'
  errmsg(fmt, ##__VA_ARGS__);                                         \
  ^~~~~~
../git/lib/libmtd.c:1082:10: note: in expansion of macro 'sys_errmsg'
   return sys_errmsg("cannot seek mtd%d to offset %"PRIdoff_t,
          ^~~~~~~~~~

/usr/lib/klibc/include/inttypes.h:28:17: note: format string is defined here
 #define PRId32 "d"

Signed-off-by: Thorsten Glaser &lt;tg@mirbsd.org&gt;
Signed-off-by: David Oberhollenzer &lt;david.oberhollenzer@sigma-star.at&gt;
</content>
</entry>
<entry>
<title>libmtd: Add support to access OOB available size</title>
<updated>2018-04-10T13:38:56+00:00</updated>
<author>
<name>Xiaolei Li</name>
<email>xiaolei.li@mediatek.com</email>
</author>
<published>2018-04-10T07:36:55+00:00</published>
<link rel='alternate' type='text/html' href='https://git.infraroot.at/mtd-utils.git/commit/?id=a10353584f93334b5687c598a15260c0fc5b8d3e'/>
<id>urn:sha1:a10353584f93334b5687c598a15260c0fc5b8d3e</id>
<content type='text'>
This patch exposes OOB available size to user. Then user can use
OOB free area according to OOB available size.

Steps to get OOB available size:
First, access /sys/class/mtd/mtdX/oobavail. If not exist, then
try to get ecc layout by ioctl "ECCGETLAYOUT". If none of them
work, set OOB available size to 0.

Signed-off-by: Xiaolei Li &lt;xiaolei.li@mediatek.com&gt;
Signed-off-by: David Oberhollenzer &lt;david.oberhollenzer@sigma-star.at&gt;
</content>
</entry>
<entry>
<title>libmtd: fix a comment typo in dev_node2num</title>
<updated>2017-11-14T23:14:02+00:00</updated>
<author>
<name>Rock Lee</name>
<email>rockdotlee@gmail.com</email>
</author>
<published>2017-11-13T07:05:34+00:00</published>
<link rel='alternate' type='text/html' href='https://git.infraroot.at/mtd-utils.git/commit/?id=7086393891df77b31d346b051fa1ecfa0aa4d66a'/>
<id>urn:sha1:7086393891df77b31d346b051fa1ecfa0aa4d66a</id>
<content type='text'>
Signed-off-by: Rock Lee &lt;rockdotlee@gmail.com&gt;
Signed-off-by: David Oberhollenzer &lt;david.oberhollenzer@sigma-star.at&gt;
</content>
</entry>
<entry>
<title>Eliminate warnings about missing prototypes</title>
<updated>2017-06-28T08:27:31+00:00</updated>
<author>
<name>David Oberhollenzer</name>
<email>david.oberhollenzer@sigma-star.at</email>
</author>
<published>2017-06-22T11:37:40+00:00</published>
<link rel='alternate' type='text/html' href='https://git.infraroot.at/mtd-utils.git/commit/?id=ca517e8b320c7a31c3a147fb1212ddb33cabd919'/>
<id>urn:sha1:ca517e8b320c7a31c3a147fb1212ddb33cabd919</id>
<content type='text'>
This patch eliminates warnings generated by the -Wmissing-prototypes
option. With this flag set, we are now forced to have prototypes for
all global, exported functions, that have to be made visible to the
definitions and we are forced to mark all local functions as static.

Signed-off-by: David Oberhollenzer &lt;david.oberhollenzer@sigma-star.at&gt;
</content>
</entry>
</feed>
