lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1548258448-62013-4-git-send-email-peng.hao2@zte.com.cn>
Date:   Wed, 23 Jan 2019 23:47:25 +0800
From:   Peng Hao <peng.hao2@....com.cn>
To:     gregkh@...uxfoundation.org, arnd@...db.de,
        andy.shevchenko@...il.com
Cc:     linux-kernel@...r.kernel.org, Peng Hao <peng.hao2@....com.cn>
Subject: [PATCH V3 3/6]  misc/pvpanic: add API for pvpanic driver framework

Add pvpanic_add/remove_device API. Follow-up patches will use them to
add/remove specific drivers into framework.

Signed-off-by: Peng Hao <peng.hao2@....com.cn>
---
 drivers/misc/pvpanic/pvpanic.c | 32 ++++++++++++++++++++++++++++++++
 drivers/misc/pvpanic/pvpanic.h | 14 ++++++++++++++
 2 files changed, 46 insertions(+)
 create mode 100644 drivers/misc/pvpanic/pvpanic.h

diff --git a/drivers/misc/pvpanic/pvpanic.c b/drivers/misc/pvpanic/pvpanic.c
index 227ab4e..f842ee4 100644
--- a/drivers/misc/pvpanic/pvpanic.c
+++ b/drivers/misc/pvpanic/pvpanic.c
@@ -48,6 +48,38 @@
 	.priority = 1, /* let this called before broken drm_fb_helper */
 };
 
+int pvpanic_add_device(struct device *dev, struct resource *res)
+{
+	struct platform_device *pdev;
+	int ret;
+
+	pdev = platform_device_alloc("pvpanic", -1);
+	if (!pdev)
+		return -ENOMEM;
+
+	pdev->dev.parent = dev;
+
+	ret = platform_device_add_resources(pdev, res, 1);
+	if (ret)
+		goto err;
+
+	ret = platform_device_add(pdev);
+	if (ret)
+		goto err;
+	pvpanic_data.pdev = pdev;
+
+	return 0;
+err:
+	platform_device_put(pdev);
+	return -1;
+}
+
+void pvpanic_remove_device(void)
+{
+	platform_device_unregister(pvpanic_data.pdev);
+	pvpanic_data.pdev = NULL;
+}
+
 static int pvpanic_platform_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
diff --git a/drivers/misc/pvpanic/pvpanic.h b/drivers/misc/pvpanic/pvpanic.h
new file mode 100644
index 0000000..a72ca59
--- /dev/null
+++ b/drivers/misc/pvpanic/pvpanic.h
@@ -0,0 +1,14 @@
+// SPDX-License-Identifier: GPL-2.0+
+/* pvpanic driver framework header file
+ *
+ * Copyright (C) 2019 ZTE Ltd.
+ * Author: Peng Hao <peng.hao2@....com.cn>
+ */
+
+#ifndef __DRIVERS_MISC_PVPANIC_H
+#define __DRIVERS_MISC_PVPANIC_H
+
+extern int pvpanic_add_device(struct device *dev, struct resource *res);
+extern void pvpanic_remove_device(void);
+
+#endif
-- 
1.8.3.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