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

OMAPDSS: DPI: Allocate driver data

Allocate driver data(dpi_data) for each DPI instance. It's allocated in
omap_dpi_probe() when DT isn't used, and in dpi_init_port() when DT is used.
The dpi_data struct instance is no longer global. In the case of DPI ops, it's
retrieved from dpi_get_data_from_dssdev(). 'dssdev' passed by the connected
encoder/panel driver is a pointer to the 'output' member in dpi_data, and thus
can be used to get the DPI instance's driver data. In the case of probe/ini_port
functions, it's set as DPI/DSS device's private data embedded in the
platform_device struct.

Having dpi_data as private data of the platform device will not work for
multiple DPI instances in the DT case. This is because there is no corresponding
platform_device for DPI or SDI, they exist only as ports under the parent DSS
platform_device in the DT case. The DPI port's private data('data' member in
device_node struct) will later be used to store dpi_data.

Signed-off-by: Archit Taneja <archit@ti.com>
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>

authored by

Archit Taneja and committed by
Tomi Valkeinen
2ac6a1aa 630d2d0d

+36 -18
+32 -14
drivers/video/fbdev/omap2/dss/dpi.c
··· 54 54 bool port_initialized; 55 55 }; 56 56 57 - static struct dpi_data dpi_data; 57 + static struct dpi_data *dpi_get_data_from_dssdev(struct omap_dss_device *dssdev) 58 + { 59 + return container_of(dssdev, struct dpi_data, output); 60 + } 61 + 62 + static struct dpi_data *dpi_get_data_from_pdev(struct platform_device *pdev) 63 + { 64 + return dev_get_drvdata(&pdev->dev); 65 + } 58 66 59 67 static struct platform_device *dpi_get_dsidev(enum omap_channel channel) 60 68 { ··· 367 359 368 360 static int dpi_display_enable(struct omap_dss_device *dssdev) 369 361 { 370 - struct dpi_data *dpi = &dpi_data; 362 + struct dpi_data *dpi = dpi_get_data_from_dssdev(dssdev); 371 363 struct omap_dss_device *out = &dpi->output; 372 364 int r; 373 365 ··· 447 439 448 440 static void dpi_display_disable(struct omap_dss_device *dssdev) 449 441 { 450 - struct dpi_data *dpi = &dpi_data; 442 + struct dpi_data *dpi = dpi_get_data_from_dssdev(dssdev); 451 443 struct omap_overlay_manager *mgr = dpi->output.manager; 452 444 453 445 mutex_lock(&dpi->lock); ··· 471 463 static void dpi_set_timings(struct omap_dss_device *dssdev, 472 464 struct omap_video_timings *timings) 473 465 { 474 - struct dpi_data *dpi = &dpi_data; 466 + struct dpi_data *dpi = dpi_get_data_from_dssdev(dssdev); 475 467 476 468 DSSDBG("dpi_set_timings\n"); 477 469 ··· 485 477 static void dpi_get_timings(struct omap_dss_device *dssdev, 486 478 struct omap_video_timings *timings) 487 479 { 488 - struct dpi_data *dpi = &dpi_data; 480 + struct dpi_data *dpi = dpi_get_data_from_dssdev(dssdev); 489 481 490 482 mutex_lock(&dpi->lock); 491 483 ··· 497 489 static int dpi_check_timings(struct omap_dss_device *dssdev, 498 490 struct omap_video_timings *timings) 499 491 { 500 - struct dpi_data *dpi = &dpi_data; 492 + struct dpi_data *dpi = dpi_get_data_from_dssdev(dssdev); 501 493 struct omap_overlay_manager *mgr = dpi->output.manager; 502 494 int lck_div, pck_div; 503 495 unsigned long fck; ··· 537 529 538 530 static void dpi_set_data_lines(struct omap_dss_device *dssdev, int data_lines) 539 531 { 540 - struct dpi_data *dpi = &dpi_data; 532 + struct dpi_data *dpi = dpi_get_data_from_dssdev(dssdev); 541 533 542 534 mutex_lock(&dpi->lock); 543 535 ··· 643 635 static int dpi_connect(struct omap_dss_device *dssdev, 644 636 struct omap_dss_device *dst) 645 637 { 646 - struct dpi_data *dpi = &dpi_data; 638 + struct dpi_data *dpi = dpi_get_data_from_dssdev(dssdev); 647 639 struct omap_overlay_manager *mgr; 648 640 int r; 649 641 ··· 702 694 703 695 static void dpi_init_output(struct platform_device *pdev) 704 696 { 705 - struct dpi_data *dpi = &dpi_data; 697 + struct dpi_data *dpi = dpi_get_data_from_pdev(pdev); 706 698 struct omap_dss_device *out = &dpi->output; 707 699 708 700 out->dev = &pdev->dev; ··· 718 710 719 711 static void __exit dpi_uninit_output(struct platform_device *pdev) 720 712 { 721 - struct dpi_data *dpi = &dpi_data; 713 + struct dpi_data *dpi = dpi_get_data_from_pdev(pdev); 722 714 struct omap_dss_device *out = &dpi->output; 723 715 724 716 omapdss_unregister_output(out); ··· 726 718 727 719 static int omap_dpi_probe(struct platform_device *pdev) 728 720 { 729 - struct dpi_data *dpi = &dpi_data; 721 + struct dpi_data *dpi; 722 + 723 + dpi = devm_kzalloc(&pdev->dev, sizeof(*dpi), GFP_KERNEL); 724 + if (!dpi) 725 + return -ENOMEM; 730 726 731 727 dpi->pdev = pdev; 732 728 ··· 772 760 773 761 int __init dpi_init_port(struct platform_device *pdev, struct device_node *port) 774 762 { 775 - struct dpi_data *dpi = &dpi_data; 763 + struct dpi_data *dpi; 776 764 struct device_node *ep; 777 765 u32 datalines; 778 766 int r; 767 + 768 + dpi = devm_kzalloc(&pdev->dev, sizeof(*dpi), GFP_KERNEL); 769 + if (!dpi) 770 + return -ENOMEM; 779 771 780 772 ep = omapdss_of_get_next_endpoint(port, NULL); 781 773 if (!ep) ··· 803 787 804 788 dpi->port_initialized = true; 805 789 790 + dev_set_drvdata(&pdev->dev, dpi); 791 + 806 792 return 0; 807 793 808 794 err_datalines: ··· 813 795 return r; 814 796 } 815 797 816 - void __exit dpi_uninit_port(void) 798 + void __exit dpi_uninit_port(struct platform_device *pdev) 817 799 { 818 - struct dpi_data *dpi = &dpi_data; 800 + struct dpi_data *dpi = dpi_get_data_from_pdev(pdev); 819 801 820 802 if (!dpi->port_initialized) 821 803 return;
+3 -3
drivers/video/fbdev/omap2/dss/dss.c
··· 820 820 return 0; 821 821 } 822 822 823 - static void __exit dss_uninit_ports(void) 823 + static void __exit dss_uninit_ports(struct platform_device *pdev) 824 824 { 825 825 #ifdef CONFIG_OMAP2_DSS_DPI 826 - dpi_uninit_port(); 826 + dpi_uninit_port(pdev); 827 827 #endif 828 828 829 829 #ifdef CONFIG_OMAP2_DSS_SDI ··· 910 910 911 911 static int __exit omap_dsshw_remove(struct platform_device *pdev) 912 912 { 913 - dss_uninit_ports(); 913 + dss_uninit_ports(pdev); 914 914 915 915 pm_runtime_disable(&pdev->dev); 916 916
+1 -1
drivers/video/fbdev/omap2/dss/dss.h
··· 359 359 void dpi_uninit_platform_driver(void) __exit; 360 360 361 361 int dpi_init_port(struct platform_device *pdev, struct device_node *port) __init; 362 - void dpi_uninit_port(void) __exit; 362 + void dpi_uninit_port(struct platform_device *pdev) __exit; 363 363 364 364 /* DISPC */ 365 365 int dispc_init_platform_driver(void) __init;