[1/2] tm6000: Add fast USB access quirk

Message ID 1314858441-30813-1-git-send-email-thierry.reding@avionic-design.de (mailing list archive)
State Accepted, archived
Headers

Commit Message

Thierry Reding Sept. 1, 2011, 6:27 a.m. UTC
  Some devices support fast access to registers using the USB interface
while others require a certain delay after each operation. This commit
adds a quirk that can be enabled by devices that don't need the delay.

Signed-off-by: Thierry Reding <thierry.reding@avionic-design.de>
---
 drivers/staging/tm6000/tm6000-core.c |    3 ++-
 drivers/staging/tm6000/tm6000.h      |    6 ++++++
 2 files changed, 8 insertions(+), 1 deletions(-)
  

Comments

Thierry Reding Sept. 1, 2011, 6:33 a.m. UTC | #1
* Thierry Reding wrote:
> Some devices support fast access to registers using the USB interface
> while others require a certain delay after each operation. This commit
> adds a quirk that can be enabled by devices that don't need the delay.
> 
> Signed-off-by: Thierry Reding <thierry.reding@avionic-design.de>
> ---
>  drivers/staging/tm6000/tm6000-core.c |    3 ++-
>  drivers/staging/tm6000/tm6000.h      |    6 ++++++
>  2 files changed, 8 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/staging/tm6000/tm6000-core.c b/drivers/staging/tm6000/tm6000-core.c
> index 64fc1c6..93a0772 100644
> --- a/drivers/staging/tm6000/tm6000-core.c
> +++ b/drivers/staging/tm6000/tm6000-core.c
> @@ -89,7 +89,8 @@ int tm6000_read_write_usb(struct tm6000_core *dev, u8 req_type, u8 req,
>  
>  	kfree(data);
>  
> -	msleep(5);
> +	if ((dev->quirks & TM6000_QUIRK_NO_USB_DELAY) == 0)
> +		msleep(5);

This is of course completely wrong. The quirk as defined below is actually a
bit position. I'll send another update where the quirk is defined as bit mask
for the given position.

Thierry

>  
>  	mutex_unlock(&dev->usb_lock);
>  	return ret;
> diff --git a/drivers/staging/tm6000/tm6000.h b/drivers/staging/tm6000/tm6000.h
> index dac2063..0e35812 100644
> --- a/drivers/staging/tm6000/tm6000.h
> +++ b/drivers/staging/tm6000/tm6000.h
> @@ -169,6 +169,10 @@ struct tm6000_endpoint {
>  	unsigned			maxsize;
>  };
>  
> +enum {
> +	TM6000_QUIRK_NO_USB_DELAY,
> +};
> +
>  struct tm6000_core {
>  	/* generic device properties */
>  	char				name[30];	/* name (including minor) of the device */
> @@ -260,6 +264,8 @@ struct tm6000_core {
>  	struct usb_isoc_ctl          isoc_ctl;
>  
>  	spinlock_t                   slock;
> +
> +	unsigned long quirks;
>  };
>  
>  enum tm6000_ops_type {
> -- 
> 1.7.6.1
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-media" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>
  

Patch

diff --git a/drivers/staging/tm6000/tm6000-core.c b/drivers/staging/tm6000/tm6000-core.c
index 64fc1c6..93a0772 100644
--- a/drivers/staging/tm6000/tm6000-core.c
+++ b/drivers/staging/tm6000/tm6000-core.c
@@ -89,7 +89,8 @@  int tm6000_read_write_usb(struct tm6000_core *dev, u8 req_type, u8 req,
 
 	kfree(data);
 
-	msleep(5);
+	if ((dev->quirks & TM6000_QUIRK_NO_USB_DELAY) == 0)
+		msleep(5);
 
 	mutex_unlock(&dev->usb_lock);
 	return ret;
diff --git a/drivers/staging/tm6000/tm6000.h b/drivers/staging/tm6000/tm6000.h
index dac2063..0e35812 100644
--- a/drivers/staging/tm6000/tm6000.h
+++ b/drivers/staging/tm6000/tm6000.h
@@ -169,6 +169,10 @@  struct tm6000_endpoint {
 	unsigned			maxsize;
 };
 
+enum {
+	TM6000_QUIRK_NO_USB_DELAY,
+};
+
 struct tm6000_core {
 	/* generic device properties */
 	char				name[30];	/* name (including minor) of the device */
@@ -260,6 +264,8 @@  struct tm6000_core {
 	struct usb_isoc_ctl          isoc_ctl;
 
 	spinlock_t                   slock;
+
+	unsigned long quirks;
 };
 
 enum tm6000_ops_type {