aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/video/omap2
diff options
context:
space:
mode:
authorTomi Valkeinen <tomi.valkeinen@ti.com>2012-08-29 09:31:29 -0400
committerTomi Valkeinen <tomi.valkeinen@ti.com>2012-09-07 13:02:06 -0400
commit5e56ad44b4d2de688823933643ff80389f33daae (patch)
treea5ac466f270451a445b4f34ecba60e92c438c127 /drivers/video/omap2
parentab585254ba6b0f2931c0f77bd99e46f017fe685c (diff)
OMAPDSS: Taal: use devm_* functions
Use devm_ functions in panel-taal.c's probe when possible. Also reorder the initialization sequence so that devm_ allocations are done before things that require explicit freeing. This simplifies the probe and remove functions. Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Diffstat (limited to 'drivers/video/omap2')
-rw-r--r--drivers/video/omap2/displays/panel-taal.c118
1 files changed, 44 insertions, 74 deletions
diff --git a/drivers/video/omap2/displays/panel-taal.c b/drivers/video/omap2/displays/panel-taal.c
index 7b2d7bb79e68..125586490e37 100644
--- a/drivers/video/omap2/displays/panel-taal.c
+++ b/drivers/video/omap2/displays/panel-taal.c
@@ -865,10 +865,8 @@ static int taal_probe(struct omap_dss_device *dssdev)
865 865
866 dev_dbg(&dssdev->dev, "probe\n"); 866 dev_dbg(&dssdev->dev, "probe\n");
867 867
868 if (!panel_data || !panel_data->name) { 868 if (!panel_data || !panel_data->name)
869 r = -EINVAL; 869 return -EINVAL;
870 goto err;
871 }
872 870
873 for (i = 0; i < ARRAY_SIZE(panel_configs); i++) { 871 for (i = 0; i < ARRAY_SIZE(panel_configs); i++) {
874 if (strcmp(panel_data->name, panel_configs[i].name) == 0) { 872 if (strcmp(panel_data->name, panel_configs[i].name) == 0) {
@@ -877,21 +875,17 @@ static int taal_probe(struct omap_dss_device *dssdev)
877 } 875 }
878 } 876 }
879 877
880 if (!panel_config) { 878 if (!panel_config)
881 r = -EINVAL; 879 return -EINVAL;
882 goto err;
883 }
884 880
885 dssdev->panel.timings = panel_config->timings; 881 dssdev->panel.timings = panel_config->timings;
886 dssdev->panel.dsi_pix_fmt = OMAP_DSS_DSI_FMT_RGB888; 882 dssdev->panel.dsi_pix_fmt = OMAP_DSS_DSI_FMT_RGB888;
887 dssdev->caps = OMAP_DSS_DISPLAY_CAP_MANUAL_UPDATE | 883 dssdev->caps = OMAP_DSS_DISPLAY_CAP_MANUAL_UPDATE |
888 OMAP_DSS_DISPLAY_CAP_TEAR_ELIM; 884 OMAP_DSS_DISPLAY_CAP_TEAR_ELIM;
889 885
890 td = kzalloc(sizeof(*td), GFP_KERNEL); 886 td = devm_kzalloc(&dssdev->dev, sizeof(*td), GFP_KERNEL);
891 if (!td) { 887 if (!td)
892 r = -ENOMEM; 888 return -ENOMEM;
893 goto err;
894 }
895 td->dssdev = dssdev; 889 td->dssdev = dssdev;
896 td->panel_config = panel_config; 890 td->panel_config = panel_config;
897 td->esd_interval = panel_data->esd_interval; 891 td->esd_interval = panel_data->esd_interval;
@@ -902,26 +896,51 @@ static int taal_probe(struct omap_dss_device *dssdev)
902 896
903 atomic_set(&td->do_update, 0); 897 atomic_set(&td->do_update, 0);
904 898
905 td->workqueue = create_singlethread_workqueue("taal_esd");
906 if (td->workqueue == NULL) {
907 dev_err(&dssdev->dev, "can't create ESD workqueue\n");
908 r = -ENOMEM;
909 goto err_wq;
910 }
911 INIT_DELAYED_WORK_DEFERRABLE(&td->esd_work, taal_esd_work);
912 INIT_DELAYED_WORK(&td->ulps_work, taal_ulps_work);
913
914 dev_set_drvdata(&dssdev->dev, td); 899 dev_set_drvdata(&dssdev->dev, td);
915 900
916 if (gpio_is_valid(panel_data->reset_gpio)) { 901 if (gpio_is_valid(panel_data->reset_gpio)) {
917 r = gpio_request_one(panel_data->reset_gpio, GPIOF_OUT_INIT_LOW, 902 r = devm_gpio_request_one(&dssdev->dev, panel_data->reset_gpio,
918 "taal rst"); 903 GPIOF_OUT_INIT_LOW, "taal rst");
919 if (r) { 904 if (r) {
920 dev_err(&dssdev->dev, "failed to request reset gpio\n"); 905 dev_err(&dssdev->dev, "failed to request reset gpio\n");
921 goto err_rst_gpio; 906 return r;
922 } 907 }
923 } 908 }
924 909
910 if (panel_data->use_ext_te) {
911 int gpio = panel_data->ext_te_gpio;
912
913 r = devm_gpio_request_one(&dssdev->dev, gpio, GPIOF_IN,
914 "taal irq");
915 if (r) {
916 dev_err(&dssdev->dev, "GPIO request failed\n");
917 return r;
918 }
919
920 r = devm_request_irq(&dssdev->dev, gpio_to_irq(gpio),
921 taal_te_isr,
922 IRQF_TRIGGER_RISING,
923 "taal vsync", dssdev);
924
925 if (r) {
926 dev_err(&dssdev->dev, "IRQ request failed\n");
927 return r;
928 }
929
930 INIT_DELAYED_WORK_DEFERRABLE(&td->te_timeout_work,
931 taal_te_timeout_work_callback);
932
933 dev_dbg(&dssdev->dev, "Using GPIO TE\n");
934 }
935
936 td->workqueue = create_singlethread_workqueue("taal_esd");
937 if (td->workqueue == NULL) {
938 dev_err(&dssdev->dev, "can't create ESD workqueue\n");
939 return -ENOMEM;
940 }
941 INIT_DELAYED_WORK_DEFERRABLE(&td->esd_work, taal_esd_work);
942 INIT_DELAYED_WORK(&td->ulps_work, taal_ulps_work);
943
925 taal_hw_reset(dssdev); 944 taal_hw_reset(dssdev);
926 945
927 if (panel_data->use_dsi_backlight) { 946 if (panel_data->use_dsi_backlight) {
@@ -945,31 +964,6 @@ static int taal_probe(struct omap_dss_device *dssdev)
945 taal_bl_update_status(bldev); 964 taal_bl_update_status(bldev);
946 } 965 }
947 966
948 if (panel_data->use_ext_te) {
949 int gpio = panel_data->ext_te_gpio;
950
951 r = gpio_request_one(gpio, GPIOF_IN, "taal irq");
952 if (r) {
953 dev_err(&dssdev->dev, "GPIO request failed\n");
954 goto err_gpio;
955 }
956
957 r = request_irq(gpio_to_irq(gpio), taal_te_isr,
958 IRQF_TRIGGER_RISING,
959 "taal vsync", dssdev);
960
961 if (r) {
962 dev_err(&dssdev->dev, "IRQ request failed\n");
963 gpio_free(gpio);
964 goto err_irq;
965 }
966
967 INIT_DELAYED_WORK_DEFERRABLE(&td->te_timeout_work,
968 taal_te_timeout_work_callback);
969
970 dev_dbg(&dssdev->dev, "Using GPIO TE\n");
971 }
972
973 r = omap_dsi_request_vc(dssdev, &td->channel); 967 r = omap_dsi_request_vc(dssdev, &td->channel);
974 if (r) { 968 if (r) {
975 dev_err(&dssdev->dev, "failed to get virtual channel\n"); 969 dev_err(&dssdev->dev, "failed to get virtual channel\n");
@@ -993,29 +987,16 @@ static int taal_probe(struct omap_dss_device *dssdev)
993err_vc_id: 987err_vc_id:
994 omap_dsi_release_vc(dssdev, td->channel); 988 omap_dsi_release_vc(dssdev, td->channel);
995err_req_vc: 989err_req_vc:
996 if (panel_data->use_ext_te)
997 free_irq(gpio_to_irq(panel_data->ext_te_gpio), dssdev);
998err_irq:
999 if (panel_data->use_ext_te)
1000 gpio_free(panel_data->ext_te_gpio);
1001err_gpio:
1002 if (bldev != NULL) 990 if (bldev != NULL)
1003 backlight_device_unregister(bldev); 991 backlight_device_unregister(bldev);
1004err_bl: 992err_bl:
1005 if (gpio_is_valid(panel_data->reset_gpio))
1006 gpio_free(panel_data->reset_gpio);
1007err_rst_gpio:
1008 destroy_workqueue(td->workqueue); 993 destroy_workqueue(td->workqueue);
1009err_wq:
1010 kfree(td);
1011err:
1012 return r; 994 return r;
1013} 995}
1014 996
1015static void __exit taal_remove(struct omap_dss_device *dssdev) 997static void __exit taal_remove(struct omap_dss_device *dssdev)
1016{ 998{
1017 struct taal_data *td = dev_get_drvdata(&dssdev->dev); 999 struct taal_data *td = dev_get_drvdata(&dssdev->dev);
1018 struct nokia_dsi_panel_data *panel_data = get_panel_data(dssdev);
1019 struct backlight_device *bldev; 1000 struct backlight_device *bldev;
1020 1001
1021 dev_dbg(&dssdev->dev, "remove\n"); 1002 dev_dbg(&dssdev->dev, "remove\n");
@@ -1023,12 +1004,6 @@ static void __exit taal_remove(struct omap_dss_device *dssdev)
1023 sysfs_remove_group(&dssdev->dev.kobj, &taal_attr_group); 1004 sysfs_remove_group(&dssdev->dev.kobj, &taal_attr_group);
1024 omap_dsi_release_vc(dssdev, td->channel); 1005 omap_dsi_release_vc(dssdev, td->channel);
1025 1006
1026 if (panel_data->use_ext_te) {
1027 int gpio = panel_data->ext_te_gpio;
1028 free_irq(gpio_to_irq(gpio), dssdev);
1029 gpio_free(gpio);
1030 }
1031
1032 bldev = td->bldev; 1007 bldev = td->bldev;
1033 if (bldev != NULL) { 1008 if (bldev != NULL) {
1034 bldev->props.power = FB_BLANK_POWERDOWN; 1009 bldev->props.power = FB_BLANK_POWERDOWN;
@@ -1042,11 +1017,6 @@ static void __exit taal_remove(struct omap_dss_device *dssdev)
1042 1017
1043 /* reset, to be sure that the panel is in a valid state */ 1018 /* reset, to be sure that the panel is in a valid state */
1044 taal_hw_reset(dssdev); 1019 taal_hw_reset(dssdev);
1045
1046 if (gpio_is_valid(panel_data->reset_gpio))
1047 gpio_free(panel_data->reset_gpio);
1048
1049 kfree(td);
1050} 1020}
1051 1021
1052static int taal_power_on(struct omap_dss_device *dssdev) 1022static int taal_power_on(struct omap_dss_device *dssdev)