mirror of
https://gitlab.rtems.org/rtems/rtos/rtems.git
synced 2025-11-16 12:34:45 +00:00
cpukit/flashdev: Return error for missing callbacks
When a callback does not exist, the Flashdev API should return error where possible instead of success. When the API returns success for missing callbacks, the Flashdev API client code may end up using uninitialized variables as if they were filled by the API. Closes #5391
This commit is contained in:
@@ -106,7 +106,7 @@ static uint32_t rtems_flashdev_ioctl_jedec_id(
|
||||
rtems_flashdev *flash
|
||||
);
|
||||
|
||||
static uint32_t rtems_flashdev_ioctl_flash_type(
|
||||
static int rtems_flashdev_ioctl_flash_type(
|
||||
rtems_flashdev *flash,
|
||||
void *arg
|
||||
);
|
||||
@@ -728,7 +728,7 @@ static int rtems_flashdev_ioctl_erase(
|
||||
int status;
|
||||
|
||||
if ( flash->erase == NULL ) {
|
||||
return 0;
|
||||
rtems_set_errno_and_return_minus_one( ENOSYS );
|
||||
}
|
||||
|
||||
erase_args_1 = (rtems_flashdev_region *) arg;
|
||||
@@ -884,14 +884,14 @@ static uint32_t rtems_flashdev_ioctl_jedec_id( rtems_flashdev *flash )
|
||||
}
|
||||
}
|
||||
|
||||
static uint32_t rtems_flashdev_ioctl_flash_type(
|
||||
static int rtems_flashdev_ioctl_flash_type(
|
||||
rtems_flashdev *flash,
|
||||
void *arg
|
||||
)
|
||||
{
|
||||
rtems_flashdev_flash_type *type = (rtems_flashdev_flash_type*)arg;
|
||||
if ( flash->flash_type == NULL ) {
|
||||
return 0;
|
||||
rtems_set_errno_and_return_minus_one( ENOSYS );
|
||||
} else {
|
||||
return ( *flash->flash_type )( flash, type );
|
||||
}
|
||||
@@ -908,7 +908,7 @@ static int rtems_flashdev_ioctl_pageinfo_offset(
|
||||
rtems_set_errno_and_return_minus_one( EINVAL );
|
||||
}
|
||||
if ( flash->page_info_by_offset == NULL ) {
|
||||
return 0;
|
||||
rtems_set_errno_and_return_minus_one( ENOSYS );
|
||||
} else {
|
||||
page_info = (rtems_flashdev_ioctl_page_info *) arg;
|
||||
return ( *flash->page_info_by_offset )( flash,
|
||||
@@ -927,7 +927,7 @@ static int rtems_flashdev_ioctl_pageinfo_index( rtems_flashdev *flash,
|
||||
rtems_set_errno_and_return_minus_one( EINVAL );
|
||||
}
|
||||
if ( flash->page_info_by_index == NULL ) {
|
||||
return 0;
|
||||
rtems_set_errno_and_return_minus_one( ENOSYS );
|
||||
} else {
|
||||
page_info = (rtems_flashdev_ioctl_page_info *) arg;
|
||||
return ( *flash->page_info_by_index )( flash,
|
||||
@@ -943,7 +943,7 @@ static int rtems_flashdev_ioctl_page_count( rtems_flashdev *flash, void *arg )
|
||||
rtems_set_errno_and_return_minus_one( EINVAL );
|
||||
}
|
||||
if ( flash->page_count == NULL ) {
|
||||
return 0;
|
||||
rtems_set_errno_and_return_minus_one( ENOSYS );
|
||||
} else {
|
||||
return ( *flash->page_count )( flash, ( (int *) arg ) );
|
||||
}
|
||||
@@ -958,7 +958,7 @@ static int rtems_flashdev_ioctl_write_block_size(
|
||||
rtems_set_errno_and_return_minus_one( EINVAL );
|
||||
}
|
||||
if ( flash->write_block_size == NULL ) {
|
||||
return 0;
|
||||
rtems_set_errno_and_return_minus_one( ENOSYS );
|
||||
} else {
|
||||
return ( *flash->write_block_size )( flash, ( (size_t *) arg ) );
|
||||
}
|
||||
@@ -975,7 +975,7 @@ static int rtems_flashdev_ioctl_sectorinfo_offset(
|
||||
rtems_set_errno_and_return_minus_one( EINVAL );
|
||||
}
|
||||
if ( flash->sector_info_by_offset == NULL ) {
|
||||
return 0;
|
||||
rtems_set_errno_and_return_minus_one( ENOSYS );
|
||||
} else {
|
||||
sector_info = (rtems_flashdev_ioctl_sector_info *) arg;
|
||||
return ( *flash->sector_info_by_offset )( flash,
|
||||
@@ -991,7 +991,7 @@ static int rtems_flashdev_ioctl_sector_count( rtems_flashdev *flash, void *arg )
|
||||
rtems_set_errno_and_return_minus_one( EINVAL );
|
||||
}
|
||||
if ( flash->sector_count == NULL ) {
|
||||
return 0;
|
||||
rtems_set_errno_and_return_minus_one( ENOSYS );
|
||||
} else {
|
||||
return ( *flash->sector_count )( flash, ( (int *) arg ) );
|
||||
}
|
||||
@@ -1042,7 +1042,7 @@ static int rtems_flashdev_ioctl_oob_bytes_per_page(
|
||||
rtems_set_errno_and_return_minus_one( EINVAL );
|
||||
}
|
||||
if ( flash->oob_bytes_per_page == NULL ) {
|
||||
return 0;
|
||||
rtems_set_errno_and_return_minus_one( ENOSYS );
|
||||
} else {
|
||||
return ( *flash->oob_bytes_per_page )( flash, ( (size_t *) arg ) );
|
||||
}
|
||||
@@ -1055,7 +1055,7 @@ static int rtems_flashdev_ioctl_oob_read( rtems_flashdev *flash, void *arg )
|
||||
rtems_set_errno_and_return_minus_one( EINVAL );
|
||||
}
|
||||
if ( flash->oob_read == NULL ) {
|
||||
return 0;
|
||||
rtems_set_errno_and_return_minus_one( ENOSYS );
|
||||
} else {
|
||||
rw_info = (rtems_flashdev_ioctl_oob_rw_info *) arg;
|
||||
return ( *flash->oob_read )(
|
||||
@@ -1154,7 +1154,7 @@ static int rtems_flashdev_ioctl_oob_write( rtems_flashdev *flash, void *arg )
|
||||
rtems_set_errno_and_return_minus_one( EINVAL );
|
||||
}
|
||||
if ( flash->oob_write == NULL ) {
|
||||
return 0;
|
||||
rtems_set_errno_and_return_minus_one( ENOSYS );
|
||||
} else {
|
||||
rw_info = (rtems_flashdev_ioctl_oob_rw_info *) arg;
|
||||
return ( *flash->oob_write )(
|
||||
@@ -1193,7 +1193,7 @@ static int rtems_flashdev_ioctl_sector_mark_bad(
|
||||
rtems_set_errno_and_return_minus_one( EINVAL );
|
||||
}
|
||||
if ( flash->sector_mark_bad == NULL ) {
|
||||
return 0;
|
||||
rtems_set_errno_and_return_minus_one( ENOSYS );
|
||||
} else {
|
||||
return ( *flash->sector_mark_bad)( flash, *(uintptr_t *) arg );
|
||||
}
|
||||
@@ -1229,7 +1229,7 @@ static int rtems_flashdev_ioctl_sectorhealth(
|
||||
rtems_set_errno_and_return_minus_one( EINVAL );
|
||||
}
|
||||
if ( flash->sector_health == NULL ) {
|
||||
return 0;
|
||||
rtems_set_errno_and_return_minus_one( ENOSYS );
|
||||
} else {
|
||||
sector_health = arg;
|
||||
return ( *flash->sector_health)( flash, sector_health->location, §or_health->sector_bad );
|
||||
|
||||
Reference in New Issue
Block a user