Skip to contentSkip to conversation

HID: roccat: Added ioctl command to retreive report size from chardev

PATCH Applied Stefan Achatz 2 participants 3 messages Jan 30, 2011 – Feb 3, 2011

Subsystems (3)
lore
Share & tools
lore

Stefan Achatz

author maintainer
#0 lore raw

PATCH 5/8 HID: roccat: Added ioctl command to retreive report size from chardev

Roccat chardev was reworked to support only a defined report size per device and this can be retreived by an ioctl now to enable future changes in report definitions.
Header was moved/renamed from drivers/hid to include/linux for accessibility.

---
 Documentation/ioctl/ioctl-number.txt |    1 +
 drivers/hid/hid-roccat-arvo.c        |    9 +++---
 drivers/hid/hid-roccat-kone.c        |   11 +++----
 drivers/hid/hid-roccat-koneplus.c    |    8 +++---
 drivers/hid/hid-roccat-kovaplus.c    |    8 +++---
 drivers/hid/hid-roccat-pyra.c        |   11 +++----
 drivers/hid/hid-roccat.c             |   48 ++++++++++++++++++++++++++-------
 drivers/hid/hid-roccat.h             |   22 ---------------
 include/linux/roccat.h               |   29 ++++++++++++++++++++
 9 files changed, 91 insertions(+), 56 deletions(-)
 delete mode 100644 drivers/hid/hid-roccat.h
 create mode 100644 include/linux/roccat.h
Documentation/ioctl/ioctl-number.txt +1 -0
index ac293e9..b0f1fa0 100644
@@ -133,6 +133,7 @@ Code  Seq#(hex)	Include File		Comments
 'H'	C0-DF	net/bluetooth/hidp/hidp.h	conflict!
 'H'	C0-DF	net/bluetooth/cmtp/cmtp.h	conflict!
 'H'	C0-DF	net/bluetooth/bnep/bnep.h	conflict!
+'H'	F1	linux/roccat.h		<mailto:[email protected]>
 'I'	all	linux/isdn.h		conflict!
 'I'	00-0F	drivers/isdn/divert/isdn_divert.h	conflict!
 'I'	40-4F	linux/mISDNif.h		conflict!
drivers/hid/hid-roccat-arvo.c +5 -4
index d72ee41..7b9a992 100644
@@ -21,8 +21,8 @@
 #include <linux/hid.h>
 #include <linux/module.h>
 #include <linux/slab.h>
+#include <linux/roccat.h>
 #include "hid-ids.h"
-#include "hid-roccat.h"
 #include "hid-roccat-common.h"
 #include "hid-roccat-arvo.h"
 
@@ -303,7 +303,8 @@ static int arvo_init_specials(struct hid_device *hdev)
 		goto exit_free;
 	}
 
-	retval = roccat_connect(arvo_class, hdev);
+	retval = roccat_connect(arvo_class, hdev,
+			sizeof(struct arvo_roccat_report));
 	if (retval < 0) {
 		hid_err(hdev, "couldn't init char dev\n");
 	} else {
@@ -386,8 +387,8 @@ static void arvo_report_to_chrdev(struct arvo_device const *arvo,
 	else
 		roccat_report.action = ARVO_ROCCAT_REPORT_ACTION_RELEASE;
 
-	roccat_report_event(arvo->chrdev_minor, (uint8_t const *)&roccat_report,
-			sizeof(struct arvo_roccat_report));
+	roccat_report_event(arvo->chrdev_minor,
+			(uint8_t const *)&roccat_report);
 }
 
 static int arvo_raw_event(struct hid_device *hdev,
drivers/hid/hid-roccat-kone.c +5 -6
index 5516653..5cdb282 100644
@@ -30,8 +30,8 @@
 #include <linux/hid.h>
 #include <linux/module.h>
 #include <linux/slab.h>
+#include <linux/roccat.h>
 #include "hid-ids.h"
-#include "hid-roccat.h"
 #include "hid-roccat-common.h"
 #include "hid-roccat-kone.h"
 
@@ -660,7 +660,8 @@ static int kone_init_specials(struct hid_device *hdev)
 			goto exit_free;
 		}
 
-		retval = roccat_connect(kone_class, hdev);
+		retval = roccat_connect(kone_class, hdev,
+				sizeof(struct kone_roccat_report));
 		if (retval < 0) {
 			hid_err(hdev, "couldn't init char dev\n");
 			/* be tolerant about not getting chrdev */
@@ -760,8 +761,7 @@ static void kone_report_to_chrdev(struct kone_device const *kone,
 		roccat_report.value = event->value;
 		roccat_report.key = 0;
 		roccat_report_event(kone->chrdev_minor,
-				(uint8_t *)&roccat_report,
-				sizeof(struct kone_roccat_report));
+				(uint8_t *)&roccat_report);
 		break;
 	case kone_mouse_event_call_overlong_macro:
 		if (event->value == kone_keystroke_action_press) {
@@ -769,8 +769,7 @@ static void kone_report_to_chrdev(struct kone_device const *kone,
 			roccat_report.value = kone->actual_profile;
 			roccat_report.key = event->macro_key;
 			roccat_report_event(kone->chrdev_minor,
-					(uint8_t *)&roccat_report,
-					sizeof(struct kone_roccat_report));
+					(uint8_t *)&roccat_report);
 		}
 		break;
 	}
drivers/hid/hid-roccat-koneplus.c +4 -4
index d1c3a02..29a42b4 100644
@@ -21,8 +21,8 @@
 #include <linux/hid.h>
 #include <linux/module.h>
 #include <linux/slab.h>
+#include <linux/roccat.h>
 #include "hid-ids.h"
-#include "hid-roccat.h"
 #include "hid-roccat-common.h"
 #include "hid-roccat-koneplus.h"
 
@@ -612,7 +612,8 @@ static int koneplus_init_specials(struct hid_device *hdev)
 			goto exit_free;
 		}
 
