Skip to content

Commit

Permalink
HID: intel-ish-hid: ishtp: add helper function for client search
Browse files Browse the repository at this point in the history
Add helper function ishtp_fw_cl_get_client() for client driver searching
client information to hide internal details from callers.

Signed-off-by: Even Xu <even.xu@intel.com>
Reviewed-by: Andriy Shevchenko <andriy.shevchenko@intel.com>
Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
  • Loading branch information
Even Xu authored and Jiri Kosina committed Sep 24, 2018
1 parent 816e7ed commit e625020
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
25 changes: 25 additions & 0 deletions drivers/hid/intel-ish-hid/ishtp/bus.c
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,31 @@ int ishtp_fw_cl_by_uuid(struct ishtp_device *dev, const uuid_le *uuid)
}
EXPORT_SYMBOL(ishtp_fw_cl_by_uuid);

/**
* ishtp_fw_cl_get_client() - return client information to client
* @dev: the ishtp device structure
* @uuid: uuid of the client to search
*
* Search firmware client using UUID and reture related client information.
*
* Return: pointer of client information on success, NULL on failure.
*/
struct ishtp_fw_client *ishtp_fw_cl_get_client(struct ishtp_device *dev,
const uuid_le *uuid)
{
int i;
unsigned long flags;

spin_lock_irqsave(&dev->fw_clients_lock, flags);
i = ishtp_fw_cl_by_uuid(dev, uuid);
spin_unlock_irqrestore(&dev->fw_clients_lock, flags);
if (i < 0 || dev->fw_clients[i].props.fixed_address)
return NULL;

return &dev->fw_clients[i];
}
EXPORT_SYMBOL(ishtp_fw_cl_get_client);

/**
* ishtp_fw_cl_by_id() - return index to fw_clients for client_id
* @dev: the ishtp device structure
Expand Down
2 changes: 2 additions & 0 deletions drivers/hid/intel-ish-hid/ishtp/bus.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,5 +113,7 @@ void ishtp_cl_driver_unregister(struct ishtp_cl_driver *driver);
int ishtp_register_event_cb(struct ishtp_cl_device *device,
void (*read_cb)(struct ishtp_cl_device *));
int ishtp_fw_cl_by_uuid(struct ishtp_device *dev, const uuid_le *cuuid);
struct ishtp_fw_client *ishtp_fw_cl_get_client(struct ishtp_device *dev,
const uuid_le *uuid);

#endif /* _LINUX_ISHTP_CL_BUS_H */

0 comments on commit e625020

Please sign in to comment.