Commit d18cbb60 authored by Daniel DeGrasse's avatar Daniel DeGrasse Committed by Fabio Baltieri
Browse files

drivers: disk: add DISK_IOCTL_CTRL_DEINIT command to supported IOCTLs



Add DISK_IOCTL_CTRL_DEINIT ioctl command to disk subsystem. When
disk_access_ioctl() is called with this command, the disk will be
de-initialized. After this IOCTL completes, the disk can safely be
reinitialized.

Fixes #60628

Signed-off-by: default avatarDaniel DeGrasse <daniel.degrasse@nxp.com>
parent fb2d5c33
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -435,6 +435,7 @@ static int disk_flash_access_ioctl(struct disk_info *disk, uint8_t cmd, void *bu
	ctx = CONTAINER_OF(disk, struct flashdisk_data, info);

	switch (cmd) {
	case DISK_IOCTL_CTRL_DEINIT:
	case DISK_IOCTL_CTRL_SYNC:
		k_mutex_lock(&ctx->lock, K_FOREVER);
		rc = flashdisk_cache_commit(ctx);
+1 −0
Original line number Diff line number Diff line
@@ -107,6 +107,7 @@ static int loopback_disk_access_ioctl(struct disk_info *disk, uint8_t cmd, void
		*(uint32_t *)buff = LOOPBACK_SECTOR_SIZE;
		return 0;
	}
	case DISK_IOCTL_CTRL_DEINIT:
	case DISK_IOCTL_CTRL_SYNC:
		return fs_sync(&ctx->file);
	case DISK_IOCTL_CTRL_INIT:
+7 −0
Original line number Diff line number Diff line
@@ -85,6 +85,13 @@ static int disk_mmc_access_ioctl(struct disk_info *disk, uint8_t cmd, void *buf)
	switch (cmd) {
	case DISK_IOCTL_CTRL_INIT:
		return disk_mmc_access_init(disk);
	case DISK_IOCTL_CTRL_DEINIT:
		mmc_ioctl(&data->card, DISK_IOCTL_CTRL_SYNC, NULL);
		/* sd_init() will toggle power to MMC, so we can just mark
		 * disk as uninitialized
		 */
		data->status = SD_UNINIT;
		return 0;
	default:
		return mmc_ioctl(&data->card, cmd, buf);
	}
+1 −0
Original line number Diff line number Diff line
@@ -178,6 +178,7 @@ static int nvme_disk_ioctl(struct disk_info *disk, uint8_t cmd, void *buff)
		*(uint32_t *)buff = nvme_namespace_get_sector_size(ns);

		break;
	case DISK_IOCTL_CTRL_DEINIT:
	case DISK_IOCTL_CTRL_SYNC:
		ret = nvme_disk_flush(ns);
		break;
+1 −0
Original line number Diff line number Diff line
@@ -94,6 +94,7 @@ static int disk_ram_access_ioctl(struct disk_info *disk, uint8_t cmd, void *buff
		*(uint32_t *)buff  = 1U;
		break;
	case DISK_IOCTL_CTRL_INIT:
	case DISK_IOCTL_CTRL_DEINIT:
		break;
	default:
		return -EINVAL;
Loading