Skip to content
This repository has been archived by the owner on Nov 8, 2023. It is now read-only.

Commit

Permalink
consumer_ir: add array length to get carrier freq
Browse files Browse the repository at this point in the history
Change-Id: Iefb424db6f16ffefa40da56c765c9b7a24bea397
  • Loading branch information
Alex Ray committed Sep 12, 2013
1 parent c900b42 commit d9d105a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
4 changes: 2 additions & 2 deletions include/hardware/consumerir.h
Expand Up @@ -66,12 +66,12 @@ typedef struct consumerir_device {
* (*get_carrier_freqs)() is called by the ConsumerIrService to enumerate
* which frequencies the IR transmitter supports. The HAL implementation
* should fill an array of consumerir_freq_range structs with the
* appropriate values for the transmitter.
* appropriate values for the transmitter, up to len elements.
*
* returns: the number of ranges on success. A negative error code on error.
*/
int (*get_carrier_freqs)(struct consumerir_device *dev,
consumerir_freq_range_t *ranges);
size_t len, consumerir_freq_range_t *ranges);

/* Reserved for future use. Must be NULL. */
void* reserved[8 - 3];
Expand Down
9 changes: 6 additions & 3 deletions modules/consumerir/consumerir.c
Expand Up @@ -54,10 +54,13 @@ static int consumerir_get_num_carrier_freqs(struct consumerir_device *dev)
}

static int consumerir_get_carrier_freqs(struct consumerir_device *dev,
consumerir_freq_range_t *ranges)
size_t len, consumerir_freq_range_t *ranges)
{
memcpy(ranges, consumerir_freqs, sizeof(consumerir_freqs));
return ARRAY_SIZE(consumerir_freqs);
size_t to_copy = ARRAY_SIZE(consumerir_freqs);

to_copy = len < to_copy ? len : to_copy;
memcpy(ranges, consumerir_freqs, to_copy * sizeof(consumerir_freq_range_t));
return to_copy;
}

static int consumerir_close(hw_device_t *dev)
Expand Down

0 comments on commit d9d105a

Please sign in to comment.