mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-23 02:05:57 +01:00
kernel module: format, use tab to indent.
This commit is contained in:
committed by
Ciro Santilli 包子露宪 六四事件 法轮功
parent
9f6ddbc436
commit
3b0a343647
@@ -33,42 +33,42 @@ static const struct file_operations fops = {
|
||||
|
||||
static void cleanup(int device_created)
|
||||
{
|
||||
if (device_created) {
|
||||
device_destroy(myclass, major);
|
||||
cdev_del(&mycdev);
|
||||
}
|
||||
if (myclass)
|
||||
class_destroy(myclass);
|
||||
if (major != -1)
|
||||
unregister_chrdev_region(major, 1);
|
||||
if (device_created) {
|
||||
device_destroy(myclass, major);
|
||||
cdev_del(&mycdev);
|
||||
}
|
||||
if (myclass)
|
||||
class_destroy(myclass);
|
||||
if (major != -1)
|
||||
unregister_chrdev_region(major, 1);
|
||||
}
|
||||
|
||||
static int myinit(void)
|
||||
{
|
||||
int device_created = 0;
|
||||
int device_created = 0;
|
||||
|
||||
/* cat /proc/devices */
|
||||
if (alloc_chrdev_region(&major, 0, 1, NAME "_proc") < 0)
|
||||
goto error;
|
||||
/* ls /sys/class */
|
||||
if ((myclass = class_create(THIS_MODULE, NAME "_sys")) == NULL)
|
||||
goto error;
|
||||
/* ls /dev/ */
|
||||
if (device_create(myclass, NULL, major, NULL, NAME "_dev") == NULL)
|
||||
goto error;
|
||||
device_created = 1;
|
||||
cdev_init(&mycdev, &fops);
|
||||
if (cdev_add(&mycdev, major, 1) == -1)
|
||||
goto error;
|
||||
return 0;
|
||||
/* cat /proc/devices */
|
||||
if (alloc_chrdev_region(&major, 0, 1, NAME "_proc") < 0)
|
||||
goto error;
|
||||
/* ls /sys/class */
|
||||
if ((myclass = class_create(THIS_MODULE, NAME "_sys")) == NULL)
|
||||
goto error;
|
||||
/* ls /dev/ */
|
||||
if (device_create(myclass, NULL, major, NULL, NAME "_dev") == NULL)
|
||||
goto error;
|
||||
device_created = 1;
|
||||
cdev_init(&mycdev, &fops);
|
||||
if (cdev_add(&mycdev, major, 1) == -1)
|
||||
goto error;
|
||||
return 0;
|
||||
error:
|
||||
cleanup(device_created);
|
||||
return -1;
|
||||
cleanup(device_created);
|
||||
return -1;
|
||||
}
|
||||
|
||||
static void myexit(void)
|
||||
{
|
||||
cleanup(1);
|
||||
cleanup(1);
|
||||
}
|
||||
|
||||
module_init(myinit)
|
||||
|
||||
Reference in New Issue
Block a user