-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
staging:iio:core add in kernel interface mapping and getting IIO chan…
…nels. Lifted from proposal for in kernel interface built on the out of staging branch. Two elements here: * Map as defined in "inkern.h" * Matching code to actually get the iio_dev and channel that we want from the global list of IIO devices. V4: Everything now built if iio is built (rather than being optional) Removal race condition prevented by using info pointer as a check of removal under a lock. V3: Drop the option of registering / getting channels using dev pointer. Stick to name only as suggested by Mark Brown (this has caused user confusion in the regulator framework.) V2: As per Greg KH suggestion, move over to registration by passing the tables into the provider drivers (how regulator does it). This does not prevent us using the original more flexible approach if at a later date there is a usecase that demands it. Signed-off-by: Jonathan Cameron <jic23@kernel.org> Acked-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
- Loading branch information
Jonathan Cameron
authored and
Greg Kroah-Hartman
committed
Feb 24, 2012
1 parent
ac917a8
commit e27d75d
Showing
5 changed files
with
447 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
/* | ||
* Industrial I/O in kernel consumer interface | ||
* | ||
* Copyright (c) 2011 Jonathan Cameron | ||
* | ||
* This program is free software; you can redistribute it and/or modify it | ||
* under the terms of the GNU General Public License version 2 as published by | ||
* the Free Software Foundation. | ||
*/ | ||
#ifndef _IIO_INKERN_CONSUMER_H_ | ||
#define _IIO_INKERN_CONSUMER_H | ||
#include "types.h" | ||
|
||
struct iio_dev; | ||
struct iio_chan_spec; | ||
|
||
/** | ||
* struct iio_channel - everything needed for a consumer to use a channel | ||
* @indio_dev: Device on which the channel exists. | ||
* @channel: Full description of the channel. | ||
*/ | ||
struct iio_channel { | ||
struct iio_dev *indio_dev; | ||
const struct iio_chan_spec *channel; | ||
}; | ||
|
||
/** | ||
* iio_channel_get() - get description of all that is needed to access channel. | ||
* @name: Unique name of the device as provided in the iio_map | ||
* with which the desired provider to consumer mapping | ||
* was registered. | ||
* @consumer_channel: Unique name to identify the channel on the consumer | ||
* side. This typically describes the channels use within | ||
* the consumer. E.g. 'battery_voltage' | ||
*/ | ||
struct iio_channel *iio_st_channel_get(const char *name, | ||
const char *consumer_channel); | ||
|
||
/** | ||
* iio_st_channel_release() - release channels obtained via iio_st_channel_get | ||
* @chan: The channel to be released. | ||
*/ | ||
void iio_st_channel_release(struct iio_channel *chan); | ||
|
||
/** | ||
* iio_st_channel_get_all() - get all channels associated with a client | ||
* @name: name of consumer device. | ||
* | ||
* Returns an array of iio_channel structures terminated with one with | ||
* null iio_dev pointer. | ||
* This function is used by fairly generic consumers to get all the | ||
* channels registered as having this consumer. | ||
*/ | ||
struct iio_channel *iio_st_channel_get_all(const char *name); | ||
|
||
/** | ||
* iio_st_channel_release_all() - reverse iio_st_get_all | ||
* @chan: Array of channels to be released. | ||
*/ | ||
void iio_st_channel_release_all(struct iio_channel *chan); | ||
|
||
/** | ||
* iio_st_read_channel_raw() - read from a given channel | ||
* @channel: The channel being queried. | ||
* @val: Value read back. | ||
* | ||
* Note raw reads from iio channels are in adc counts and hence | ||
* scale will need to be applied if standard units required. | ||
*/ | ||
int iio_st_read_channel_raw(struct iio_channel *chan, | ||
int *val); | ||
|
||
/** | ||
* iio_st_get_channel_type() - get the type of a channel | ||
* @channel: The channel being queried. | ||
* @type: The type of the channel. | ||
* | ||
* returns the enum iio_chan_type of the channel | ||
*/ | ||
int iio_st_get_channel_type(struct iio_channel *channel, | ||
enum iio_chan_type *type); | ||
|
||
/** | ||
* iio_st_read_channel_scale() - read the scale value for a channel | ||
* @channel: The channel being queried. | ||
* @val: First part of value read back. | ||
* @val2: Second part of value read back. | ||
* | ||
* Note returns a description of what is in val and val2, such | ||
* as IIO_VAL_INT_PLUS_MICRO telling us we have a value of val | ||
* + val2/1e6 | ||
*/ | ||
int iio_st_read_channel_scale(struct iio_channel *chan, int *val, | ||
int *val2); | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
* Industrial I/O in kernel access map interface. | ||
* | ||
* Copyright (c) 2011 Jonathan Cameron | ||
* | ||
* This program is free software; you can redistribute it and/or modify it | ||
* under the terms of the GNU General Public License version 2 as published by | ||
* the Free Software Foundation. | ||
*/ | ||
|
||
#ifndef _IIO_INKERN_H_ | ||
#define _IIO_INKERN_H_ | ||
|
||
struct iio_map; | ||
|
||
/** | ||
* iio_map_array_register() - tell the core about inkernel consumers | ||
* @indio_dev: provider device | ||
* @map: array of mappings specifying association of channel with client | ||
*/ | ||
int iio_map_array_register(struct iio_dev *indio_dev, | ||
struct iio_map *map); | ||
|
||
/** | ||
* iio_map_array_unregister() - tell the core to remove consumer mappings | ||
* @indio_dev: provider device | ||
* @map: array of mappings to remove. Note these must have same memory | ||
* addresses as those originally added not just equal parameter | ||
* values. | ||
*/ | ||
int iio_map_array_unregister(struct iio_dev *indio_dev, | ||
struct iio_map *map); | ||
|
||
#endif |
Oops, something went wrong.