diff options
Diffstat (limited to 'drivers/gpu/drm/drm_platform.c')
-rw-r--r-- | drivers/gpu/drm/drm_platform.c | 75 |
1 files changed, 72 insertions, 3 deletions
diff --git a/drivers/gpu/drm/drm_platform.c b/drivers/gpu/drm/drm_platform.c index 92d1d0fb7b75..7223f06d8e58 100644 --- a/drivers/gpu/drm/drm_platform.c +++ b/drivers/gpu/drm/drm_platform.c | |||
@@ -109,8 +109,60 @@ err_g1: | |||
109 | } | 109 | } |
110 | EXPORT_SYMBOL(drm_get_platform_dev); | 110 | EXPORT_SYMBOL(drm_get_platform_dev); |
111 | 111 | ||
112 | static int drm_platform_get_irq(struct drm_device *dev) | ||
113 | { | ||
114 | return platform_get_irq(dev->platformdev, 0); | ||
115 | } | ||
116 | |||
117 | static const char *drm_platform_get_name(struct drm_device *dev) | ||
118 | { | ||
119 | return dev->platformdev->name; | ||
120 | } | ||
121 | |||
122 | static int drm_platform_set_busid(struct drm_device *dev, struct drm_master *master) | ||
123 | { | ||
124 | int len, ret; | ||
125 | |||
126 | master->unique_len = 10 + strlen(dev->platformdev->name); | ||
127 | master->unique = kmalloc(master->unique_len + 1, GFP_KERNEL); | ||
128 | |||
129 | if (master->unique == NULL) | ||
130 | return -ENOMEM; | ||
131 | |||
132 | len = snprintf(master->unique, master->unique_len, | ||
133 | "platform:%s", dev->platformdev->name); | ||
134 | |||
135 | if (len > master->unique_len) { | ||
136 | DRM_ERROR("Unique buffer overflowed\n"); | ||
137 | ret = -EINVAL; | ||
138 | goto err; | ||
139 | } | ||
140 | |||
141 | dev->devname = | ||
142 | kmalloc(strlen(dev->platformdev->name) + | ||
143 | master->unique_len + 2, GFP_KERNEL); | ||
144 | |||
145 | if (dev->devname == NULL) { | ||
146 | ret = -ENOMEM; | ||
147 | goto err; | ||
148 | } | ||
149 | |||
150 | sprintf(dev->devname, "%s@%s", dev->platformdev->name, | ||
151 | master->unique); | ||
152 | return 0; | ||
153 | err: | ||
154 | return ret; | ||
155 | } | ||
156 | |||
157 | static struct drm_bus drm_platform_bus = { | ||
158 | .bus_type = DRIVER_BUS_PLATFORM, | ||
159 | .get_irq = drm_platform_get_irq, | ||
160 | .get_name = drm_platform_get_name, | ||
161 | .set_busid = drm_platform_set_busid, | ||
162 | }; | ||
163 | |||
112 | /** | 164 | /** |
113 | * Platform device initialization. Called via drm_init at module load time, | 165 | * Platform device initialization. Called direct from modules. |
114 | * | 166 | * |
115 | * \return zero on success or a negative number on failure. | 167 | * \return zero on success or a negative number on failure. |
116 | * | 168 | * |
@@ -121,7 +173,24 @@ EXPORT_SYMBOL(drm_get_platform_dev); | |||
121 | * after the initialization for driver customization. | 173 | * after the initialization for driver customization. |
122 | */ | 174 | */ |
123 | 175 | ||
124 | int drm_platform_init(struct drm_driver *driver) | 176 | int drm_platform_init(struct drm_driver *driver, struct platform_device *platform_device) |
125 | { | 177 | { |
126 | return drm_get_platform_dev(driver->platform_device, driver); | 178 | DRM_DEBUG("\n"); |
179 | |||
180 | driver->kdriver.platform_device = platform_device; | ||
181 | driver->bus = &drm_platform_bus; | ||
182 | INIT_LIST_HEAD(&driver->device_list); | ||
183 | return drm_get_platform_dev(platform_device, driver); | ||
184 | } | ||
185 | EXPORT_SYMBOL(drm_platform_init); | ||
186 | |||
187 | void drm_platform_exit(struct drm_driver *driver, struct platform_device *platform_device) | ||
188 | { | ||
189 | struct drm_device *dev, *tmp; | ||
190 | DRM_DEBUG("\n"); | ||
191 | |||
192 | list_for_each_entry_safe(dev, tmp, &driver->device_list, driver_item) | ||
193 | drm_put_dev(dev); | ||
194 | DRM_INFO("Module unloaded\n"); | ||
127 | } | 195 | } |
196 | EXPORT_SYMBOL(drm_platform_exit); | ||