-		retval = roccat_connect(koneplus_class, hdev);
+		retval = roccat_connect(koneplus_class, hdev,
+				sizeof(struct koneplus_roccat_report));
 		if (retval < 0) {
 			hid_err(hdev, "couldn't init char dev\n");
 		} else {
@@ -718,8 +719,7 @@ static void koneplus_report_to_chrdev(struct koneplus_device const *koneplus,
 	roccat_report.data2 = button_report->data2;
 	roccat_report.profile = koneplus->actual_profile + 1;
 	roccat_report_event(koneplus->chrdev_minor,
-			(uint8_t const *)&roccat_report,
-			sizeof(struct koneplus_roccat_report));
+			(uint8_t const *)&roccat_report);
 }
 
 static int koneplus_raw_event(struct hid_device *hdev,
drivers/hid/hid-roccat-kovaplus.c +4 -4
index 1f547a2..7664e2c 100644
@@ -20,8 +20,8 @@
 #include <linux/hid.h>
 #include <linux/module.h>
 #include <linux/slab.h>
+#include <linux/roccat.h>
 #include "hid-ids.h"
-#include "hid-roccat.h"
 #include "hid-roccat-common.h"
 #include "hid-roccat-kovaplus.h"
 
@@ -524,7 +524,8 @@ static int kovaplus_init_specials(struct hid_device *hdev)
 			goto exit_free;
 		}
 
-		retval = roccat_connect(kovaplus_class, hdev);
+		retval = roccat_connect(kovaplus_class, hdev,
+				sizeof(struct kovaplus_roccat_report));
 		if (retval < 0) {
 			hid_err(hdev, "couldn't init char dev\n");
 		} else {
@@ -648,8 +649,7 @@ static void kovaplus_report_to_chrdev(struct kovaplus_device const *kovaplus,
 	roccat_report.data2 = button_report->data2;
 
 	roccat_report_event(kovaplus->chrdev_minor,
-			(uint8_t const *)&roccat_report,
-			sizeof(struct kovaplus_roccat_report));
+			(uint8_t const *)&roccat_report);
 }
 
 static int kovaplus_raw_event(struct hid_device *hdev,
drivers/hid/hid-roccat-pyra.c +5 -6
index abe77d3..be4daa9 100644
@@ -22,8 +22,8 @@
 #include <linux/hid.h>
 #include <linux/module.h>
 #include <linux/slab.h>
+#include <linux/roccat.h>
 #include "hid-ids.h"
-#include "hid-roccat.h"
 #include "hid-roccat-common.h"
 #include "hid-roccat-pyra.h"
 
@@ -506,7 +506,8 @@ static int pyra_init_specials(struct hid_device *hdev)
 			goto exit_free;
 		}
 
