rpmsg_char.c (69265bc12b6567c6aa9550a198b791e876fbfd2c) rpmsg_char.c (608edd96049b142de7944413cd7c24cb3f203d37)
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Copyright (C) 2022, STMicroelectronics
4 * Copyright (c) 2016, Linaro Ltd.
5 * Copyright (c) 2012, Michal Simek <monstr@monstr.eu>
6 * Copyright (c) 2012, PetaLogix
7 * Copyright (c) 2011, Texas Instruments, Inc.
8 * Copyright (c) 2011, Google, Inc.

--- 13 unchanged lines hidden (view full) ---

22#include <linux/poll.h>
23#include <linux/rpmsg.h>
24#include <linux/skbuff.h>
25#include <linux/slab.h>
26#include <linux/uaccess.h>
27#include <uapi/linux/rpmsg.h>
28
29#include "rpmsg_char.h"
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Copyright (C) 2022, STMicroelectronics
4 * Copyright (c) 2016, Linaro Ltd.
5 * Copyright (c) 2012, Michal Simek <monstr@monstr.eu>
6 * Copyright (c) 2012, PetaLogix
7 * Copyright (c) 2011, Texas Instruments, Inc.
8 * Copyright (c) 2011, Google, Inc.

--- 13 unchanged lines hidden (view full) ---

22#include <linux/poll.h>
23#include <linux/rpmsg.h>
24#include <linux/skbuff.h>
25#include <linux/slab.h>
26#include <linux/uaccess.h>
27#include <uapi/linux/rpmsg.h>
28
29#include "rpmsg_char.h"
30#include "rpmsg_internal.h"
30
31#define RPMSG_DEV_MAX (MINORMASK + 1)
32
33static dev_t rpmsg_major;
31
32#define RPMSG_DEV_MAX (MINORMASK + 1)
33
34static dev_t rpmsg_major;
34static struct class *rpmsg_class;
35
36static DEFINE_IDA(rpmsg_ctrl_ida);
37static DEFINE_IDA(rpmsg_ept_ida);
38static DEFINE_IDA(rpmsg_minor_ida);
39
40#define dev_to_eptdev(dev) container_of(dev, struct rpmsg_eptdev, dev)
41#define cdev_to_eptdev(i_cdev) container_of(i_cdev, struct rpmsg_eptdev, cdev)
42

--- 502 unchanged lines hidden (view full) ---

545 int ret;
546
547 ret = alloc_chrdev_region(&rpmsg_major, 0, RPMSG_DEV_MAX, "rpmsg");
548 if (ret < 0) {
549 pr_err("failed to allocate char dev region\n");
550 return ret;
551 }
552
35
36static DEFINE_IDA(rpmsg_ctrl_ida);
37static DEFINE_IDA(rpmsg_ept_ida);
38static DEFINE_IDA(rpmsg_minor_ida);
39
40#define dev_to_eptdev(dev) container_of(dev, struct rpmsg_eptdev, dev)
41#define cdev_to_eptdev(i_cdev) container_of(i_cdev, struct rpmsg_eptdev, cdev)
42

--- 502 unchanged lines hidden (view full) ---

545 int ret;
546
547 ret = alloc_chrdev_region(&rpmsg_major, 0, RPMSG_DEV_MAX, "rpmsg");
548 if (ret < 0) {
549 pr_err("failed to allocate char dev region\n");
550 return ret;
551 }
552
553 rpmsg_class = class_create(THIS_MODULE, "rpmsg");
554 if (IS_ERR(rpmsg_class)) {
555 pr_err("failed to create rpmsg class\n");
556 unregister_chrdev_region(rpmsg_major, RPMSG_DEV_MAX);
557 return PTR_ERR(rpmsg_class);
558 }
559
560 ret = register_rpmsg_driver(&rpmsg_chrdev_driver);
561 if (ret < 0) {
562 pr_err("failed to register rpmsg driver\n");
553 ret = register_rpmsg_driver(&rpmsg_chrdev_driver);
554 if (ret < 0) {
555 pr_err("failed to register rpmsg driver\n");
563 class_destroy(rpmsg_class);
564 unregister_chrdev_region(rpmsg_major, RPMSG_DEV_MAX);
565 }
566
567 return ret;
568}
569postcore_initcall(rpmsg_chrdev_init);
570
571static void rpmsg_chrdev_exit(void)
572{
573 unregister_rpmsg_driver(&rpmsg_chrdev_driver);
556 unregister_chrdev_region(rpmsg_major, RPMSG_DEV_MAX);
557 }
558
559 return ret;
560}
561postcore_initcall(rpmsg_chrdev_init);
562
563static void rpmsg_chrdev_exit(void)
564{
565 unregister_rpmsg_driver(&rpmsg_chrdev_driver);
574 class_destroy(rpmsg_class);
575 unregister_chrdev_region(rpmsg_major, RPMSG_DEV_MAX);
576}
577module_exit(rpmsg_chrdev_exit);
578
579MODULE_ALIAS("rpmsg:rpmsg_chrdev");
580MODULE_LICENSE("GPL v2");
566 unregister_chrdev_region(rpmsg_major, RPMSG_DEV_MAX);
567}
568module_exit(rpmsg_chrdev_exit);
569
570MODULE_ALIAS("rpmsg:rpmsg_chrdev");
571MODULE_LICENSE("GPL v2");