diff mbox

[2/7] drm/udl: fix Bpp calculation in dumb_create()

Message ID 1390245989-13280-2-git-send-email-dh.herrmann@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

David Herrmann Jan. 20, 2014, 7:26 p.m. UTC
Probably a typo.. we obviously need "(bpp + 7) / 8" instead of
"(bpp + 1) / 8". Unlikely to be hit in any sane code, but lets be safe.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
---
 drivers/gpu/drm/udl/udl_gem.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Daniel Vetter Jan. 21, 2014, 9:38 a.m. UTC | #1
On Mon, Jan 20, 2014 at 08:26:24PM +0100, David Herrmann wrote:
> Probably a typo.. we obviously need "(bpp + 7) / 8" instead of
> "(bpp + 1) / 8". Unlikely to be hit in any sane code, but lets be safe.
> 
> Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
> ---
>  drivers/gpu/drm/udl/udl_gem.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/udl/udl_gem.c b/drivers/gpu/drm/udl/udl_gem.c
> index 8d67b94..df963a1 100644
> --- a/drivers/gpu/drm/udl/udl_gem.c
> +++ b/drivers/gpu/drm/udl/udl_gem.c
> @@ -60,7 +60,7 @@ int udl_dumb_create(struct drm_file *file,
>  		    struct drm_device *dev,
>  		    struct drm_mode_create_dumb *args)
>  {
> -	args->pitch = args->width * ((args->bpp + 1) / 8);
> +	args->pitch = args->width * ((args->bpp + 7) / 8);

DIV_ROUND_UP?

>  	args->size = args->pitch * args->height;
>  	return udl_gem_create(file, dev,
>  			      args->size, &args->handle);
> -- 
> 1.8.5.3
>
David Herrmann Jan. 21, 2014, 11:13 a.m. UTC | #2
Hi

On Tue, Jan 21, 2014 at 10:38 AM, Daniel Vetter <daniel@ffwll.ch> wrote:
> On Mon, Jan 20, 2014 at 08:26:24PM +0100, David Herrmann wrote:
>> Probably a typo.. we obviously need "(bpp + 7) / 8" instead of
>> "(bpp + 1) / 8". Unlikely to be hit in any sane code, but lets be safe.
>>
>> Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
>> ---
>>  drivers/gpu/drm/udl/udl_gem.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/gpu/drm/udl/udl_gem.c b/drivers/gpu/drm/udl/udl_gem.c
>> index 8d67b94..df963a1 100644
>> --- a/drivers/gpu/drm/udl/udl_gem.c
>> +++ b/drivers/gpu/drm/udl/udl_gem.c
>> @@ -60,7 +60,7 @@ int udl_dumb_create(struct drm_file *file,
>>                   struct drm_device *dev,
>>                   struct drm_mode_create_dumb *args)
>>  {
>> -     args->pitch = args->width * ((args->bpp + 1) / 8);
>> +     args->pitch = args->width * ((args->bpp + 7) / 8);
>
> DIV_ROUND_UP?

Hm, udl doesn't use this anywhere, so I'd like to keep consistency. I
guess I will replace all those occurrences by DIV_ROUND_UP() and meld
it into this fix (except if someone wants two separate commits?).

Thanks
David

>>       args->size = args->pitch * args->height;
>>       return udl_gem_create(file, dev,
>>                             args->size, &args->handle);
>> --
>> 1.8.5.3
>>
>
> --
> Daniel Vetter
> Software Engineer, Intel Corporation
> +41 (0) 79 365 57 48 - http://blog.ffwll.ch
diff mbox

Patch

diff --git a/drivers/gpu/drm/udl/udl_gem.c b/drivers/gpu/drm/udl/udl_gem.c
index 8d67b94..df963a1 100644
--- a/drivers/gpu/drm/udl/udl_gem.c
+++ b/drivers/gpu/drm/udl/udl_gem.c
@@ -60,7 +60,7 @@  int udl_dumb_create(struct drm_file *file,
 		    struct drm_device *dev,
 		    struct drm_mode_create_dumb *args)
 {
-	args->pitch = args->width * ((args->bpp + 1) / 8);
+	args->pitch = args->width * ((args->bpp + 7) / 8);
 	args->size = args->pitch * args->height;
 	return udl_gem_create(file, dev,
 			      args->size, &args->handle);