vt: vt_ioctl: fix VT_DISALLOCATE freeing in-use virtual console
[linux/fpc-iii.git] / drivers / gpu / drm / arc / arcpgu_hdmi.c
blob977dfa55162ffb82af90b2c177e44f83f2502e6c
1 /*
2 * ARC PGU DRM driver.
4 * Copyright (C) 2016 Synopsys, Inc. (www.synopsys.com)
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
17 #include <drm/drm_crtc.h>
18 #include <drm/drm_encoder.h>
19 #include <drm/drm_device.h>
21 #include "arcpgu.h"
23 static struct drm_encoder_funcs arcpgu_drm_encoder_funcs = {
24 .destroy = drm_encoder_cleanup,
27 int arcpgu_drm_hdmi_init(struct drm_device *drm, struct device_node *np)
29 struct drm_encoder *encoder;
30 struct drm_bridge *bridge;
32 int ret = 0;
34 encoder = devm_kzalloc(drm->dev, sizeof(*encoder), GFP_KERNEL);
35 if (encoder == NULL)
36 return -ENOMEM;
38 /* Locate drm bridge from the hdmi encoder DT node */
39 bridge = of_drm_find_bridge(np);
40 if (!bridge)
41 return -EPROBE_DEFER;
43 encoder->possible_crtcs = 1;
44 encoder->possible_clones = 0;
45 ret = drm_encoder_init(drm, encoder, &arcpgu_drm_encoder_funcs,
46 DRM_MODE_ENCODER_TMDS, NULL);
47 if (ret)
48 return ret;
50 /* Link drm_bridge to encoder */
51 ret = drm_bridge_attach(encoder, bridge, NULL);
52 if (ret)
53 drm_encoder_cleanup(encoder);
55 return ret;