Skip to content

Commit

Permalink
Merge branch 'for-6.6/roccat' into for-linus
Browse files Browse the repository at this point in the history
Constify class struct by Ivan Orlov and Greg Kroah-Hartman
  • Loading branch information
Benjamin Tissoires committed Aug 31, 2023
2 parents 18a0993 + 21168bd commit b949116
Show file tree
Hide file tree
Showing 12 changed files with 117 additions and 98 deletions.
20 changes: 11 additions & 9 deletions drivers/hid/hid-roccat-arvo.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@
#include "hid-roccat-common.h"
#include "hid-roccat-arvo.h"

static struct class *arvo_class;

static ssize_t arvo_sysfs_show_mode_key(struct device *dev,
struct device_attribute *attr, char *buf)
{
Expand Down Expand Up @@ -268,6 +266,11 @@ static const struct attribute_group *arvo_groups[] = {
NULL,
};

static const struct class arvo_class = {
.name = "arvo",
.dev_groups = arvo_groups,
};

static int arvo_init_arvo_device_struct(struct usb_device *usb_dev,
struct arvo_device *arvo)
{
Expand Down Expand Up @@ -309,7 +312,7 @@ 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");
Expand Down Expand Up @@ -433,21 +436,20 @@ static int __init arvo_init(void)
{
int retval;

arvo_class = class_create("arvo");
if (IS_ERR(arvo_class))
return PTR_ERR(arvo_class);
arvo_class->dev_groups = arvo_groups;
retval = class_register(&arvo_class);
if (retval)
return retval;

retval = hid_register_driver(&arvo_driver);
if (retval)
class_destroy(arvo_class);
class_unregister(&arvo_class);
return retval;
}

static void __exit arvo_exit(void)
{
hid_unregister_driver(&arvo_driver);
class_destroy(arvo_class);
class_unregister(&arvo_class);
}

module_init(arvo_init);
Expand Down
21 changes: 12 additions & 9 deletions drivers/hid/hid-roccat-isku.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@
#include "hid-roccat-common.h"
#include "hid-roccat-isku.h"

static struct class *isku_class;

static void isku_profile_activated(struct isku_device *isku, uint new_profile)
{
isku->actual_profile = new_profile;
Expand Down Expand Up @@ -248,6 +246,11 @@ static const struct attribute_group *isku_groups[] = {
NULL,
};

static const struct class isku_class = {
.name = "isku",
.dev_groups = isku_groups,
};

static int isku_init_isku_device_struct(struct usb_device *usb_dev,
struct isku_device *isku)
{
Expand Down Expand Up @@ -289,7 +292,7 @@ static int isku_init_specials(struct hid_device *hdev)
goto exit_free;
}

retval = roccat_connect(isku_class, hdev,
retval = roccat_connect(&isku_class, hdev,
sizeof(struct isku_roccat_report));
if (retval < 0) {
hid_err(hdev, "couldn't init char dev\n");
Expand Down Expand Up @@ -435,21 +438,21 @@ static struct hid_driver isku_driver = {
static int __init isku_init(void)
{
int retval;
isku_class = class_create("isku");
if (IS_ERR(isku_class))
return PTR_ERR(isku_class);
isku_class->dev_groups = isku_groups;

retval = class_register(&isku_class);
if (retval)
return retval;

retval = hid_register_driver(&isku_driver);
if (retval)
class_destroy(isku_class);
class_unregister(&isku_class);
return retval;
}

static void __exit isku_exit(void)
{
hid_unregister_driver(&isku_driver);
class_destroy(isku_class);
class_unregister(&isku_class);
}

module_init(isku_init);
Expand Down
24 changes: 13 additions & 11 deletions drivers/hid/hid-roccat-kone.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,6 @@ static int kone_send(struct usb_device *usb_dev, uint usb_command,
return ((len < 0) ? len : ((len != size) ? -EIO : 0));
}

/* kone_class is used for creating sysfs attributes via roccat char device */
static struct class *kone_class;

static void kone_set_settings_checksum(struct kone_settings *settings)
{
uint16_t checksum = 0;
Expand Down Expand Up @@ -657,6 +654,12 @@ static const struct attribute_group *kone_groups[] = {
NULL,
};

/* kone_class is used for creating sysfs attributes via roccat char device */
static const struct class kone_class = {
.name = "kone",
.dev_groups = kone_groups,
};

static int kone_init_kone_device_struct(struct usb_device *usb_dev,
struct kone_device *kone)
{
Expand Down Expand Up @@ -712,8 +715,8 @@ static int kone_init_specials(struct hid_device *hdev)
goto exit_free;
}

retval = roccat_connect(kone_class, hdev,
sizeof(struct kone_roccat_report));
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 */
Expand Down Expand Up @@ -890,21 +893,20 @@ static int __init kone_init(void)
int retval;

/* class name has to be same as driver name */
kone_class = class_create("kone");
if (IS_ERR(kone_class))
return PTR_ERR(kone_class);
kone_class->dev_groups = kone_groups;
retval = class_register(&kone_class);
if (retval)
return retval;

retval = hid_register_driver(&kone_driver);
if (retval)
class_destroy(kone_class);
class_unregister(&kone_class);
return retval;
}

static void __exit kone_exit(void)
{
hid_unregister_driver(&kone_driver);
class_destroy(kone_class);
class_unregister(&kone_class);
}

module_init(kone_init);
Expand Down
22 changes: 12 additions & 10 deletions drivers/hid/hid-roccat-koneplus.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@

static uint profile_numbers[5] = {0, 1, 2, 3, 4};

static struct class *koneplus_class;

static void koneplus_profile_activated(struct koneplus_device *koneplus,
uint new_profile)
{
Expand Down Expand Up @@ -356,6 +354,11 @@ static const struct attribute_group *koneplus_groups[] = {
NULL,
};

static const struct class koneplus_class = {
.name = "koneplus",
.dev_groups = koneplus_groups,
};

static int koneplus_init_koneplus_device_struct(struct usb_device *usb_dev,
struct koneplus_device *koneplus)
{
Expand Down Expand Up @@ -394,8 +397,8 @@ static int koneplus_init_specials(struct hid_device *hdev)
goto exit_free;
}

retval = roccat_connect(koneplus_class, hdev,
sizeof(struct koneplus_roccat_report));
retval = roccat_connect(&koneplus_class, hdev,
sizeof(struct koneplus_roccat_report));
if (retval < 0) {
hid_err(hdev, "couldn't init char dev\n");
} else {
Expand Down Expand Up @@ -549,21 +552,20 @@ static int __init koneplus_init(void)
int retval;

/* class name has to be same as driver name */
koneplus_class = class_create("koneplus");
if (IS_ERR(koneplus_class))
return PTR_ERR(koneplus_class);
koneplus_class->dev_groups = koneplus_groups;
retval = class_register(&koneplus_class);
if (retval)
return retval;

retval = hid_register_driver(&koneplus_driver);
if (retval)
class_destroy(koneplus_class);
class_unregister(&koneplus_class);
return retval;
}

static void __exit koneplus_exit(void)
{
hid_unregister_driver(&koneplus_driver);
class_destroy(koneplus_class);
class_unregister(&koneplus_class);
}

module_init(koneplus_init);
Expand Down
22 changes: 12 additions & 10 deletions drivers/hid/hid-roccat-konepure.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ struct konepure_mouse_report_button {
uint8_t unknown[2];
} __packed;

static struct class *konepure_class;

ROCCAT_COMMON2_BIN_ATTRIBUTE_W(control, 0x04, 0x03);
ROCCAT_COMMON2_BIN_ATTRIBUTE_RW(actual_profile, 0x05, 0x03);
ROCCAT_COMMON2_BIN_ATTRIBUTE_RW(profile_settings, 0x06, 0x1f);
Expand Down Expand Up @@ -72,6 +70,11 @@ static const struct attribute_group *konepure_groups[] = {
NULL,
};

static const struct class konepure_class = {
.name = "konepure",
.dev_groups = konepure_groups,
};

static int konepure_init_specials(struct hid_device *hdev)
{
struct usb_interface *intf = to_usb_interface(hdev->dev.parent);
Expand All @@ -98,8 +101,8 @@ static int konepure_init_specials(struct hid_device *hdev)
goto exit_free;
}

retval = roccat_connect(konepure_class, hdev,
sizeof(struct konepure_mouse_report_button));
retval = roccat_connect(&konepure_class, hdev,
sizeof(struct konepure_mouse_report_button));
if (retval < 0) {
hid_err(hdev, "couldn't init char dev\n");
} else {
Expand Down Expand Up @@ -207,21 +210,20 @@ static int __init konepure_init(void)
{
int retval;

konepure_class = class_create("konepure");
if (IS_ERR(konepure_class))
return PTR_ERR(konepure_class);
konepure_class->dev_groups = konepure_groups;
retval = class_register(&konepure_class);
if (retval)
return retval;

retval = hid_register_driver(&konepure_driver);
if (retval)
class_destroy(konepure_class);
class_unregister(&konepure_class);
return retval;
}

static void __exit konepure_exit(void)
{
hid_unregister_driver(&konepure_driver);
class_destroy(konepure_class);
class_unregister(&konepure_class);
}

module_init(konepure_init);
Expand Down
22 changes: 12 additions & 10 deletions drivers/hid/hid-roccat-kovaplus.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@

static uint profile_numbers[5] = {0, 1, 2, 3, 4};

static struct class *kovaplus_class;

static uint kovaplus_convert_event_cpi(uint value)
{
return (value == 7 ? 4 : (value == 4 ? 3 : value));
Expand Down Expand Up @@ -409,6 +407,11 @@ static const struct attribute_group *kovaplus_groups[] = {
NULL,
};

static const struct class kovaplus_class = {
.name = "kovaplus",
.dev_groups = kovaplus_groups,
};

static int kovaplus_init_kovaplus_device_struct(struct usb_device *usb_dev,
struct kovaplus_device *kovaplus)
{
Expand Down Expand Up @@ -463,8 +466,8 @@ static int kovaplus_init_specials(struct hid_device *hdev)
goto exit_free;
}

retval = roccat_connect(kovaplus_class, hdev,
sizeof(struct kovaplus_roccat_report));
retval = roccat_connect(&kovaplus_class, hdev,
sizeof(struct kovaplus_roccat_report));
if (retval < 0) {
hid_err(hdev, "couldn't init char dev\n");
} else {
Expand Down Expand Up @@ -638,21 +641,20 @@ static int __init kovaplus_init(void)
{
int retval;

kovaplus_class = class_create("kovaplus");
if (IS_ERR(kovaplus_class))
return PTR_ERR(kovaplus_class);
kovaplus_class->dev_groups = kovaplus_groups;
retval = class_register(&kovaplus_class);
if (retval)
return retval;

retval = hid_register_driver(&kovaplus_driver);
if (retval)
class_destroy(kovaplus_class);
class_unregister(&kovaplus_class);
return retval;
}

static void __exit kovaplus_exit(void)
{
hid_unregister_driver(&kovaplus_driver);
class_destroy(kovaplus_class);
class_unregister(&kovaplus_class);
}

module_init(kovaplus_init);
Expand Down
Loading

0 comments on commit b949116

Please sign in to comment.