-		retval = roccat_connect(pyra_class, hdev);
+		retval = roccat_connect(pyra_class, hdev,
+				sizeof(struct pyra_roccat_report));
 		if (retval < 0) {
 			hid_err(hdev, "couldn't init char dev\n");
 		} else {
@@ -610,8 +611,7 @@ static void pyra_report_to_chrdev(struct pyra_device const *pyra,
 		roccat_report.value = button_event->data1;
 		roccat_report.key = 0;
 		roccat_report_event(pyra->chrdev_minor,
-				(uint8_t const *)&roccat_report,
-				sizeof(struct pyra_roccat_report));
+				(uint8_t const *)&roccat_report);
 		break;
 	case PYRA_MOUSE_EVENT_BUTTON_TYPE_MACRO:
 	case PYRA_MOUSE_EVENT_BUTTON_TYPE_SHORTCUT:
@@ -625,8 +625,7 @@ static void pyra_report_to_chrdev(struct pyra_device const *pyra,
 			 */
 			roccat_report.value = pyra->actual_profile + 1;
 			roccat_report_event(pyra->chrdev_minor,
-					(uint8_t const *)&roccat_report,
-					sizeof(struct pyra_roccat_report));
+					(uint8_t const *)&roccat_report);
 		}
 		break;
 	}
drivers/hid/hid-roccat.c +38 -10

115 lines not on this page · raw message

