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

drm/panel: simple: Add proper definition for prepare and unprepare

Move out code from enable and disable routines to prepare
and unprepare routines, so that functionality is properly
distributed across all the panel functions.

Signed-off-by: Ajay Kumar <ajaykumar.rs@samsung.com>
Signed-off-by: Thierry Reding <treding@nvidia.com>

authored by

Ajay Kumar and committed by
Thierry Reding
613a633e 1a670e7b

+27 -10
+27 -10
drivers/gpu/drm/panel/panel-simple.c
··· 47 47 48 48 struct panel_simple { 49 49 struct drm_panel base; 50 + bool prepared; 50 51 bool enabled; 51 52 52 53 const struct panel_desc *desc; ··· 109 108 backlight_update_status(p->backlight); 110 109 } 111 110 112 - if (p->enable_gpio) 113 - gpiod_set_value_cansleep(p->enable_gpio, 0); 114 - 115 - regulator_disable(p->supply); 116 111 p->enabled = false; 117 112 118 113 return 0; ··· 116 119 117 120 static int panel_simple_unprepare(struct drm_panel *panel) 118 121 { 122 + struct panel_simple *p = to_panel_simple(panel); 123 + 124 + if (!p->prepared) 125 + return 0; 126 + 127 + if (p->enable_gpio) 128 + gpiod_set_value_cansleep(p->enable_gpio, 0); 129 + 130 + regulator_disable(p->supply); 131 + 132 + p->prepared = false; 133 + 119 134 return 0; 120 135 } 121 136 122 137 static int panel_simple_prepare(struct drm_panel *panel) 123 138 { 124 - return 0; 125 - } 126 - 127 - static int panel_simple_enable(struct drm_panel *panel) 128 - { 129 139 struct panel_simple *p = to_panel_simple(panel); 130 140 int err; 131 141 132 - if (p->enabled) 142 + if (p->prepared) 133 143 return 0; 134 144 135 145 err = regulator_enable(p->supply); ··· 147 143 148 144 if (p->enable_gpio) 149 145 gpiod_set_value_cansleep(p->enable_gpio, 1); 146 + 147 + p->prepared = true; 148 + 149 + return 0; 150 + } 151 + 152 + static int panel_simple_enable(struct drm_panel *panel) 153 + { 154 + struct panel_simple *p = to_panel_simple(panel); 155 + 156 + if (p->enabled) 157 + return 0; 150 158 151 159 if (p->backlight) { 152 160 p->backlight->props.power = FB_BLANK_UNBLANK; ··· 210 194 return -ENOMEM; 211 195 212 196 panel->enabled = false; 197 + panel->prepared = false; 213 198 panel->desc = desc; 214 199 215 200 panel->supply = devm_regulator_get(dev, "power");