diff options
Diffstat (limited to 'drivers/video/gbefb.c')
-rw-r--r-- | drivers/video/gbefb.c | 64 |
1 files changed, 37 insertions, 27 deletions
diff --git a/drivers/video/gbefb.c b/drivers/video/gbefb.c index d3c1922cb13a..d744c51807b7 100644 --- a/drivers/video/gbefb.c +++ b/drivers/video/gbefb.c | |||
@@ -11,7 +11,7 @@ | |||
11 | 11 | ||
12 | #include <linux/config.h> | 12 | #include <linux/config.h> |
13 | #include <linux/delay.h> | 13 | #include <linux/delay.h> |
14 | #include <linux/device.h> | 14 | #include <linux/platform_device.h> |
15 | #include <linux/dma-mapping.h> | 15 | #include <linux/dma-mapping.h> |
16 | #include <linux/errno.h> | 16 | #include <linux/errno.h> |
17 | #include <linux/fb.h> | 17 | #include <linux/fb.h> |
@@ -1038,7 +1038,6 @@ static struct fb_ops gbefb_ops = { | |||
1038 | .fb_fillrect = cfb_fillrect, | 1038 | .fb_fillrect = cfb_fillrect, |
1039 | .fb_copyarea = cfb_copyarea, | 1039 | .fb_copyarea = cfb_copyarea, |
1040 | .fb_imageblit = cfb_imageblit, | 1040 | .fb_imageblit = cfb_imageblit, |
1041 | .fb_cursor = soft_cursor, | ||
1042 | }; | 1041 | }; |
1043 | 1042 | ||
1044 | /* | 1043 | /* |
@@ -1106,12 +1105,11 @@ int __init gbefb_setup(char *options) | |||
1106 | return 0; | 1105 | return 0; |
1107 | } | 1106 | } |
1108 | 1107 | ||
1109 | static int __init gbefb_probe(struct device *dev) | 1108 | static int __init gbefb_probe(struct platform_device *p_dev) |
1110 | { | 1109 | { |
1111 | int i, ret = 0; | 1110 | int i, ret = 0; |
1112 | struct fb_info *info; | 1111 | struct fb_info *info; |
1113 | struct gbefb_par *par; | 1112 | struct gbefb_par *par; |
1114 | struct platform_device *p_dev = to_platform_device(dev); | ||
1115 | #ifndef MODULE | 1113 | #ifndef MODULE |
1116 | char *options = NULL; | 1114 | char *options = NULL; |
1117 | #endif | 1115 | #endif |
@@ -1126,7 +1124,7 @@ static int __init gbefb_probe(struct device *dev) | |||
1126 | gbefb_setup(options); | 1124 | gbefb_setup(options); |
1127 | #endif | 1125 | #endif |
1128 | 1126 | ||
1129 | if (!request_mem_region(GBE_BASE, sizeof(struct sgi_gbe), "GBE")) { | 1127 | if (!request_region(GBE_BASE, sizeof(struct sgi_gbe), "GBE")) { |
1130 | printk(KERN_ERR "gbefb: couldn't reserve mmio region\n"); | 1128 | printk(KERN_ERR "gbefb: couldn't reserve mmio region\n"); |
1131 | ret = -EBUSY; | 1129 | ret = -EBUSY; |
1132 | goto out_release_framebuffer; | 1130 | goto out_release_framebuffer; |
@@ -1152,12 +1150,24 @@ static int __init gbefb_probe(struct device *dev) | |||
1152 | if (gbe_mem_phys) { | 1150 | if (gbe_mem_phys) { |
1153 | /* memory was allocated at boot time */ | 1151 | /* memory was allocated at boot time */ |
1154 | gbe_mem = ioremap_nocache(gbe_mem_phys, gbe_mem_size); | 1152 | gbe_mem = ioremap_nocache(gbe_mem_phys, gbe_mem_size); |
1153 | if (!gbe_mem) { | ||
1154 | printk(KERN_ERR "gbefb: couldn't map framebuffer\n"); | ||
1155 | ret = -ENOMEM; | ||
1156 | goto out_tiles_free; | ||
1157 | } | ||
1158 | |||
1155 | gbe_dma_addr = 0; | 1159 | gbe_dma_addr = 0; |
1156 | } else { | 1160 | } else { |
1157 | /* try to allocate memory with the classical allocator | 1161 | /* try to allocate memory with the classical allocator |
1158 | * this has high chance to fail on low memory machines */ | 1162 | * this has high chance to fail on low memory machines */ |
1159 | gbe_mem = dma_alloc_coherent(NULL, gbe_mem_size, &gbe_dma_addr, | 1163 | gbe_mem = dma_alloc_coherent(NULL, gbe_mem_size, &gbe_dma_addr, |
1160 | GFP_KERNEL); | 1164 | GFP_KERNEL); |
1165 | if (!gbe_mem) { | ||
1166 | printk(KERN_ERR "gbefb: couldn't allocate framebuffer memory\n"); | ||
1167 | ret = -ENOMEM; | ||
1168 | goto out_tiles_free; | ||
1169 | } | ||
1170 | |||
1161 | gbe_mem_phys = (unsigned long) gbe_dma_addr; | 1171 | gbe_mem_phys = (unsigned long) gbe_dma_addr; |
1162 | } | 1172 | } |
1163 | 1173 | ||
@@ -1165,12 +1175,6 @@ static int __init gbefb_probe(struct device *dev) | |||
1165 | mtrr_add(gbe_mem_phys, gbe_mem_size, MTRR_TYPE_WRCOMB, 1); | 1175 | mtrr_add(gbe_mem_phys, gbe_mem_size, MTRR_TYPE_WRCOMB, 1); |
1166 | #endif | 1176 | #endif |
1167 | 1177 | ||
1168 | if (!gbe_mem) { | ||
1169 | printk(KERN_ERR "gbefb: couldn't map framebuffer\n"); | ||
1170 | ret = -ENXIO; | ||
1171 | goto out_tiles_free; | ||
1172 | } | ||
1173 | |||
1174 | /* map framebuffer memory into tiles table */ | 1178 | /* map framebuffer memory into tiles table */ |
1175 | for (i = 0; i < (gbe_mem_size >> TILE_SHIFT); i++) | 1179 | for (i = 0; i < (gbe_mem_size >> TILE_SHIFT); i++) |
1176 | gbe_tiles.cpu[i] = (gbe_mem_phys >> TILE_SHIFT) + i; | 1180 | gbe_tiles.cpu[i] = (gbe_mem_phys >> TILE_SHIFT) + i; |
@@ -1199,8 +1203,8 @@ static int __init gbefb_probe(struct device *dev) | |||
1199 | goto out_gbe_unmap; | 1203 | goto out_gbe_unmap; |
1200 | } | 1204 | } |
1201 | 1205 | ||
1202 | dev_set_drvdata(&p_dev->dev, info); | 1206 | platform_set_drvdata(p_dev, info); |
1203 | gbefb_create_sysfs(dev); | 1207 | gbefb_create_sysfs(&p_dev->dev); |
1204 | 1208 | ||
1205 | printk(KERN_INFO "fb%d: %s rev %d @ 0x%08x using %dkB memory\n", | 1209 | printk(KERN_INFO "fb%d: %s rev %d @ 0x%08x using %dkB memory\n", |
1206 | info->node, info->fix.id, gbe_revision, (unsigned) GBE_BASE, | 1210 | info->node, info->fix.id, gbe_revision, (unsigned) GBE_BASE, |
@@ -1226,10 +1230,9 @@ out_release_framebuffer: | |||
1226 | return ret; | 1230 | return ret; |
1227 | } | 1231 | } |
1228 | 1232 | ||
1229 | static int __devexit gbefb_remove(struct device* dev) | 1233 | static int __devexit gbefb_remove(struct platform_device* p_dev) |
1230 | { | 1234 | { |
1231 | struct platform_device *p_dev = to_platform_device(dev); | 1235 | struct fb_info *info = platform_get_drvdata(p_dev); |
1232 | struct fb_info *info = dev_get_drvdata(&p_dev->dev); | ||
1233 | 1236 | ||
1234 | unregister_framebuffer(info); | 1237 | unregister_framebuffer(info); |
1235 | gbe_turn_off(); | 1238 | gbe_turn_off(); |
@@ -1247,31 +1250,38 @@ static int __devexit gbefb_remove(struct device* dev) | |||
1247 | return 0; | 1250 | return 0; |
1248 | } | 1251 | } |
1249 | 1252 | ||
1250 | static struct device_driver gbefb_driver = { | 1253 | static struct platform_driver gbefb_driver = { |
1251 | .name = "gbefb", | ||
1252 | .bus = &platform_bus_type, | ||
1253 | .probe = gbefb_probe, | 1254 | .probe = gbefb_probe, |
1254 | .remove = __devexit_p(gbefb_remove), | 1255 | .remove = __devexit_p(gbefb_remove), |
1256 | .driver = { | ||
1257 | .name = "gbefb", | ||
1258 | }, | ||
1255 | }; | 1259 | }; |
1256 | 1260 | ||
1257 | static struct platform_device gbefb_device = { | 1261 | static struct platform_device *gbefb_device; |
1258 | .name = "gbefb", | ||
1259 | }; | ||
1260 | 1262 | ||
1261 | int __init gbefb_init(void) | 1263 | int __init gbefb_init(void) |
1262 | { | 1264 | { |
1263 | int ret = driver_register(&gbefb_driver); | 1265 | int ret = platform_driver_register(&gbefb_driver); |
1264 | if (!ret) { | 1266 | if (!ret) { |
1265 | ret = platform_device_register(&gbefb_device); | 1267 | gbefb_device = platform_device_alloc("gbefb", 0); |
1266 | if (ret) | 1268 | if (gbefb_device) { |
1267 | driver_unregister(&gbefb_driver); | 1269 | ret = platform_device_add(gbefb_device); |
1270 | } else { | ||
1271 | ret = -ENOMEM; | ||
1272 | } | ||
1273 | if (ret) { | ||
1274 | platform_device_put(gbefb_device); | ||
1275 | platform_driver_unregister(&gbefb_driver); | ||
1276 | } | ||
1268 | } | 1277 | } |
1269 | return ret; | 1278 | return ret; |
1270 | } | 1279 | } |
1271 | 1280 | ||
1272 | void __exit gbefb_exit(void) | 1281 | void __exit gbefb_exit(void) |
1273 | { | 1282 | { |
1274 | driver_unregister(&gbefb_driver); | 1283 | platform_device_unregister(gbefb_device); |
1284 | platform_driver_unregister(&gbefb_driver); | ||
1275 | } | 1285 | } |
1276 | 1286 | ||
1277 | module_init(gbefb_init); | 1287 | module_init(gbefb_init); |