mirror of
https://gitlab.rtems.org/rtems/rtos/rtems.git
synced 2026-09-21 04:51:15 +08:00
rtems: Move _Partition_Is_buffer_valid()
It is used only in one place. Make the PTCB the first parameter. Rename it to _Partition_Is_address_a_buffer_begin().
This commit is contained in:
@@ -56,29 +56,6 @@ RTEMS_INLINE_ROUTINE bool _Partition_Is_buffer_on_boundary (
|
||||
return ((offset % the_partition->buffer_size) == 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Checks whether the_buffer is a valid buffer from the_partition.
|
||||
*
|
||||
* This function returns TRUE if the_buffer is a valid buffer from
|
||||
* the_partition, otherwise FALSE is returned.
|
||||
*/
|
||||
RTEMS_INLINE_ROUTINE bool _Partition_Is_buffer_valid (
|
||||
Chain_Node *the_buffer,
|
||||
Partition_Control *the_partition
|
||||
)
|
||||
{
|
||||
void *starting;
|
||||
void *ending;
|
||||
|
||||
starting = the_partition->starting_address;
|
||||
ending = _Addresses_Add_offset( starting, the_partition->length );
|
||||
|
||||
return (
|
||||
_Addresses_Is_in_range( the_buffer, starting, ending ) &&
|
||||
_Partition_Is_buffer_on_boundary( the_buffer, the_partition )
|
||||
);
|
||||
}
|
||||
|
||||
RTEMS_INLINE_ROUTINE bool _Partition_Is_buffer_size_aligned(
|
||||
uint32_t buffer_size
|
||||
)
|
||||
|
||||
@@ -21,8 +21,24 @@
|
||||
#endif
|
||||
|
||||
#include <rtems/rtems/partimpl.h>
|
||||
#include <rtems/score/address.h>
|
||||
#include <rtems/score/chainimpl.h>
|
||||
|
||||
static bool _Partition_Is_address_a_buffer_begin(
|
||||
const Partition_Control *the_partition,
|
||||
const void *the_buffer
|
||||
)
|
||||
{
|
||||
void *starting;
|
||||
void *ending;
|
||||
|
||||
starting = the_partition->starting_address;
|
||||
ending = _Addresses_Add_offset( starting, the_partition->length );
|
||||
|
||||
return _Addresses_Is_in_range( the_buffer, starting, ending )
|
||||
&& _Partition_Is_buffer_on_boundary( the_buffer, the_partition );
|
||||
}
|
||||
|
||||
static void _Partition_Free_buffer(
|
||||
Partition_Control *the_partition,
|
||||
void *the_buffer
|
||||
@@ -51,7 +67,7 @@ rtems_status_code rtems_partition_return_buffer(
|
||||
|
||||
_Partition_Acquire_critical( the_partition, &lock_context );
|
||||
|
||||
if ( !_Partition_Is_buffer_valid( buffer, the_partition ) ) {
|
||||
if ( !_Partition_Is_address_a_buffer_begin( the_partition, buffer ) ) {
|
||||
_Partition_Release( the_partition, &lock_context );
|
||||
return RTEMS_INVALID_ADDRESS;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user