summaryrefslogtreecommitdiff
path: root/drivers/staging/most
diff options
context:
space:
mode:
authorChristian Gromm <christian.gromm@microchip.com>2017-11-21 17:04:44 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2017-11-27 11:20:34 +0300
commit14c018a93e8e74310e2e9f9a9e6cb39e7337c44b (patch)
tree058f917c53f65fbc8cc4d8b224ca4a7a38638da7 /drivers/staging/most
parent4d5f022f3a664ee5987118b754058ff31df03835 (diff)
downloadlinux-14c018a93e8e74310e2e9f9a9e6cb39e7337c44b.tar.xz
staging: most: core: remove function get_channel_by_iface
This patch removes the function get_channel_by_iface that walks a list of all registered interfaces and returns a pointer to a channel when matched. Instead the private field of the interface structure is used to directly access the channel via the id. The patch is needed to remove unnecessary list traversing. Signed-off-by: Christian Gromm <christian.gromm@microchip.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/most')
-rw-r--r--drivers/staging/most/core.c47
1 files changed, 13 insertions, 34 deletions
diff --git a/drivers/staging/most/core.c b/drivers/staging/most/core.c
index d4456abf18ed..7f7d6b65d76f 100644
--- a/drivers/staging/most/core.c
+++ b/drivers/staging/most/core.c
@@ -989,37 +989,10 @@ static void most_write_completion(struct mbo *mbo)
arm_mbo(mbo);
}
-/**
- * get_channel_by_iface - get pointer to channel object
- * @iface: pointer to interface instance
- * @id: channel ID
- *
- * This retrieves a pointer to a channel of the given interface and channel ID.
- */
-static struct
-most_c_obj *get_channel_by_iface(struct most_interface *iface, int id)
-{
- struct most_inst_obj *i;
-
- if (unlikely(!iface)) {
- pr_err("Bad interface\n");
- return NULL;
- }
- if (unlikely((id < 0) || (id >= iface->num_channels))) {
- pr_err("Channel index (%d) out of range\n", id);
- return NULL;
- }
- i = iface->priv;
- if (unlikely(!i)) {
- pr_err("interface is not registered\n");
- return NULL;
- }
- return i->channel[id];
-}
-
int channel_has_mbo(struct most_interface *iface, int id, struct most_aim *aim)
{
- struct most_c_obj *c = get_channel_by_iface(iface, id);
+ struct most_inst_obj *inst = iface->priv;
+ struct most_c_obj *c = inst->channel[id];
unsigned long flags;
int empty;
@@ -1051,10 +1024,11 @@ struct mbo *most_get_mbo(struct most_interface *iface, int id,
{
struct mbo *mbo;
struct most_c_obj *c;
+ struct most_inst_obj *inst = iface->priv;
unsigned long flags;
int *num_buffers_ptr;
- c = get_channel_by_iface(iface, id);
+ c = inst->channel[id];
if (unlikely(!c))
return NULL;
@@ -1156,7 +1130,8 @@ int most_start_channel(struct most_interface *iface, int id,
{
int num_buffer;
int ret;
- struct most_c_obj *c = get_channel_by_iface(iface, id);
+ struct most_inst_obj *inst = iface->priv;
+ struct most_c_obj *c = inst->channel[id];
if (unlikely(!c))
return -EINVAL;
@@ -1224,13 +1199,15 @@ EXPORT_SYMBOL_GPL(most_start_channel);
int most_stop_channel(struct most_interface *iface, int id,
struct most_aim *aim)
{
+ struct most_inst_obj *inst;
struct most_c_obj *c;
if (unlikely((!iface) || (id >= iface->num_channels) || (id < 0))) {
pr_err("Bad interface or index out of range\n");
return -EINVAL;
}
- c = get_channel_by_iface(iface, id);
+ inst = iface->priv;
+ c = inst->channel[id];
if (unlikely(!c))
return -EINVAL;
@@ -1507,7 +1484,8 @@ EXPORT_SYMBOL_GPL(most_deregister_interface);
*/
void most_stop_enqueue(struct most_interface *iface, int id)
{
- struct most_c_obj *c = get_channel_by_iface(iface, id);
+ struct most_inst_obj *inst = iface->priv;
+ struct most_c_obj *c = inst->channel[id];
if (!c)
return;
@@ -1528,7 +1506,8 @@ EXPORT_SYMBOL_GPL(most_stop_enqueue);
*/
void most_resume_enqueue(struct most_interface *iface, int id)
{
- struct most_c_obj *c = get_channel_by_iface(iface, id);
+ struct most_inst_obj *inst = iface->priv;
+ struct most_c_obj *c = inst->channel[id];
if (!c)
return;