am d9d105a0: consumer_ir: add array length to get carrier freq

* commit 'd9d105a0ce6bbaa8d1d1cf70a255612a5dd33701':
  consumer_ir: add array length to get carrier freq
This commit is contained in:
Alex Ray 2013-09-12 09:12:47 -07:00 committed by Android Git Automerger
commit d587c613c6
2 changed files with 8 additions and 5 deletions

View file

@ -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];

View file

@ -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)