-
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.
HID: roccat: Introduce module hid-roccat-common
Module hid-roccat-common contains functions used by roccat device driver modules to reduce code duplication. At the moment it contains just two wrapper methods for usb_control_msg that ensure that the buffer used for transfer is dma capable which wasn't the case before. The kconfig option is not visible to the user but will be selected by the device specific drivers. Signed-off-by: Stefan Achatz <erazor_de@users.sourceforge.net> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
- Loading branch information
Stefan Achatz
authored and
Jiri Kosina
committed
Feb 3, 2011
1 parent
a28764e
commit 5772f63
Showing
8 changed files
with
254 additions
and
426 deletions.
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
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,62 @@ | ||
/* | ||
* Roccat common functions for device specific drivers | ||
* | ||
* Copyright (c) 2011 Stefan Achatz <erazor_de@users.sourceforge.net> | ||
*/ | ||
|
||
/* | ||
* This program is free software; you can redistribute it and/or modify it | ||
* under the terms of the GNU General Public License as published by the Free | ||
* Software Foundation; either version 2 of the License, or (at your option) | ||
* any later version. | ||
*/ | ||
|
||
#include <linux/slab.h> | ||
#include "hid-roccat-common.h" | ||
|
||
int roccat_common_receive(struct usb_device *usb_dev, uint usb_command, | ||
void *data, uint size) | ||
{ | ||
char *buf; | ||
int len; | ||
|
||
buf = kmalloc(size, GFP_KERNEL); | ||
if (buf == NULL) | ||
return -ENOMEM; | ||
|
||
len = usb_control_msg(usb_dev, usb_rcvctrlpipe(usb_dev, 0), | ||
USB_REQ_CLEAR_FEATURE, | ||
USB_TYPE_CLASS | USB_RECIP_INTERFACE | USB_DIR_IN, | ||
usb_command, 0, buf, size, USB_CTRL_SET_TIMEOUT); | ||
|
||
memcpy(data, buf, size); | ||
kfree(buf); | ||
return ((len < 0) ? len : ((len != size) ? -EIO : 0)); | ||
} | ||
EXPORT_SYMBOL_GPL(roccat_common_receive); | ||
|
||
int roccat_common_send(struct usb_device *usb_dev, uint usb_command, | ||
void const *data, uint size) | ||
{ | ||
char *buf; | ||
int len; | ||
|
||
buf = kmalloc(size, GFP_KERNEL); | ||
if (buf == NULL) | ||
return -ENOMEM; | ||
|
||
memcpy(buf, data, size); | ||
|
||
len = usb_control_msg(usb_dev, usb_sndctrlpipe(usb_dev, 0), | ||
USB_REQ_SET_CONFIGURATION, | ||
USB_TYPE_CLASS | USB_RECIP_INTERFACE | USB_DIR_OUT, | ||
usb_command, 0, buf, size, USB_CTRL_SET_TIMEOUT); | ||
|
||
kfree(buf); | ||
return ((len < 0) ? len : ((len != size) ? -EIO : 0)); | ||
} | ||
EXPORT_SYMBOL_GPL(roccat_common_send); | ||
|
||
MODULE_AUTHOR("Stefan Achatz"); | ||
MODULE_DESCRIPTION("USB Roccat common driver"); | ||
MODULE_LICENSE("GPL v2"); |
Oops, something went wrong.