diff mbox

drm: tegra: shut up harmless warning on NOMMU

Message ID 20170112111425.3228358-1-arnd@arndb.de (mailing list archive)
State New, archived
Headers show

Commit Message

Arnd Bergmann Jan. 12, 2017, 11:13 a.m. UTC
The tegra DRM driver is almost ok without an MMU, but there
is one small warning that I get:

drivers/gpu/drm/tegra/gem.c: In function 'tegra_drm_mmap':
drivers/gpu/drm/tegra/gem.c:508:12: unused variable 'prot'

This marks the variable as __maybe_unused instead.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 drivers/gpu/drm/tegra/gem.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Thierry Reding Jan. 19, 2017, 11 a.m. UTC | #1
On Thu, Jan 12, 2017 at 12:13:51PM +0100, Arnd Bergmann wrote:
> The tegra DRM driver is almost ok without an MMU, but there
> is one small warning that I get:
> 
> drivers/gpu/drm/tegra/gem.c: In function 'tegra_drm_mmap':
> drivers/gpu/drm/tegra/gem.c:508:12: unused variable 'prot'
> 
> This marks the variable as __maybe_unused instead.
> 
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
>  drivers/gpu/drm/tegra/gem.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/tegra/gem.c b/drivers/gpu/drm/tegra/gem.c
> index 7d853e6b5ff0..63f14b7a59a0 100644
> --- a/drivers/gpu/drm/tegra/gem.c
> +++ b/drivers/gpu/drm/tegra/gem.c
> @@ -505,7 +505,7 @@ int tegra_drm_mmap(struct file *file, struct vm_area_struct *vma)
>  
>  		vma->vm_pgoff = vm_pgoff;
>  	} else {
> -		pgprot_t prot = vm_get_page_prot(vma->vm_flags);
> +		pgprot_t prot __maybe_unused = vm_get_page_prot(vma->vm_flags);

This seems to me like a suboptimal solution. The reason why this fails
is because pgprot_writecombine(prot) for NOMMU translates to __pgprot(0)
via a macro. This also means that we need to potentially add a
__maybe_unused annotation to every local variable that stores a value
that gets passed to pgprot_writecombine().

There fortunately aren't very many of those cases, but I still think
that a better solution would be to turn pgprot_writecombine() into a
static inline function, so that the parameter would get silently
ignored. Or perhaps if it must remain a macro, then doing the following
should still avoid the need to modify every call site:

	#define pgprot_writecombine(prot) ({ (void)prot; __pgprot(0); })

Thierry
diff mbox

Patch

diff --git a/drivers/gpu/drm/tegra/gem.c b/drivers/gpu/drm/tegra/gem.c
index 7d853e6b5ff0..63f14b7a59a0 100644
--- a/drivers/gpu/drm/tegra/gem.c
+++ b/drivers/gpu/drm/tegra/gem.c
@@ -505,7 +505,7 @@  int tegra_drm_mmap(struct file *file, struct vm_area_struct *vma)
 
 		vma->vm_pgoff = vm_pgoff;
 	} else {
-		pgprot_t prot = vm_get_page_prot(vma->vm_flags);
+		pgprot_t prot __maybe_unused = vm_get_page_prot(vma->vm_flags);
 
 		vma->vm_flags |= VM_MIXEDMAP;
 		vma->vm_flags &= ~VM_PFNMAP;