Skip to content

Commit

Permalink
BCM2708_VCIO : Add automatic creation of device node
Browse files Browse the repository at this point in the history
  • Loading branch information
trevd authored and popcornmix committed Feb 7, 2015
1 parent 5f1c4a0 commit 7fa07e9
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
12 changes: 11 additions & 1 deletion arch/arm/mach-bcm2708/vcio.c
Expand Up @@ -61,7 +61,7 @@
#define MBOX_DATA28_LSB(msg) (((uint32_t)msg) >> 4)

#define MBOX_MAGIC 0xd0d0c0de

static struct class *vcio_class = NULL;
struct vc_mailbox {
struct device *dev; /* parent device */
void __iomem *status;
Expand Down Expand Up @@ -421,6 +421,13 @@ static int bcm_vcio_probe(struct platform_device *pdev)
"Failed registering the character device %d\n", ret);
return ret;
}
vcio_class = class_create(THIS_MODULE, BCM_VCIO_DRIVER_NAME);
if (IS_ERR(vcio_class)) {
ret = PTR_ERR(vcio_class);
return ret ;
}
device_create(vcio_class, NULL, MKDEV(MAJOR_NUM, 0), NULL,
"vcio");
}
return ret;
}
Expand Down Expand Up @@ -462,6 +469,9 @@ static int __init bcm_mbox_init(void)

static void __exit bcm_mbox_exit(void)
{
device_destroy(vcio_class,MKDEV(MAJOR_NUM, 0));
class_destroy(vcio_class);
unregister_chrdev(MAJOR_NUM, DEVICE_FILE_NAME);
platform_driver_unregister(&bcm_mbox_driver);
}

Expand Down
12 changes: 11 additions & 1 deletion arch/arm/mach-bcm2709/vcio.c
Expand Up @@ -61,7 +61,7 @@
#define MBOX_DATA28_LSB(msg) (((uint32_t)msg) >> 4)

#define MBOX_MAGIC 0xd0d0c0de

static struct class *vcio_class = NULL;
struct vc_mailbox {
struct device *dev; /* parent device */
void __iomem *status;
Expand Down Expand Up @@ -421,6 +421,13 @@ static int bcm_vcio_probe(struct platform_device *pdev)
"Failed registering the character device %d\n", ret);
return ret;
}
vcio_class = class_create(THIS_MODULE, BCM_VCIO_DRIVER_NAME);
if (IS_ERR(vcio_class)) {
ret = PTR_ERR(vcio_class);
return ret ;
}
device_create(vcio_class, NULL, MKDEV(MAJOR_NUM, 0), NULL,
"vcio");
}
return ret;
}
Expand Down Expand Up @@ -462,6 +469,9 @@ static int __init bcm_mbox_init(void)

static void __exit bcm_mbox_exit(void)
{
device_destroy(vcio_class,MKDEV(MAJOR_NUM, 0));
class_destroy(vcio_class);
unregister_chrdev(MAJOR_NUM, DEVICE_FILE_NAME);
platform_driver_unregister(&bcm_mbox_driver);
}

Expand Down

0 comments on commit 7fa07e9

Please sign in to comment.