Add method for triggering Sanitize command
Subsystems (2)
PATCH 1/1 Add method for triggering Sanitize command
This patch adds a method to trigger Sanitize command to MMC. The Sanitize command is used for deleting the unmapped memory region of the MMC device.
mmc.c +5 -0
@@ -90,6 +90,11 @@ static struct Command commands[] = { "Permanently disable the eMMC H/W Reset feature on <device>.\nNOTE! This is a one-time programmable (unreversible) change.", NULL }, + { do_sanitize,-1 , +"sanitize" ,"<device>\n" +"Send Sanitize command to the <device>.\nThis will delete the unmapped memory region of the device" , +NULL + }, { 0, 0, 0, 0 } };
mmc.h +1 -0
@@ -38,6 +38,7 @@#define EXT_CSD_PART_CONFIG 179#define EXT_CSD_BOOT_WP 173#define EXT_CSD_WR_REL_PARAM 166 +#define EXT_CSD_SANITIZE_START 165#define EXT_CSD_BKOPS_EN 163/* R/W */ #define EXT_CSD_RST_N_FUNCTION 162/* R/W */ #define EXT_CSD_NATIVE_SECTOR_SIZE 63/* R */
mmc_cmds.c +28 -0
@@ -767,3 +767,31 @@ int do_read_extcsd(int nargs, char **argv) out_free:return ret; } + +int do_sanitize (int nargs,char **argv) +{ +int fd, ret; +char *device; + +CHECK (nargs !=2 ,"Usage: mmc sanitize </path/to/mmcblkX>\n" , +exit (1 )); + + device = argv[1 ]; + + fd =open (device,O_RDWR ); +if (fd <0 ) { +perror ("open" ); +exit (1 ); + } + + ret =write_extcsd_value (fd,EXT_CSD_SANITIZE_START ,1 ); +if (ret) { +fprintf (stderr,"Could not write 0x%02x to EXT_CSD[%d] in %s\n" , +1 ,EXT_CSD_SANITIZE_START , device); +exit (1 ); + } + +return ret; + +} +
mmc_cmds.h +1 -0
@@ -24,3 +24,4 @@ int do_write_boot_en(int nargs, char **argv);int do_write_bkops_en (int nargs,char **argv);int do_hwreset_en (int nargs,char **argv);int do_hwreset_dis (int nargs,char **argv); +int do_sanitize (int nargs,char **argv);
Signature · 4 lines
1.7.6 -- QUALCOMM ISRAEL, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
Quoted 56 lines · Yaniv Gardi
This patch adds a method to trigger Sanitize command to MMC. The Sanitize command is used for deleting the unmapped memory region of the MMC device.
Signed-off-by Yaniv Gardi <[email protected]>mmc.c +5
-0@@ -90,6 +90,11 @@ static struct Command commands[] = { "Permanently disable the eMMC H/W Reset feature on <device>.\nNOTE! This is a one-time programmable (unreversible) change.", NULL }, + { do_sanitize,-1 , +"sanitize" ,"<device>\n" +"Send Sanitize command to the <device>.\nThis will delete the unmapped memory region of the device" , +NULL + }, { 0, 0, 0, 0 } };mmc.h +1
-0@@ -38,6 +38,7 @@#define EXT_CSD_PART_CONFIG 179#define EXT_CSD_BOOT_WP 173#define EXT_CSD_WR_REL_PARAM 166 +#define EXT_CSD_SANITIZE_START 165#define EXT_CSD_BKOPS_EN 163/* R/W */ #define EXT_CSD_RST_N_FUNCTION 162/* R/W */ #define EXT_CSD_NATIVE_SECTOR_SIZE 63/* R */ mmc_cmds.c +14
-0@@ -767,3 +767,31 @@ int do_read_extcsd(int nargs, char **argv) out_free:return ret; } + +int do_sanitize (int nargs,char **argv) +{ +int fd, ret; +char *device; + +CHECK (nargs !=2 ,"Usage: mmc sanitize </path/to/mmcblkX>\n" , +exit (1 )); + + device = argv[1 ]; + + fd =open (device,O_RDWR ); +if (fd <0 ) { +perror ("open" );
mmc_cmds.c int do_read_extcsd(int nargs, char **argv) · line 793
Quoted 10 lines
mmc_cmds.c +10
-0+exit (1 ); + } + + ret =write_extcsd_value (fd,EXT_CSD_SANITIZE_START ,1 ); +if (ret) { +fprintf (stderr,"Could not write 0x%02x to EXT_CSD[%d] in %s\n" , +1 ,EXT_CSD_SANITIZE_START , device); +exit (1 ); + } +
don't we need to close the opened blkdev file here? or is it done somewhere else?
Quoted 13 lines
mmc_cmds.c +4
-0+return ret; + +} +mmc_cmds.h +1
-0@@ -24,3 +24,4 @@ int do_write_boot_en(int nargs, char **argv);int do_write_bkops_en (int nargs,char **argv);int do_hwreset_en (int nargs,char **argv);int do_hwreset_dis (int nargs,char **argv); +int do_sanitize (int nargs,char **argv);
Hi,
Quoted 61 lines · Subhash Jadavani
Quoted 60 lines · Yaniv Gardi
This patch adds a method to trigger Sanitize command to MMC. The Sanitize command is used for deleting the unmapped memory region of the MMC device.
Signed-off-by Yaniv Gardi <[email protected]>mmc.c +5
-0@@ -90,6 +90,11 @@ static struct Command commands[] = { "Permanently disable the eMMC H/W Reset feature on <device>.\nNOTE! This is a one-time programmable (unreversible) change.", NULL }, + { do_sanitize,-1 , +"sanitize" ,"<device>\n" +"Send Sanitize command to the <device>.\nThis will delete the unmapped memory region of the device" , +NULL + }, { 0, 0, 0, 0 } }; diff --git a/mmc.h b/mmc.hindex c863751..5173d34 100644
mmc.h +1
-0@@ -38,6 +38,7 @@#define EXT_CSD_PART_CONFIG 179#define EXT_CSD_BOOT_WP 173#define EXT_CSD_WR_REL_PARAM 166 +#define EXT_CSD_SANITIZE_START 165#define EXT_CSD_BKOPS_EN 163/* R/W */ #define EXT_CSD_RST_N_FUNCTION 162/* R/W */ #define EXT_CSD_NATIVE_SECTOR_SIZE 63/* R */ mmc_cmds.c +19
-0@@ -767,3 +767,31 @@ int do_read_extcsd(int nargs, char **argv) out_free:return ret; } + +int do_sanitize (int nargs,char **argv) +{ +int fd, ret; +char *device; + +CHECK (nargs !=2 ,"Usage: mmc sanitize </path/to/mmcblkX>\n" , +exit (1 )); + + device = argv[1 ]; + + fd =open (device,O_RDWR ); +if (fd <0 ) { +perror ("open" ); +exit (1 ); + } + + ret =write_extcsd_value (fd,EXT_CSD_SANITIZE_START ,1 ); +if (ret) {
Quoted 8 lines
mmc_cmds.c int do_read_extcsd(int nargs, char **argv) · line 793
Quoted 5 lines
mmc_cmds.c +5
-0+fprintf (stderr,"Could not write 0x%02x to EXT_CSD[%d] in %s\n" , +1 ,EXT_CSD_SANITIZE_START , device); +exit (1 ); + } +don't we need to close the opened blkdev file here? or is it done somewhere else?
Linux closes open file descriptors on process exit, no?
- Chris.
Signature · 2 lines
Chris Ball <[email protected]> <http://printf.net/> One Laptop Per Child
Subhash Jadavani
Acked-byQuoted 71 lines · Chris Ball
Hi,
Quoted 60 lines · Subhash Jadavani
Quoted 59 lines · Yaniv Gardi
This patch adds a method to trigger Sanitize command to MMC. The Sanitize command is used for deleting the unmapped memory region of the MMC device.
Signed-off-by Yaniv Gardi <[email protected]>mmc.c +5
-0@@ -90,6 +90,11 @@ static struct Command commands[] = { "Permanently disable the eMMC H/W Reset feature on <device>.\nNOTE! This is a one-time programmable (unreversible) change.", NULL }, + { do_sanitize,-1 , +"sanitize" ,"<device>\n" +"Send Sanitize command to the <device>.\nThis will delete the unmapped memory region of the device" , +NULL + }, { 0, 0, 0, 0 } }; diff --git a/mmc.h b/mmc.hindex c863751..5173d34 100644
mmc.h +1
-0@@ -38,6 +38,7 @@#define EXT_CSD_PART_CONFIG 179#define EXT_CSD_BOOT_WP 173#define EXT_CSD_WR_REL_PARAM 166 +#define EXT_CSD_SANITIZE_START 165#define EXT_CSD_BKOPS_EN 163/* R/W */ #define EXT_CSD_RST_N_FUNCTION 162/* R/W */ #define EXT_CSD_NATIVE_SECTOR_SIZE 63/* R */ mmc_cmds.c +18
-0@@ -767,3 +767,31 @@ int do_read_extcsd(int nargs, char **argv) out_free:return ret; } + +int do_sanitize (int nargs,char **argv) +{ +int fd, ret; +char *device; + +CHECK (nargs !=2 ,"Usage: mmc sanitize </path/to/mmcblkX>\n" , +exit (1 )); + + device = argv[1 ]; + + fd =open (device,O_RDWR ); +if (fd <0 ) { +perror ("open" ); +exit (1 ); + } + + ret =write_extcsd_value (fd,EXT_CSD_SANITIZE_START ,1 );Quoted 8 lines
mmc_cmds.c int do_read_extcsd(int nargs, char **argv) · line 793
Quoted 6 lines
mmc_cmds.c +6
-0+if (ret) { +fprintf (stderr,"Could not write 0x%02x to EXT_CSD[%d] in %s\n" , +1 ,EXT_CSD_SANITIZE_START , device); +exit (1 ); + } +don't we need to close the opened blkdev file here? or is it done somewhere else?
Quoted 1 line
Linux closes open file descriptors on process exit, no?
ok then it looks good to me.
Thanks,
Subhash
Quoted 2 lines
- Chris.
Hi,
Quoted 5 lines · Yaniv Gardi
This patch adds a method to trigger Sanitize command to MMC. The Sanitize command is used for deleting the unmapped memory region of the MMC device.
Signed-off-by Yaniv Gardi <[email protected]>
Thanks, pushed to mmc-utils.
- Chris.
Signature · 2 lines
Chris Ball <[email protected]> <http://printf.net/> One Laptop Per Child