Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ad485x upstreaming #2527

Draft
wants to merge 8 commits into
base: staging/linus
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions drivers/iio/industrialio-backend.c
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,30 @@ ssize_t iio_backend_ext_info_set(struct iio_dev *indio_dev, uintptr_t private,
}
EXPORT_SYMBOL_NS_GPL(iio_backend_ext_info_set, IIO_BACKEND);

/**
* iio_backend_interface_type_get - get the interace type used.
* @back: Backend device
* @type: Interface type
*
* RETURNS:
* 0 on success, negative error number on failure.
*/
int iio_backend_interface_type_get(struct iio_backend *back,
enum iio_backend_interface_type *type)
{
int ret;

ret = iio_backend_op_call(back, interface_type_get, type);
if (ret)
return ret;

if (*type > IIO_BACKEND_INTERFACE_CMOS)
return -EINVAL;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok sorry for the above. I think I somehow though this was doing a set and not a get. For now, I would likely leave it up to frontend to deal with the returned type. Also not -EINVAL is not too accurate as the frontend as no fault about this :)


return 0;
}
EXPORT_SYMBOL_NS_GPL(iio_backend_interface_type_get, IIO_BACKEND);

/**
* iio_backend_extend_chan_spec - Extend an IIO channel
* @indio_dev: IIO device
Expand Down
10 changes: 10 additions & 0 deletions include/linux/iio/backend.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ enum iio_backend_sample_trigger {
IIO_BACKEND_SAMPLE_TRIGGER_MAX
};

enum iio_backend_interface_type {
IIO_BACKEND_INTERFACE_LVDS,
IIO_BACKEND_INTERFACE_CMOS
};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think IIO_BACKEND_INTERFACE_* may be a better name. Also squash this with the other op being added. I've done it before (as the code is typically simple). Example of me adding multiple ops:

https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git/commit/?h=testing&id=c66eabcc1ca64dbf20d0758ce210a85fa83f4b21


/**
* struct iio_backend_ops - operations structure for an iio_backend
* @enable: Enable backend.
Expand All @@ -81,6 +86,7 @@ enum iio_backend_sample_trigger {
* @extend_chan_spec: Extend an IIO channel.
* @ext_info_set: Extended info setter.
* @ext_info_get: Extended info getter.
* @interface_type_get: Interface type.
**/
struct iio_backend_ops {
int (*enable)(struct iio_backend *back);
Expand Down Expand Up @@ -113,6 +119,8 @@ struct iio_backend_ops {
const char *buf, size_t len);
int (*ext_info_get)(struct iio_backend *back, uintptr_t private,
const struct iio_chan_spec *chan, char *buf);
int (*interface_type_get)(struct iio_backend *back,
enum iio_backend_interface_type *type);
};

int iio_backend_chan_enable(struct iio_backend *back, unsigned int chan);
Expand Down Expand Up @@ -142,6 +150,8 @@ ssize_t iio_backend_ext_info_set(struct iio_dev *indio_dev, uintptr_t private,
ssize_t iio_backend_ext_info_get(struct iio_dev *indio_dev, uintptr_t private,
const struct iio_chan_spec *chan, char *buf);

int iio_backend_interface_type_get(struct iio_backend *back,
enum iio_backend_interface_type *type);
int iio_backend_extend_chan_spec(struct iio_dev *indio_dev,
struct iio_backend *back,
struct iio_chan_spec *chan);
Expand Down