Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use class_create only with AJA_CREATE_DEVICE_NODES #28

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions ajadriver/linux/ntv2driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -2834,18 +2834,22 @@ static int reboot_handler(struct notifier_block *this, unsigned long code, void

static UWord deviceNumber;

#if defined(AJA_CREATE_DEVICE_NODES)
static int aja_ntv2_dev_uevent(struct device *dev, struct kobj_uevent_env *env)
{
add_uevent_var(env, "DEVMODE=%#o", 0666);
return 0;
}
#endif

static int __init aja_ntv2_module_init(void)
{
int res;
int i;
char versionString[STRMAX];
#if defined(AJA_CREATE_DEVICE_NODES)
struct class *ntv2_class = NULL;
#endif

for (i = 0; i < NTV2_MAXBOARDS; i++)
{
Expand Down Expand Up @@ -2889,6 +2893,7 @@ static int __init aja_ntv2_module_init(void)
getNTV2ModuleParams()->uart_max = NTV2_MAXBOARDS;
atomic_set(&getNTV2ModuleParams()->uart_index, 0);

#if defined(AJA_CREATE_DEVICE_NODES)
// Create device class
ntv2_class = class_create(THIS_MODULE, getNTV2ModuleParams()->driverName);
if (IS_ERR(ntv2_class))
Expand All @@ -2900,6 +2905,7 @@ static int __init aja_ntv2_module_init(void)
}
ntv2_class->dev_uevent = aja_ntv2_dev_uevent;
getNTV2ModuleParams()->class = ntv2_class;
#endif

// register device with kernel
MSG("%s: register chrdev %s\n",
Expand Down Expand Up @@ -2963,10 +2969,12 @@ static int __init aja_ntv2_module_init(void)
getNTV2ModuleParams()->driverName);
}

#if defined(AJA_CREATE_DEVICE_NODES)
if (getNTV2ModuleParams()->class)
{
class_destroy(getNTV2ModuleParams()->class);
}
#endif

if (getNTV2ModuleParams()->uart_driver)
{
Expand Down Expand Up @@ -3589,7 +3597,9 @@ static void __exit aja_ntv2_module_cleanup(void)

pci_unregister_driver(&ntv2_driver);

#if defined(AJA_CREATE_DEVICE_NODES)
class_destroy(getNTV2ModuleParams()->class);
#endif

uart_unregister_driver(&ntv2_uart_driver);

Expand Down