diff options
author | Dave Airlie <airlied@linux.ie> | 2009-09-25 16:39:00 -0400 |
---|---|---|
committer | Dave Airlie <airlied@linux.ie> | 2009-09-25 16:39:00 -0400 |
commit | 8ef8678c8f6131ca5941fa387cd3939c68c4f36d (patch) | |
tree | b937ca4a7763aec284f311947d323310dbdfbcfa /drivers/gpu | |
parent | adea4796cfb9b74d340f9e32ba523fb61305d0b7 (diff) |
drm/kms: protect against fb helper not being created.
If drivers don't init the fb helper on the connector, the cmdline
code won't work, but it shouldn't crash either.
Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'drivers/gpu')
-rw-r--r-- | drivers/gpu/drm/drm_crtc_helper.c | 13 | ||||
-rw-r--r-- | drivers/gpu/drm/drm_fb_helper.c | 14 |
2 files changed, 23 insertions, 4 deletions
diff --git a/drivers/gpu/drm/drm_crtc_helper.c b/drivers/gpu/drm/drm_crtc_helper.c index 82fd6e82450f..1fe4e1d344fd 100644 --- a/drivers/gpu/drm/drm_crtc_helper.c +++ b/drivers/gpu/drm/drm_crtc_helper.c | |||
@@ -279,16 +279,25 @@ static struct drm_display_mode *drm_has_preferred_mode(struct drm_connector *con | |||
279 | static bool drm_has_cmdline_mode(struct drm_connector *connector) | 279 | static bool drm_has_cmdline_mode(struct drm_connector *connector) |
280 | { | 280 | { |
281 | struct drm_fb_helper_connector *fb_help_conn = connector->fb_helper_private; | 281 | struct drm_fb_helper_connector *fb_help_conn = connector->fb_helper_private; |
282 | struct drm_fb_helper_cmdline_mode *cmdline_mode = &fb_help_conn->cmdline_mode; | 282 | struct drm_fb_helper_cmdline_mode *cmdline_mode; |
283 | |||
284 | if (!fb_help_conn) | ||
285 | return false; | ||
286 | |||
287 | cmdline_mode = &fb_help_conn->cmdline_mode; | ||
283 | return cmdline_mode->specified; | 288 | return cmdline_mode->specified; |
284 | } | 289 | } |
285 | 290 | ||
286 | static struct drm_display_mode *drm_pick_cmdline_mode(struct drm_connector *connector, int width, int height) | 291 | static struct drm_display_mode *drm_pick_cmdline_mode(struct drm_connector *connector, int width, int height) |
287 | { | 292 | { |
288 | struct drm_fb_helper_connector *fb_help_conn = connector->fb_helper_private; | 293 | struct drm_fb_helper_connector *fb_help_conn = connector->fb_helper_private; |
289 | struct drm_fb_helper_cmdline_mode *cmdline_mode = &fb_help_conn->cmdline_mode; | 294 | struct drm_fb_helper_cmdline_mode *cmdline_mode; |
290 | struct drm_display_mode *mode = NULL; | 295 | struct drm_display_mode *mode = NULL; |
291 | 296 | ||
297 | if (!fb_help_conn) | ||
298 | return mode; | ||
299 | |||
300 | cmdline_mode = &fb_help_conn->cmdline_mode; | ||
292 | if (cmdline_mode->specified == false) | 301 | if (cmdline_mode->specified == false) |
293 | return mode; | 302 | return mode; |
294 | 303 | ||
diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c index 2537d2e81849..10d810ef8faa 100644 --- a/drivers/gpu/drm/drm_fb_helper.c +++ b/drivers/gpu/drm/drm_fb_helper.c | |||
@@ -90,8 +90,12 @@ static bool drm_fb_helper_connector_parse_command_line(struct drm_connector *con | |||
90 | int i; | 90 | int i; |
91 | enum drm_connector_force force = DRM_FORCE_UNSPECIFIED; | 91 | enum drm_connector_force force = DRM_FORCE_UNSPECIFIED; |
92 | struct drm_fb_helper_connector *fb_help_conn = connector->fb_helper_private; | 92 | struct drm_fb_helper_connector *fb_help_conn = connector->fb_helper_private; |
93 | struct drm_fb_helper_cmdline_mode *cmdline_mode = &fb_help_conn->cmdline_mode; | 93 | struct drm_fb_helper_cmdline_mode *cmdline_mode; |
94 | 94 | ||
95 | if (!fb_help_conn) | ||
96 | return false; | ||
97 | |||
98 | cmdline_mode = &fb_help_conn->cmdline_mode; | ||
95 | if (!mode_option) | 99 | if (!mode_option) |
96 | mode_option = fb_mode_option; | 100 | mode_option = fb_mode_option; |
97 | 101 | ||
@@ -694,7 +698,13 @@ int drm_fb_helper_single_fb_probe(struct drm_device *dev, | |||
694 | /* first up get a count of crtcs now in use and new min/maxes width/heights */ | 698 | /* first up get a count of crtcs now in use and new min/maxes width/heights */ |
695 | list_for_each_entry(connector, &dev->mode_config.connector_list, head) { | 699 | list_for_each_entry(connector, &dev->mode_config.connector_list, head) { |
696 | struct drm_fb_helper_connector *fb_help_conn = connector->fb_helper_private; | 700 | struct drm_fb_helper_connector *fb_help_conn = connector->fb_helper_private; |
697 | struct drm_fb_helper_cmdline_mode *cmdline_mode = &fb_help_conn->cmdline_mode; | 701 | |
702 | struct drm_fb_helper_cmdline_mode *cmdline_mode; | ||
703 | |||
704 | if (!fb_help_conn) | ||
705 | continue; | ||
706 | |||
707 | cmdline_mode = &fb_help_conn->cmdline_mode; | ||
698 | 708 | ||
699 | if (cmdline_mode->bpp_specified) { | 709 | if (cmdline_mode->bpp_specified) { |
700 | switch (cmdline_mode->bpp) { | 710 | switch (cmdline_mode->bpp) { |