platform/x86: dell_rbu: don't open code list_for_each_entry*()
The loop declaration in packet_read_list() and packet_empty_list() can be simplified by reusing the common list_for_each_entry*() helper macros. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
This commit is contained in:
@@ -255,15 +255,13 @@ static int packetize_data(const u8 *data, size_t length)
|
|||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int do_packet_read(char *data, struct list_head *ptemp_list,
|
static int do_packet_read(char *data, struct packet_data *newpacket,
|
||||||
int length, int bytes_read, int *list_read_count)
|
int length, int bytes_read, int *list_read_count)
|
||||||
{
|
{
|
||||||
void *ptemp_buf;
|
void *ptemp_buf;
|
||||||
struct packet_data *newpacket = NULL;
|
|
||||||
int bytes_copied = 0;
|
int bytes_copied = 0;
|
||||||
int j = 0;
|
int j = 0;
|
||||||
|
|
||||||
newpacket = list_entry(ptemp_list, struct packet_data, list);
|
|
||||||
*list_read_count += newpacket->length;
|
*list_read_count += newpacket->length;
|
||||||
|
|
||||||
if (*list_read_count > bytes_read) {
|
if (*list_read_count > bytes_read) {
|
||||||
@@ -291,7 +289,7 @@ static int do_packet_read(char *data, struct list_head *ptemp_list,
|
|||||||
|
|
||||||
static int packet_read_list(char *data, size_t * pread_length)
|
static int packet_read_list(char *data, size_t * pread_length)
|
||||||
{
|
{
|
||||||
struct list_head *ptemp_list;
|
struct packet_data *newpacket;
|
||||||
int temp_count = 0;
|
int temp_count = 0;
|
||||||
int bytes_copied = 0;
|
int bytes_copied = 0;
|
||||||
int bytes_read = 0;
|
int bytes_read = 0;
|
||||||
@@ -305,9 +303,8 @@ static int packet_read_list(char *data, size_t * pread_length)
|
|||||||
remaining_bytes = *pread_length;
|
remaining_bytes = *pread_length;
|
||||||
bytes_read = rbu_data.packet_read_count;
|
bytes_read = rbu_data.packet_read_count;
|
||||||
|
|
||||||
ptemp_list = (&packet_data_head.list)->next;
|
list_for_each_entry(newpacket, (&packet_data_head.list)->next, list) {
|
||||||
while (!list_empty(ptemp_list)) {
|
bytes_copied = do_packet_read(pdest, newpacket,
|
||||||
bytes_copied = do_packet_read(pdest, ptemp_list,
|
|
||||||
remaining_bytes, bytes_read, &temp_count);
|
remaining_bytes, bytes_read, &temp_count);
|
||||||
remaining_bytes -= bytes_copied;
|
remaining_bytes -= bytes_copied;
|
||||||
bytes_read += bytes_copied;
|
bytes_read += bytes_copied;
|
||||||
@@ -318,8 +315,6 @@ static int packet_read_list(char *data, size_t * pread_length)
|
|||||||
*/
|
*/
|
||||||
if (remaining_bytes == 0)
|
if (remaining_bytes == 0)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
ptemp_list = ptemp_list->next;
|
|
||||||
}
|
}
|
||||||
/*finally set the bytes read */
|
/*finally set the bytes read */
|
||||||
*pread_length = bytes_read - rbu_data.packet_read_count;
|
*pread_length = bytes_read - rbu_data.packet_read_count;
|
||||||
@@ -329,17 +324,11 @@ static int packet_read_list(char *data, size_t * pread_length)
|
|||||||
|
|
||||||
static void packet_empty_list(void)
|
static void packet_empty_list(void)
|
||||||
{
|
{
|
||||||
struct list_head *ptemp_list;
|
struct packet_data *newpacket, *tmp;
|
||||||
struct list_head *pnext_list;
|
|
||||||
struct packet_data *newpacket;
|
list_for_each_entry_safe(newpacket, tmp, (&packet_data_head.list)->next, list) {
|
||||||
|
list_del(&newpacket->list);
|
||||||
|
|
||||||
ptemp_list = (&packet_data_head.list)->next;
|
|
||||||
while (!list_empty(ptemp_list)) {
|
|
||||||
newpacket =
|
|
||||||
list_entry(ptemp_list, struct packet_data, list);
|
|
||||||
pnext_list = ptemp_list->next;
|
|
||||||
list_del(ptemp_list);
|
|
||||||
ptemp_list = pnext_list;
|
|
||||||
/*
|
/*
|
||||||
* zero out the RBU packet memory before freeing
|
* zero out the RBU packet memory before freeing
|
||||||
* to make sure there are no stale RBU packets left in memory
|
* to make sure there are no stale RBU packets left in memory
|
||||||
|
Reference in New Issue
Block a user