drivers/hid/hid-roccat.h deleted +0 -22
deleted file mode 100644
index c739337..0000000
@@ -1,22 +0,0 @@
-#ifndef __HID_ROCCAT_H
-#define __HID_ROCCAT_H
-
-/*
- * Copyright (c) 2010 Stefan Achatz <[email protected]>
- */
-
-/*
- * 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/hid.h>
-#include <linux/types.h>
-
-int roccat_connect(struct class *klass, struct hid_device *hid);
-void roccat_disconnect(int minor);
-int roccat_report_event(int minor, u8 const *data, int len);
-
-#endif
include/linux/roccat.h new file +29 -0
new file mode 100644
index 0000000..24e1ca0
@@ -0,0 +1,29 @@
+#ifndef __HID_ROCCAT_H
+#define __HID_ROCCAT_H
+
+/*
+ * Copyright (c) 2010 Stefan Achatz <[email protected]>
+ */
+
+/*
+ * 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/hid.h>
+#include <linux/types.h>
+
+#define ROCCATIOCGREPSIZE _IOR('H', 0xf1, int)
+
+#ifdef __KERNEL__
+
+int roccat_connect(struct class *klass, struct hid_device *hid,
+		int report_size);
+void roccat_disconnect(int minor);
+int roccat_report_event(int minor, u8 const *data);
+
+#endif
+
+#endif
Signature · 1 line
1.7.3.4
#1 lore raw
Quoted 25 lines · Stefan Achatz
include/linux/roccat.h new file +19 -0
new file mode 100644
index 0000000..24e1ca0
@@ -0,0 +1,29 @@
+#ifndef __HID_ROCCAT_H
+#define __HID_ROCCAT_H
+
+/*
+ * Copyright (c) 2010 Stefan Achatz <[email protected]>
+ */
+
+/*
+ * 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/hid.h>
+#include <linux/types.h>
+
+#define ROCCATIOCGREPSIZE _IOR('H', 0xf1, int)
+

include/linux/roccat.h line 29

Quoted 10 lines
include/linux/roccat.h new file +10 -0
+#ifdef __KERNEL__
+
+int roccat_connect(struct class *klass, struct hid_device *hid,
+		int report_size);
+void roccat_disconnect(int minor);
+int roccat_report_event(int minor, u8 const *data);
+
+#endif
+
+#endif

I think something like include/linux/hid-roccat.h would be better here.

Thanks,

Signature · 2 lines
Jiri Kosina
SUSE Labs, Novell Inc.
author maintainer
#2 lore raw

[PATCH 9/8] HID: roccat: Renamed header roccat.h -> hid-roccat.h

It was desired that the header roccat.h should be named hid-roccat.h

---
 Documentation/ioctl/ioctl-number.txt |    2 +-
 drivers/hid/hid-roccat-arvo.c        |    2 +-
 drivers/hid/hid-roccat-kone.c        |    2 +-
 drivers/hid/hid-roccat-koneplus.c    |    2 +-
 drivers/hid/hid-roccat-kovaplus.c    |    2 +-
 drivers/hid/hid-roccat-pyra.c        |    2 +-
 drivers/hid/hid-roccat.c             |    2 +-
 include/linux/hid-roccat.h           |   29 +++++++++++++++++++++++++++++
 include/linux/roccat.h               |   29 -----------------------------
 9 files changed, 36 insertions(+), 36 deletions(-)
 create mode 100644 include/linux/hid-roccat.h
 delete mode 100644 include/linux/roccat.h
Documentation/ioctl/ioctl-number.txt +1 -1
index b0f1fa0..e68543f 100644
@@ -133,7 +133,7 @@ Code  Seq#(hex)	Include File		Comments
 'H'	C0-DF	net/bluetooth/hidp/hidp.h	conflict!
 'H'	C0-DF	net/bluetooth/cmtp/cmtp.h	conflict!
 'H'	C0-DF	net/bluetooth/bnep/bnep.h	conflict!
-'H'	F1	linux/roccat.h		<mailto:[email protected]>
+'H'	F1	linux/hid-roccat.h	<mailto:[email protected]>
 'I'	all	linux/isdn.h		conflict!
 'I'	00-0F	drivers/isdn/divert/isdn_divert.h	conflict!
 'I'	40-4F	linux/mISDNif.h		conflict!
drivers/hid/hid-roccat-arvo.c +1 -1
index 75f532f..2307471 100644
@@ -21,7 +21,7 @@
 #include <linux/hid.h>
 #include <linux/module.h>
 #include <linux/slab.h>
-#include <linux/roccat.h>
+#include <linux/hid-roccat.h>
 #include "hid-ids.h"
 #include "hid-roccat-common.h"
 #include "hid-roccat-arvo.h"
drivers/hid/hid-roccat-kone.c +1 -1
index d749796..a57838d 100644
@@ -30,7 +30,7 @@
 #include <linux/hid.h>
 #include <linux/module.h>
 #include <linux/slab.h>
-#include <linux/roccat.h>
+#include <linux/hid-roccat.h>
 #include "hid-ids.h"
 #include "hid-roccat-common.h"
 #include "hid-roccat-kone.h"
drivers/hid/hid-roccat-koneplus.c +1 -1
index ac20107..a8e2117 100644
@@ -21,7 +21,7 @@
 #include <linux/hid.h>
 #include <linux/module.h>
 #include <linux/slab.h>
-#include <linux/roccat.h>
+#include <linux/hid-roccat.h>
 #include "hid-ids.h"
 #include "hid-roccat-common.h"
 #include "hid-roccat-koneplus.h"
drivers/hid/hid-roccat-kovaplus.c +1 -1
index 4eeb62f..984be2f 100644
@@ -20,7 +20,7 @@
 #include <linux/hid.h>
 #include <linux/module.h>
 #include <linux/slab.h>
-#include <linux/roccat.h>
+#include <linux/hid-roccat.h>
 #include "hid-ids.h"
 #include "hid-roccat-common.h"
 #include "hid-roccat-kovaplus.h"
drivers/hid/hid-roccat-pyra.c +1 -1
index 02a7243..160f481 100644
@@ -22,7 +22,7 @@
 #include <linux/hid.h>
 #include <linux/module.h>
 #include <linux/slab.h>
-#include <linux/roccat.h>
+#include <linux/hid-roccat.h>
 #include "hid-ids.h"
 #include "hid-roccat-common.h"
 #include "hid-roccat-pyra.h"
drivers/hid/hid-roccat.c +1 -1
index bbe294c..5666e75 100644
@@ -26,7 +26,7 @@
 #include <linux/cdev.h>
 #include <linux/poll.h>
 #include <linux/sched.h>
-#include <linux/roccat.h>
+#include <linux/hid-roccat.h>
 
 #define ROCCAT_FIRST_MINOR 0
 #define ROCCAT_MAX_DEVICES 8
include/linux/hid-roccat.h new file +29 -0
new file mode 100644
index 0000000..24e1ca0
@@ -0,0 +1,29 @@
+#ifndef __HID_ROCCAT_H
+#define __HID_ROCCAT_H
+
+/*
+ * Copyright (c) 2010 Stefan Achatz <[email protected]>
+ */
+
+/*
+ * 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/hid.h>
+#include <linux/types.h>
+
+#define ROCCATIOCGREPSIZE _IOR('H', 0xf1, int)
+
+#ifdef __KERNEL__
+
+int roccat_connect(struct class *klass, struct hid_device *hid,
+		int report_size);
+void roccat_disconnect(int minor);
+int roccat_report_event(int minor, u8 const *data);
+
+#endif
+
+#endif
include/linux/roccat.h deleted +0 -29
deleted file mode 100644
index 24e1ca0..0000000
@@ -1,29 +0,0 @@
-#ifndef __HID_ROCCAT_H
-#define __HID_ROCCAT_H
-
-/*
- * Copyright (c) 2010 Stefan Achatz <[email protected]>
- */
-
-/*
- * 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/hid.h>
-#include <linux/types.h>
-
-#define ROCCATIOCGREPSIZE _IOR('H', 0xf1, int)
-
-#ifdef __KERNEL__
-
-int roccat_connect(struct class *klass, struct hid_device *hid,
-		int report_size);
-void roccat_disconnect(int minor);
-int roccat_report_event(int minor, u8 const *data);
-
-#endif
-
-#endif
Signature · 1 line
1.7.3.4