* [PATCH 1/2] drm/fb_helper: Use correct allocation count for arrays.
@ 2016-02-15 12:45 Maarten Lankhorst
2016-02-15 12:45 ` [PATCH 2/2] drm/fb_helper: Use add_one_connector in add_all_connectors Maarten Lankhorst
0 siblings, 1 reply; 3+ messages in thread
From: Maarten Lankhorst @ 2016-02-15 12:45 UTC (permalink / raw)
To: dri-devel
The fb helper iterates over connectors, using fb_helper->num_connectors
makes it more clear what size the allocations are.
Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
---
drivers/gpu/drm/drm_fb_helper.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index 46a2b1c55bd6..0893b82ce588 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -1989,13 +1989,13 @@ static void drm_setup_crtcs(struct drm_fb_helper *fb_helper)
width = dev->mode_config.max_width;
height = dev->mode_config.max_height;
- crtcs = kcalloc(dev->mode_config.num_connector,
+ crtcs = kcalloc(fb_helper->connector_count,
sizeof(struct drm_fb_helper_crtc *), GFP_KERNEL);
- modes = kcalloc(dev->mode_config.num_connector,
+ modes = kcalloc(fb_helper->connector_count,
sizeof(struct drm_display_mode *), GFP_KERNEL);
- offsets = kcalloc(dev->mode_config.num_connector,
+ offsets = kcalloc(fb_helper->connector_count,
sizeof(struct drm_fb_offset), GFP_KERNEL);
- enabled = kcalloc(dev->mode_config.num_connector,
+ enabled = kcalloc(fb_helper->connector_count,
sizeof(bool), GFP_KERNEL);
if (!crtcs || !modes || !enabled || !offsets) {
DRM_ERROR("Memory allocation failed\n");
@@ -2009,9 +2009,9 @@ static void drm_setup_crtcs(struct drm_fb_helper *fb_helper)
fb_helper->funcs->initial_config(fb_helper, crtcs, modes,
offsets,
enabled, width, height))) {
- memset(modes, 0, dev->mode_config.num_connector*sizeof(modes[0]));
- memset(crtcs, 0, dev->mode_config.num_connector*sizeof(crtcs[0]));
- memset(offsets, 0, dev->mode_config.num_connector*sizeof(offsets[0]));
+ memset(modes, 0, fb_helper->connector_count*sizeof(modes[0]));
+ memset(crtcs, 0, fb_helper->connector_count*sizeof(crtcs[0]));
+ memset(offsets, 0, fb_helper->connector_count*sizeof(offsets[0]));
if (!drm_target_cloned(fb_helper, modes, offsets,
enabled, width, height) &&
--
2.1.0
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply related [flat|nested] 3+ messages in thread* [PATCH 2/2] drm/fb_helper: Use add_one_connector in add_all_connectors.
2016-02-15 12:45 [PATCH 1/2] drm/fb_helper: Use correct allocation count for arrays Maarten Lankhorst
@ 2016-02-15 12:45 ` Maarten Lankhorst
2016-02-15 14:26 ` Daniel Vetter
0 siblings, 1 reply; 3+ messages in thread
From: Maarten Lankhorst @ 2016-02-15 12:45 UTC (permalink / raw)
To: dri-devel
add_all_connectors doesn't checks whether reallocation is needed, but add_one does.
Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
---
drivers/gpu/drm/drm_fb_helper.c | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)
diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index 0893b82ce588..855108e6e1bd 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -104,21 +104,17 @@ int drm_fb_helper_single_add_all_connectors(struct drm_fb_helper *fb_helper)
{
struct drm_device *dev = fb_helper->dev;
struct drm_connector *connector;
- int i;
+ int i, ret;
if (!drm_fbdev_emulation)
return 0;
mutex_lock(&dev->mode_config.mutex);
drm_for_each_connector(connector, dev) {
- struct drm_fb_helper_connector *fb_helper_connector;
+ ret = drm_fb_helper_add_one_connector(fb_helper, connector);
- fb_helper_connector = kzalloc(sizeof(struct drm_fb_helper_connector), GFP_KERNEL);
- if (!fb_helper_connector)
+ if (ret)
goto fail;
-
- fb_helper_connector->connector = connector;
- fb_helper->connector_info[fb_helper->connector_count++] = fb_helper_connector;
}
mutex_unlock(&dev->mode_config.mutex);
return 0;
@@ -130,7 +126,7 @@ fail:
fb_helper->connector_count = 0;
mutex_unlock(&dev->mode_config.mutex);
- return -ENOMEM;
+ return ret;
}
EXPORT_SYMBOL(drm_fb_helper_single_add_all_connectors);
--
2.1.0
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH 2/2] drm/fb_helper: Use add_one_connector in add_all_connectors.
2016-02-15 12:45 ` [PATCH 2/2] drm/fb_helper: Use add_one_connector in add_all_connectors Maarten Lankhorst
@ 2016-02-15 14:26 ` Daniel Vetter
0 siblings, 0 replies; 3+ messages in thread
From: Daniel Vetter @ 2016-02-15 14:26 UTC (permalink / raw)
To: Maarten Lankhorst; +Cc: dri-devel
On Mon, Feb 15, 2016 at 01:45:16PM +0100, Maarten Lankhorst wrote:
> add_all_connectors doesn't checks whether reallocation is needed, but add_one does.
>
> Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Both applied to drm-misc, thanks.
-Daniel
> ---
> drivers/gpu/drm/drm_fb_helper.c | 12 ++++--------
> 1 file changed, 4 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
> index 0893b82ce588..855108e6e1bd 100644
> --- a/drivers/gpu/drm/drm_fb_helper.c
> +++ b/drivers/gpu/drm/drm_fb_helper.c
> @@ -104,21 +104,17 @@ int drm_fb_helper_single_add_all_connectors(struct drm_fb_helper *fb_helper)
> {
> struct drm_device *dev = fb_helper->dev;
> struct drm_connector *connector;
> - int i;
> + int i, ret;
>
> if (!drm_fbdev_emulation)
> return 0;
>
> mutex_lock(&dev->mode_config.mutex);
> drm_for_each_connector(connector, dev) {
> - struct drm_fb_helper_connector *fb_helper_connector;
> + ret = drm_fb_helper_add_one_connector(fb_helper, connector);
>
> - fb_helper_connector = kzalloc(sizeof(struct drm_fb_helper_connector), GFP_KERNEL);
> - if (!fb_helper_connector)
> + if (ret)
> goto fail;
> -
> - fb_helper_connector->connector = connector;
> - fb_helper->connector_info[fb_helper->connector_count++] = fb_helper_connector;
> }
> mutex_unlock(&dev->mode_config.mutex);
> return 0;
> @@ -130,7 +126,7 @@ fail:
> fb_helper->connector_count = 0;
> mutex_unlock(&dev->mode_config.mutex);
>
> - return -ENOMEM;
> + return ret;
> }
> EXPORT_SYMBOL(drm_fb_helper_single_add_all_connectors);
>
> --
> 2.1.0
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-02-15 14:26 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-02-15 12:45 [PATCH 1/2] drm/fb_helper: Use correct allocation count for arrays Maarten Lankhorst
2016-02-15 12:45 ` [PATCH 2/2] drm/fb_helper: Use add_one_connector in add_all_connectors Maarten Lankhorst
2016-02-15 14:26 ` Daniel Vetter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox