mirror of https://gitee.com/openkylin/linux.git
staging: unisys: refactor visorchipset_file_init()
Fix the declaration so it is a single line. Fix CamelCase parameter names: MajorDev => major_dev pControlVm_channel => controlvm_channel Remove the unnecessary gotos and just return directly in error cases. Fix the last error condition so it returns the result of cdev_add() instead of always zero. Signed-off-by: Ken Depro <kenneth.depro@unisys.com> Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
be080dc1af
commit
7381312852
|
@ -57,13 +57,12 @@ static const struct file_operations visorchipset_fops = {
|
||||||
.mmap = visorchipset_mmap,
|
.mmap = visorchipset_mmap,
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
int visorchipset_file_init(dev_t major_dev, VISORCHANNEL **controlvm_channel)
|
||||||
visorchipset_file_init(dev_t majorDev, VISORCHANNEL **pControlVm_channel)
|
|
||||||
{
|
{
|
||||||
int rc = -1;
|
int rc = 0;
|
||||||
|
|
||||||
PControlVm_channel = pControlVm_channel;
|
PControlVm_channel = controlvm_channel;
|
||||||
MajorDev = majorDev;
|
MajorDev = major_dev;
|
||||||
cdev_init(&Cdev, &visorchipset_fops);
|
cdev_init(&Cdev, &visorchipset_fops);
|
||||||
Cdev.owner = THIS_MODULE;
|
Cdev.owner = THIS_MODULE;
|
||||||
if (MAJOR(MajorDev) == 0) {
|
if (MAJOR(MajorDev) == 0) {
|
||||||
|
@ -71,7 +70,7 @@ visorchipset_file_init(dev_t majorDev, VISORCHANNEL **pControlVm_channel)
|
||||||
if (alloc_chrdev_region(&MajorDev, 0, 1, MYDRVNAME) < 0) {
|
if (alloc_chrdev_region(&MajorDev, 0, 1, MYDRVNAME) < 0) {
|
||||||
ERRDRV("Unable to allocate+register char device %s",
|
ERRDRV("Unable to allocate+register char device %s",
|
||||||
MYDRVNAME);
|
MYDRVNAME);
|
||||||
goto Away;
|
return -1;
|
||||||
}
|
}
|
||||||
Registered = TRUE;
|
Registered = TRUE;
|
||||||
INFODRV("New major number %d registered\n", MAJOR(MajorDev));
|
INFODRV("New major number %d registered\n", MAJOR(MajorDev));
|
||||||
|
@ -79,20 +78,19 @@ visorchipset_file_init(dev_t majorDev, VISORCHANNEL **pControlVm_channel)
|
||||||
/* static major device number registration required */
|
/* static major device number registration required */
|
||||||
if (register_chrdev_region(MajorDev, 1, MYDRVNAME) < 0) {
|
if (register_chrdev_region(MajorDev, 1, MYDRVNAME) < 0) {
|
||||||
ERRDRV("Unable to register char device %s", MYDRVNAME);
|
ERRDRV("Unable to register char device %s", MYDRVNAME);
|
||||||
goto Away;
|
return -1;
|
||||||
}
|
}
|
||||||
Registered = TRUE;
|
Registered = TRUE;
|
||||||
INFODRV("Static major number %d registered\n", MAJOR(MajorDev));
|
INFODRV("Static major number %d registered\n", MAJOR(MajorDev));
|
||||||
}
|
}
|
||||||
if (cdev_add(&Cdev, MKDEV(MAJOR(MajorDev), 0), 1) < 0) {
|
rc = cdev_add(&Cdev, MKDEV(MAJOR(MajorDev), 0), 1);
|
||||||
|
if (rc < 0) {
|
||||||
ERRDRV("failed to create char device: (status=%d)\n", rc);
|
ERRDRV("failed to create char device: (status=%d)\n", rc);
|
||||||
goto Away;
|
return -1;
|
||||||
}
|
}
|
||||||
INFODRV("Registered char device for %s (major=%d)",
|
INFODRV("Registered char device for %s (major=%d)",
|
||||||
MYDRVNAME, MAJOR(MajorDev));
|
MYDRVNAME, MAJOR(MajorDev));
|
||||||
rc = 0;
|
return 0;
|
||||||
Away:
|
|
||||||
return rc;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
|
|
||||||
#include "globals.h"
|
#include "globals.h"
|
||||||
|
|
||||||
int visorchipset_file_init(dev_t majorDev, VISORCHANNEL **pControlVm_channel);
|
int visorchipset_file_init(dev_t major_dev, VISORCHANNEL **controlvm_channel);
|
||||||
void visorchipset_file_cleanup(void);
|
void visorchipset_file_cleanup(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue