Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

fbdev/xilinxfb: Fix improper casting and tighen up probe path

The xilinxfb driver is improperly casting a physical address to a
u32, and the probe routine isn't as straight forward as it could be.
(discovered by gcc spitting out warnings on most recent change to
xilinxfb driver).

This patch fixes the cast and simplifies the probe path.

Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
Tested-by: John Linn <john.linn@xilinx.com>

+23 -36
+23 -36
drivers/video/xilinxfb.c
··· 124 124 registers */ 125 125 126 126 dcr_host_t dcr_host; 127 - unsigned int dcr_start; 128 127 unsigned int dcr_len; 129 128 130 129 void *fb_virt; /* virt. address of the frame buffer */ ··· 324 325 drvdata->regs); 325 326 } 326 327 /* Put a banner in the log (for DEBUG) */ 327 - dev_dbg(dev, "fb: phys=%p, virt=%p, size=%x\n", 328 - (void *)drvdata->fb_phys, drvdata->fb_virt, fbsize); 328 + dev_dbg(dev, "fb: phys=%llx, virt=%p, size=%x\n", 329 + (unsigned long long)drvdata->fb_phys, drvdata->fb_virt, fbsize); 329 330 330 331 return 0; /* success */ 331 332 ··· 403 404 u32 tft_access; 404 405 struct xilinxfb_platform_data pdata; 405 406 struct resource res; 406 - int size, rc; 407 - int start = 0, len = 0; 408 - dcr_host_t dcr_host; 407 + int size, rc, start; 409 408 struct xilinxfb_drvdata *drvdata; 410 409 411 410 /* Copy with the default pdata (not a ptr reference!) */ ··· 411 414 412 415 dev_dbg(&op->dev, "xilinxfb_of_probe(%p, %p)\n", op, match); 413 416 417 + /* Allocate the driver data region */ 418 + drvdata = kzalloc(sizeof(*drvdata), GFP_KERNEL); 419 + if (!drvdata) { 420 + dev_err(&op->dev, "Couldn't allocate device private record\n"); 421 + return -ENOMEM; 422 + } 423 + 414 424 /* 415 425 * To check whether the core is connected directly to DCR or PLB 416 426 * interface and initialize the tft_access accordingly. 417 427 */ 418 428 p = (u32 *)of_get_property(op->node, "xlnx,dcr-splb-slave-if", NULL); 419 - 420 - if (p) 421 - tft_access = *p; 422 - else 423 - tft_access = 0; /* For backward compatibility */ 429 + tft_access = p ? *p : 0; 424 430 425 431 /* 426 432 * Fill the resource structure if its direct PLB interface 427 433 * otherwise fill the dcr_host structure. 428 434 */ 429 435 if (tft_access) { 436 + drvdata->flags |= PLB_ACCESS_FLAG; 430 437 rc = of_address_to_resource(op->node, 0, &res); 431 438 if (rc) { 432 439 dev_err(&op->dev, "invalid address\n"); 433 - return -ENODEV; 440 + goto err; 434 441 } 435 - 436 442 } else { 443 + res.start = 0; 437 444 start = dcr_resource_start(op->node, 0); 438 - len = dcr_resource_len(op->node, 0); 439 - dcr_host = dcr_map(op->node, start, len); 440 - if (!DCR_MAP_OK(dcr_host)) { 441 - dev_err(&op->dev, "invalid address\n"); 442 - return -ENODEV; 445 + drvdata->dcr_len = dcr_resource_len(op->node, 0); 446 + drvdata->dcr_host = dcr_map(op->node, start, drvdata->dcr_len); 447 + if (!DCR_MAP_OK(drvdata->dcr_host)) { 448 + dev_err(&op->dev, "invalid DCR address\n"); 449 + goto err; 443 450 } 444 451 } 445 452 ··· 468 467 if (of_find_property(op->node, "rotate-display", NULL)) 469 468 pdata.rotate_screen = 1; 470 469 471 - /* Allocate the driver data region */ 472 - drvdata = kzalloc(sizeof(*drvdata), GFP_KERNEL); 473 - if (!drvdata) { 474 - dev_err(&op->dev, "Couldn't allocate device private record\n"); 475 - return -ENOMEM; 476 - } 477 470 dev_set_drvdata(&op->dev, drvdata); 471 + return xilinxfb_assign(&op->dev, drvdata, res.start, &pdata); 478 472 479 - if (tft_access) 480 - drvdata->flags |= PLB_ACCESS_FLAG; 481 - 482 - /* Arguments are passed based on the interface */ 483 - if (drvdata->flags & PLB_ACCESS_FLAG) { 484 - return xilinxfb_assign(&op->dev, drvdata, res.start, &pdata); 485 - } else { 486 - drvdata->dcr_start = start; 487 - drvdata->dcr_len = len; 488 - drvdata->dcr_host = dcr_host; 489 - return xilinxfb_assign(&op->dev, drvdata, 0, &pdata); 490 - } 473 + err: 474 + kfree(drvdata); 475 + return -ENODEV; 491 476 } 492 477 493 478 static int __devexit xilinxfb_of_remove(struct of_device *op)