xref: /dflybsd-src/sys/dev/drm/drm_sysfs.c (revision d31c517d078953a876cc5ae53b51b5b1c8f06d30)
1c2ee31feSFrançois Tigeot /*
23a2096e8SFrançois Tigeot  * Copyright 2015-2018 François Tigeot <ftigeot@wolfpond.org>
3c2ee31feSFrançois Tigeot  * All Rights Reserved.
4c2ee31feSFrançois Tigeot  *
5c2ee31feSFrançois Tigeot  * Permission is hereby granted, free of charge, to any person obtaining a
6c2ee31feSFrançois Tigeot  * copy of this software and associated documentation files (the "Software"),
7c2ee31feSFrançois Tigeot  * to deal in the Software without restriction, including without limitation
8c2ee31feSFrançois Tigeot  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9c2ee31feSFrançois Tigeot  * and/or sell copies of the Software, and to permit persons to whom the
10c2ee31feSFrançois Tigeot  * Software is furnished to do so, subject to the following conditions:
11c2ee31feSFrançois Tigeot  *
12c2ee31feSFrançois Tigeot  * The above copyright notice and this permission notice (including the next
13c2ee31feSFrançois Tigeot  * paragraph) shall be included in all copies or substantial portions of the
14c2ee31feSFrançois Tigeot  * Software.
15c2ee31feSFrançois Tigeot  *
16c2ee31feSFrançois Tigeot  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17c2ee31feSFrançois Tigeot  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18c2ee31feSFrançois Tigeot  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
19c2ee31feSFrançois Tigeot  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20c2ee31feSFrançois Tigeot  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21c2ee31feSFrançois Tigeot  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
22c2ee31feSFrançois Tigeot  * IN THE SOFTWARE.
23c2ee31feSFrançois Tigeot  */
24c2ee31feSFrançois Tigeot 
253a2096e8SFrançois Tigeot #include <linux/device.h>
263a2096e8SFrançois Tigeot 
273a2096e8SFrançois Tigeot #include <drm/drm_sysfs.h>
28c2ee31feSFrançois Tigeot #include <drm/drmP.h>
292c9916cdSFrançois Tigeot #include "drm_internal.h"
30c2ee31feSFrançois Tigeot 
31c2ee31feSFrançois Tigeot int drm_sysfs_connector_add(struct drm_connector *connector)
32c2ee31feSFrançois Tigeot {
33*d31c517dSFrançois Tigeot 	struct drm_device *dev = connector->dev;
34*d31c517dSFrançois Tigeot 
35*d31c517dSFrançois Tigeot 	if (connector->kdev)
36*d31c517dSFrançois Tigeot 		return 0;
37*d31c517dSFrançois Tigeot 
38*d31c517dSFrançois Tigeot 	/* Linux uses device_create_with_groups() here */
39*d31c517dSFrançois Tigeot 	connector->kdev = kzalloc(sizeof(struct device), M_WAITOK);
40*d31c517dSFrançois Tigeot 	connector->kdev->kobj.name = kasprintf(GFP_KERNEL, "card%d-%s",
41*d31c517dSFrançois Tigeot 					       dev->primary->index,
42*d31c517dSFrançois Tigeot 					       connector->name);
43*d31c517dSFrançois Tigeot 	DRM_DEBUG("adding \"%s\" to sysfs\n", connector->name);
44*d31c517dSFrançois Tigeot 
45c2ee31feSFrançois Tigeot 	return 0;
46c2ee31feSFrançois Tigeot }
47c2ee31feSFrançois Tigeot 
48c2ee31feSFrançois Tigeot void drm_sysfs_connector_remove(struct drm_connector *connector)
49c2ee31feSFrançois Tigeot {
50*d31c517dSFrançois Tigeot 	DRM_DEBUG("removing \"%s\" from sysfs\n", connector->name);
51*d31c517dSFrançois Tigeot 
52*d31c517dSFrançois Tigeot 	if (connector->kdev)
53*d31c517dSFrançois Tigeot 		kfree(connector->kdev);
54c2ee31feSFrançois Tigeot }
55ba55f2f5SFrançois Tigeot 
56ba55f2f5SFrançois Tigeot void drm_sysfs_hotplug_event(struct drm_device *dev)
57ba55f2f5SFrançois Tigeot {
58ba55f2f5SFrançois Tigeot }
593a2096e8SFrançois Tigeot 
603a2096e8SFrançois Tigeot int drm_class_device_register(struct device *dev)
613a2096e8SFrançois Tigeot {
623a2096e8SFrançois Tigeot 	return 0;
633a2096e8SFrançois Tigeot }
643a2096e8SFrançois Tigeot 
653a2096e8SFrançois Tigeot void drm_class_device_unregister(struct device *dev)
663a2096e8SFrançois Tigeot {
673a2096e8SFrançois Tigeot }
68