aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/video/fbsysfs.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/video/fbsysfs.c')
-rw-r--r--drivers/video/fbsysfs.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/drivers/video/fbsysfs.c b/drivers/video/fbsysfs.c
index 63b505cce4ec..1147b899f007 100644
--- a/drivers/video/fbsysfs.c
+++ b/drivers/video/fbsysfs.c
@@ -244,15 +244,15 @@ static ssize_t show_virtual(struct class_device *class_device, char *buf)
244 244
245/* Format for cmap is "%02x%c%4x%4x%4x\n" */ 245/* Format for cmap is "%02x%c%4x%4x%4x\n" */
246/* %02x entry %c transp %4x red %4x blue %4x green \n */ 246/* %02x entry %c transp %4x red %4x blue %4x green \n */
247/* 255 rows at 16 chars equals 4096 */ 247/* 256 rows at 16 chars equals 4096, the normal page size */
248/* PAGE_SIZE can be 4096 or larger */ 248/* the code will automatically adjust for different page sizes */
249static ssize_t store_cmap(struct class_device *class_device, const char *buf, 249static ssize_t store_cmap(struct class_device *class_device, const char *buf,
250 size_t count) 250 size_t count)
251{ 251{
252 struct fb_info *fb_info = (struct fb_info *)class_get_devdata(class_device); 252 struct fb_info *fb_info = (struct fb_info *)class_get_devdata(class_device);
253 int rc, i, start, length, transp = 0; 253 int rc, i, start, length, transp = 0;
254 254
255 if ((count > 4096) || ((count % 16) != 0) || (PAGE_SIZE < 4096)) 255 if ((count > PAGE_SIZE) || ((count % 16) != 0))
256 return -EINVAL; 256 return -EINVAL;
257 257
258 if (!fb_info->fbops->fb_setcolreg && !fb_info->fbops->fb_setcmap) 258 if (!fb_info->fbops->fb_setcolreg && !fb_info->fbops->fb_setcmap)
@@ -317,18 +317,18 @@ static ssize_t show_cmap(struct class_device *class_device, char *buf)
317 !fb_info->cmap.green) 317 !fb_info->cmap.green)
318 return -EINVAL; 318 return -EINVAL;
319 319
320 if (PAGE_SIZE < 4096) 320 if (fb_info->cmap.len > PAGE_SIZE / 16)
321 return -EINVAL; 321 return -EINVAL;
322 322
323 /* don't mess with the format, the buffer is PAGE_SIZE */ 323 /* don't mess with the format, the buffer is PAGE_SIZE */
324 /* 255 entries at 16 chars per line equals 4096 = PAGE_SIZE */ 324 /* 256 entries at 16 chars per line equals 4096 = PAGE_SIZE */
325 for (i = 0; i < fb_info->cmap.len; i++) { 325 for (i = 0; i < fb_info->cmap.len; i++) {
326 sprintf(&buf[ i * 16], "%02x%c%4x%4x%4x\n", i + fb_info->cmap.start, 326 snprintf(&buf[ i * 16], PAGE_SIZE - i * 16, "%02x%c%4x%4x%4x\n", i + fb_info->cmap.start,
327 ((fb_info->cmap.transp && fb_info->cmap.transp[i]) ? '*' : ' '), 327 ((fb_info->cmap.transp && fb_info->cmap.transp[i]) ? '*' : ' '),
328 fb_info->cmap.red[i], fb_info->cmap.blue[i], 328 fb_info->cmap.red[i], fb_info->cmap.blue[i],
329 fb_info->cmap.green[i]); 329 fb_info->cmap.green[i]);
330 } 330 }
331 return 4096; 331 return 16 * fb_info->cmap.len;
332} 332}
333 333
334static ssize_t store_blank(struct class_device *class_device, const char * buf, 334static ssize_t store_blank(struct class_device *class_device, const char * buf,
@@ -414,6 +414,13 @@ static ssize_t show_pan(struct class_device *class_device, char *buf)
414 fb_info->var.xoffset); 414 fb_info->var.xoffset);
415} 415}
416 416
417static ssize_t show_name(struct class_device *class_device, char *buf)
418{
419 struct fb_info *fb_info = (struct fb_info *)class_get_devdata(class_device);
420
421 return snprintf(buf, PAGE_SIZE, "%s\n", fb_info->fix.id);
422}
423
417static struct class_device_attribute class_device_attrs[] = { 424static struct class_device_attribute class_device_attrs[] = {
418 __ATTR(bits_per_pixel, S_IRUGO|S_IWUSR, show_bpp, store_bpp), 425 __ATTR(bits_per_pixel, S_IRUGO|S_IWUSR, show_bpp, store_bpp),
419 __ATTR(blank, S_IRUGO|S_IWUSR, show_blank, store_blank), 426 __ATTR(blank, S_IRUGO|S_IWUSR, show_blank, store_blank),
@@ -424,6 +431,7 @@ static struct class_device_attribute class_device_attrs[] = {
424 __ATTR(modes, S_IRUGO|S_IWUSR, show_modes, store_modes), 431 __ATTR(modes, S_IRUGO|S_IWUSR, show_modes, store_modes),
425 __ATTR(pan, S_IRUGO|S_IWUSR, show_pan, store_pan), 432 __ATTR(pan, S_IRUGO|S_IWUSR, show_pan, store_pan),
426 __ATTR(virtual_size, S_IRUGO|S_IWUSR, show_virtual, store_virtual), 433 __ATTR(virtual_size, S_IRUGO|S_IWUSR, show_virtual, store_virtual),
434 __ATTR(name, S_IRUGO, show_name, NULL),
427}; 435};
428 436
429int fb_init_class_device(struct fb_info *fb_info) 437int fb_init_class_device(struct fb_info *fb_info)