fs: Add model field to geometry and mtd_geometry_s

the model is very useful to track the device info

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
Xiang Xiao 2021-08-11 12:21:39 +08:00 committed by Gustavo Henrique Nihei
parent 30aa0ee700
commit 9f027208d4
53 changed files with 116 additions and 0 deletions

View file

@ -920,6 +920,8 @@ static int cxd56_emmc_geometry(struct inode *inode,
DEBUGASSERT(inode && inode->i_private);
priv = (struct cxd56_emmc_state_s *)inode->i_private;
memset(geometry, 0, sizeof(*geometry));
geometry->geo_available = true;
geometry->geo_mediachanged = false;
#if !defined(CONFIG_MMCSD_READONLY)

View file

@ -190,6 +190,8 @@ static int cxd56_ioctl(struct mtd_dev_s *dev, int cmd, unsigned long arg)
finfo("cmd: GEOM\n");
if (geo)
{
memset(geo, 0, sizeof(*geo));
/* Populate the geometry structure with information need to
* know the capacity and how to access the device.
*

View file

@ -192,6 +192,9 @@ static int mmcl_geometry(struct inode *inode, struct geometry *geometry)
if (geometry)
{
dev = (struct mmcl_dev_s *)inode->i_private;
memset(geometry, 0, sizeof(*geometry));
geometry->geo_available = true;
geometry->geo_mediachanged = false;
geometry->geo_writeenabled = true;

View file

@ -314,6 +314,8 @@ static int lc823450_ioctl(struct mtd_dev_s *dev, int cmd,
geo = (struct mtd_geometry_s *)arg;
if (geo)
{
memset(geo, 0, sizeof(*geo));
/* Populate the geometry structure with information needed to
* know the capacity and how to access the device.
*/

View file

@ -858,6 +858,8 @@ static int lpc43_ioctl(struct mtd_dev_s *dev, int cmd, unsigned long arg)
(struct mtd_geometry_s *)((uintptr_t)arg);
if (geo)
{
memset(geo, 0, sizeof(*geo));
/* Populate the geometry structure with information need to
* know the capacity and how to access the device.
*

View file

@ -288,6 +288,8 @@ static int pplus_fls_ioctl(struct mtd_dev_s *dev,
if (geo)
{
memset(geo, 0, sizeof(*geo));
/* Populate the geometry structure with information need to
* know the capacity and how to access the device.
*

View file

@ -456,6 +456,8 @@ static int rp2040_flash_ioctl(struct mtd_dev_s *dev,
if (geo != NULL)
{
memset(geo, 0, sizeof(*geo));
geo->blocksize = FLASH_SECTOR_SIZE;
geo->erasesize = FLASH_BLOCK_SIZE;
geo->neraseblocks = FLASH_BLOCK_COUNT;

View file

@ -236,6 +236,8 @@ static int ameba_flash_ioctl(struct mtd_dev_s *dev,
(struct mtd_geometry_s *)((uintptr_t)arg);
if (geo)
{
memset(geo, 0, sizeof(*geo));
geo->blocksize = AMEBA_PAGE_SIZE;
geo->erasesize = AMEBA_SECTOR_SIZE;
geo->neraseblocks = priv->nsectors;

View file

@ -292,6 +292,9 @@ static int eeed_geometry(struct inode *inode, struct geometry *geometry)
if (geometry)
{
dev = (struct eeed_struct_s *)inode->i_private;
memset(geometry, 0, sizeof(*geometry));
geometry->geo_available = true;
geometry->geo_mediachanged = false;
geometry->geo_writeenabled = true;

View file

@ -377,6 +377,8 @@ static int tiva_ioctl(struct mtd_dev_s *dev, int cmd, unsigned long arg)
struct mtd_geometry_s *geo = (struct mtd_geometry_s *)arg;
if (geo)
{
memset(geo, 0, sizeof(*geo));
/* Populate the geometry structure with information needed to
* know the capacity and how to access the device.
*

View file

@ -782,6 +782,8 @@ static int tlsr82_flash_ioctl(struct mtd_dev_s *dev, int cmd,
if (geo)
{
memset(geo, 0, sizeof(*geo));
/* Populate the geometry structure with information need to
* know the capacity and how to access the device.
*

View file

@ -296,6 +296,8 @@ int bl602_ioctl(struct mtd_dev_s *dev, int cmd,
struct mtd_geometry_s *geo = (struct mtd_geometry_s *)arg;
if (geo)
{
memset(geo, 0, sizeof(*geo));
geo->blocksize = SPIFLASH_BLOCKSIZE;
geo->erasesize = SPIFLASH_BLOCKSIZE;
geo->neraseblocks = (priv->config->flash_size) / \

View file

@ -577,6 +577,8 @@ static int esp32c3_ioctl(struct mtd_dev_s *dev, int cmd,
struct mtd_geometry_s *geo = (struct mtd_geometry_s *)arg;
if (geo)
{
memset(geo, 0, sizeof(*geo));
geo->blocksize = MTD_BLK_SIZE;
geo->erasesize = MTD_ERASE_SIZE;
geo->neraseblocks = MTD_SIZE(priv) / MTD_ERASE_SIZE;

View file

@ -1990,6 +1990,8 @@ static int esp32_ioctl(struct mtd_dev_s *dev, int cmd,
struct mtd_geometry_s *geo = (struct mtd_geometry_s *)arg;
if (geo)
{
memset(geo, 0, sizeof(*geo));
geo->blocksize = MTD_BLKSIZE(priv);
geo->erasesize = MTD_ERASESIZE(priv);
geo->neraseblocks = MTD_SIZE(priv) / MTD_ERASESIZE(priv);
@ -2066,6 +2068,8 @@ static int esp32_ioctl_encrypt(struct mtd_dev_s *dev, int cmd,
struct mtd_geometry_s *geo = (struct mtd_geometry_s *)arg;
if (geo)
{
memset(geo, 0, sizeof(*geo));
geo->blocksize = SPI_FLASH_ENCRYPT_MIN_SIZE;
geo->erasesize = MTD_ERASESIZE(priv);
geo->neraseblocks = MTD_SIZE(priv) / geo->erasesize;

View file

@ -620,6 +620,8 @@ static int esp32s3_ioctl(struct mtd_dev_s *dev, int cmd,
struct mtd_geometry_s *geo = (struct mtd_geometry_s *)arg;
if (geo)
{
memset(geo, 0, sizeof(*geo));
geo->blocksize = MTD_BLK_SIZE;
geo->erasesize = MTD_ERASE_SIZE;
geo->neraseblocks = MTD_SIZE(priv) / MTD_ERASE_SIZE;

View file

@ -556,6 +556,8 @@ static int imxrt_flexspi_nor_ioctl(struct mtd_dev_s *dev,
if (geo)
{
memset(geo, 0, sizeof(*geo));
/* Populate the geometry structure with information need to
* know the capacity and how to access the device.
*

View file

@ -288,6 +288,9 @@ static int loop_geometry(FAR struct inode *inode,
if (geometry)
{
dev = (FAR struct loop_struct_s *)inode->i_private;
memset(geometry, 0, sizeof(*geometry));
geometry->geo_available = true;
geometry->geo_mediachanged = false;
geometry->geo_writeenabled = dev->writeenabled;

View file

@ -307,6 +307,9 @@ static int rd_geometry(FAR struct inode *inode, struct geometry *geometry)
if (geometry)
{
dev = (struct rd_struct_s *)inode->i_private;
memset(geometry, 0, sizeof(*geometry));
geometry->geo_available = true;
geometry->geo_mediachanged = false;
geometry->geo_writeenabled = RDFLAG_IS_WRENABLED(dev->rd_flags);

View file

@ -2247,6 +2247,8 @@ static int mmcsd_geometry(FAR struct inode *inode, struct geometry *geometry)
if (geometry)
{
memset(geometry, 0, sizeof(*geometry));
/* Is there a (supported) card inserted in the slot? */
priv = (FAR struct mmcsd_state_s *)inode->i_private;

View file

@ -1611,6 +1611,8 @@ static int mmcsd_geometry(FAR struct inode *inode, struct geometry *geometry)
/* Then return the card geometry */
memset(geometry, 0, sizeof(*geometry));
geometry->geo_available =
((slot->state & (MMCSD_SLOTSTATUS_NOTREADY |
MMCSD_SLOTSTATUS_NODISK)) == 0);

View file

@ -579,6 +579,8 @@ static int at24c_ioctl(FAR struct mtd_dev_s *dev, int cmd, unsigned long arg)
((uintptr_t)arg);
if (geo)
{
memset(geo, 0, sizeof(*geo));
/* Populate the geometry structure with information need to
* know the capacity and how to access the device.
*

View file

@ -616,6 +616,8 @@ static int at25_ioctl(FAR struct mtd_dev_s *dev, int cmd, unsigned long arg)
if (geo != NULL)
{
memset(geo, 0, sizeof(*geo));
/* Populate the geometry structure with information need to
* know the capacity and how to access the device.
*

View file

@ -783,6 +783,8 @@ static int at45db_ioctl(FAR struct mtd_dev_s *mtd,
(FAR struct mtd_geometry_s *)((uintptr_t)arg);
if (geo)
{
memset(geo, 0, sizeof(*geo));
/* Populate the geometry structure with information need to
* know the capacity and how to access the device.
*

View file

@ -443,6 +443,8 @@ static int filemtd_ioctl(FAR struct mtd_dev_s *dev, int cmd,
if (geo)
{
memset(geo, 0, sizeof(*geo));
/* Populate the geometry structure with information need to
* know the capacity and how to access the device.
*/

View file

@ -478,6 +478,8 @@ static int ftl_geometry(FAR struct inode *inode,
geometry->geo_nsectors = dev->geo.neraseblocks * dev->blkper;
geometry->geo_sectorsize = dev->geo.blocksize;
strcpy(geometry->geo_model, dev->geo.model);
finfo("available: true mediachanged: false writeenabled: %s\n",
geometry->geo_writeenabled ? "true" : "false");
finfo("nsectors: %" PRIuOFF " sectorsize: %u\n",

View file

@ -947,6 +947,8 @@ static int gd25_ioctl(FAR struct mtd_dev_s *dev, int cmd, unsigned long arg)
(FAR struct mtd_geometry_s *)((uintptr_t)arg);
if (geo)
{
memset(geo, 0, sizeof(*geo));
geo->blocksize = GD25_PAGE_SIZE;
geo->erasesize = GD25_SECTOR_SIZE;
geo->neraseblocks = priv->nsectors;

View file

@ -753,6 +753,8 @@ static int gd5f_ioctl(FAR struct mtd_dev_s *dev, int cmd, unsigned long arg)
(FAR struct mtd_geometry_s *)((uintptr_t)arg);
if (geo)
{
memset(geo, 0, sizeof(*geo));
geo->blocksize = (1 << priv->pageshift);
geo->erasesize = (1 << priv->sectorshift);
geo->neraseblocks = priv->nsectors;

View file

@ -1010,6 +1010,8 @@ static int is25xp_ioctl(FAR struct mtd_dev_s *dev,
(FAR struct mtd_geometry_s *)((uintptr_t)arg);
if (geo)
{
memset(geo, 0, sizeof(*geo));
/* Populate the geometry structure with information need to
* know the capacity and how to access the device.
*

View file

@ -1056,6 +1056,8 @@ static int m25p_ioctl(FAR struct mtd_dev_s *dev, int cmd, unsigned long arg)
((uintptr_t)arg);
if (geo)
{
memset(geo, 0, sizeof(*geo));
/* Populate the geometry structure with information need to
* know the capacity and how to access the device.
*

View file

@ -758,6 +758,8 @@ static int nand_ioctl(struct mtd_dev_s *dev, int cmd, unsigned long arg)
FAR struct mtd_geometry_s *geo = (struct mtd_geometry_s *)arg;
if (geo)
{
memset(geo, 0, sizeof(*geo));
/* Populate the geometry structure with information needed to
* know the capacity and how to access the device. Returns:
*

View file

@ -403,6 +403,8 @@ static int part_ioctl(FAR struct mtd_dev_s *dev, int cmd, unsigned long arg)
FAR struct mtd_geometry_s *geo = (FAR struct mtd_geometry_s *)arg;
if (geo)
{
memset(geo, 0, sizeof(*geo));
/* Populate the geometry structure with information needed to
* know the capacity and how to access the device.
*/

View file

@ -310,6 +310,8 @@ static int progmem_ioctl(FAR struct mtd_dev_s *dev, int cmd,
FAR struct mtd_geometry_s *geo = (FAR struct mtd_geometry_s *)arg;
if (geo)
{
memset(geo, 0, sizeof(*geo));
/* Populate the geometry structure with information needed to
* know the capacity and how to access the device.
*

View file

@ -275,6 +275,8 @@ static int mtd_ioctl(FAR struct mtd_dev_s *dev, int cmd, unsigned long arg)
((uintptr_t)arg);
if (geo)
{
memset(geo, 0, sizeof(*geo));
/* Populate the geometry structure with information need to
* know the capacity and how to access the device.
*

View file

@ -1053,6 +1053,8 @@ static int mx25l_ioctl(FAR struct mtd_dev_s *dev, int cmd, unsigned long arg)
(FAR struct mtd_geometry_s *)((uintptr_t)arg);
if (geo)
{
memset(geo, 0, sizeof(*geo));
/* Populate the geometry structure with information need to
* know the capacity and how to access the device.
*

View file

@ -735,6 +735,8 @@ int mx25rxx_ioctl(FAR struct mtd_dev_s *dev, int cmd, unsigned long arg)
if (geo)
{
memset(geo, 0, sizeof(*geo));
/* Populate the geometry structure with information need to
* know the capacity and how to access the device.
*

View file

@ -789,6 +789,8 @@ static int mx35_ioctl(FAR struct mtd_dev_s *dev, int cmd, unsigned long arg)
(FAR struct mtd_geometry_s *)((uintptr_t)arg);
if (geo)
{
memset(geo, 0, sizeof(*geo));
/* Populate the geometry structure with information need to
* know the capacity and how to access the device.
*

View file

@ -1371,6 +1371,8 @@ static int n25qxxx_ioctl(FAR struct mtd_dev_s *dev,
if (geo)
{
memset(geo, 0, sizeof(*geo));
/* Populate the geometry structure with information need to
* know the capacity and how to access the device.
*

View file

@ -276,6 +276,8 @@ static int nullmtd_ioctl(FAR struct mtd_dev_s *dev, int cmd,
if (geo)
{
memset(geo, 0, sizeof(*geo));
/* Populate the geometry structure with information need to
* know the capacity and how to access the device.
*/

View file

@ -386,6 +386,8 @@ static int ram_ioctl(FAR struct mtd_dev_s *dev, int cmd, unsigned long arg)
(FAR struct mtd_geometry_s *)((uintptr_t)arg);
if (geo)
{
memset(geo, 0, sizeof(*geo));
/* Populate the geometry structure with information need to
* know the capacity and how to access the device.
*/

View file

@ -838,6 +838,8 @@ static int ramtron_ioctl(FAR struct mtd_dev_s *dev,
(FAR struct mtd_geometry_s *)((uintptr_t)arg);
if (geo)
{
memset(geo, 0, sizeof(*geo));
/* Populate the geometry structure with information need to
* know the capacity and how to access the device.
*

View file

@ -1419,6 +1419,8 @@ static int s25fl1_ioctl(FAR struct mtd_dev_s *dev,
if (geo)
{
memset(geo, 0, sizeof(*geo));
/* Populate the geometry structure with information need to
* know the capacity and how to access the device.
*

View file

@ -521,6 +521,8 @@ static int s512_ioctl(FAR struct mtd_dev_s *dev, int cmd, unsigned long arg)
((uintptr_t)arg);
if (geo)
{
memset(geo, 0, sizeof(*geo));
/* Populate the geometry structure with information need to
* know the capacity and how to access the device.
*

View file

@ -241,6 +241,8 @@ static int skel_ioctl(FAR struct mtd_dev_s *dev, int cmd, unsigned long arg)
FAR struct mtd_geometry_s *geo = (FAR struct mtd_geometry_s *)arg;
if (geo)
{
memset(geo, 0, sizeof(*geo));
/* Populate the geometry structure with information needed to
* know the capacity and how to access the device.
*

View file

@ -1066,6 +1066,8 @@ static int smart_geometry(FAR struct inode *inode, struct geometry *geometry)
dev->sectorsize;
geometry->geo_sectorsize = dev->sectorsize;
strcpy(geometry->geo_model, dev->geo.model);
finfo("available: true mediachanged: false writeenabled: %s\n",
geometry->geo_writeenabled ? "true" : "false");
finfo("nsectors: %" PRIuOFF " sectorsize: %" PRIi16 "\n",

View file

@ -1167,6 +1167,8 @@ static int sst25_ioctl(FAR struct mtd_dev_s *dev, int cmd, unsigned long arg)
((uintptr_t)arg);
if (geo)
{
memset(geo, 0, sizeof(*geo));
/* Populate the geometry structure with information need to
* know the capacity and how to access the device.
*

View file

@ -871,6 +871,8 @@ static int sst25xx_ioctl(FAR struct mtd_dev_s *dev, int cmd,
((uintptr_t)arg);
if (geo)
{
memset(geo, 0, sizeof(*geo));
/* Populate the geometry structure with information need to
* know the capacity and how to access the device.
*

View file

@ -877,6 +877,8 @@ static int sst26_ioctl(FAR struct mtd_dev_s *dev, int cmd, unsigned long arg)
(FAR struct mtd_geometry_s *)((uintptr_t)arg);
if (geo != NULL)
{
memset(geo, 0, sizeof(*geo));
/* Populate the geometry structure with information need to
* know the capacity and how to access the device.
*

View file

@ -710,6 +710,8 @@ static int sst39vf_ioctl(FAR struct mtd_dev_s *dev,
FAR struct mtd_geometry_s *geo = (FAR struct mtd_geometry_s *)arg;
if (geo)
{
memset(geo, 0, sizeof(*geo));
/* Populate the geometry structure with information need to
* know the capacity and how to access the device.
*/

View file

@ -1294,6 +1294,8 @@ static int w25_ioctl(FAR struct mtd_dev_s *dev, int cmd, unsigned long arg)
(FAR struct mtd_geometry_s *)((uintptr_t)arg);
if (geo)
{
memset(geo, 0, sizeof(*geo));
/* Populate the geometry structure with information need to
* know the capacity and how to access the device.
*

View file

@ -1409,6 +1409,8 @@ static int w25qxxxjv_ioctl(FAR struct mtd_dev_s *dev,
if (geo)
{
memset(geo, 0, sizeof(*geo));
/* Populate the geometry structure with information need to
* know the capacity and how to access the device.
*

View file

@ -2220,6 +2220,8 @@ static int usbhost_geometry(FAR struct inode *inode,
ret = nxmutex_lock(&priv->lock);
if (ret >= 0)
{
memset(geometry, 0, sizeof(*geometry));
geometry->geo_available = true;
geometry->geo_mediachanged = false;
geometry->geo_writeenabled = true;

View file

@ -237,6 +237,10 @@ struct geometry
bool geo_writeenabled; /* true: It is okay to write to this device */
blkcnt_t geo_nsectors; /* Number of sectors on the device */
blksize_t geo_sectorsize; /* Size of one sector */
/* NULL-terminated string representing the device model */
char geo_model[NAME_MAX + 1];
};
struct partition_info_s

View file

@ -110,6 +110,10 @@ struct mtd_geometry_s
uint32_t erasesize; /* Size of one erase blocks -- must be a multiple
* of blocksize. */
uint32_t neraseblocks; /* Number of erase blocks */
/* NULL-terminated string representing the device model */
char model[NAME_MAX + 1];
};
/* This structure describes a range of sectors to be protected or