[Top] [All Lists]

Re: [PATCH] mips/include/asm/mipsregs.h: s/u16/unsigned short/

To: Qais Yousef <>
Subject: Re: [PATCH] mips/include/asm/mipsregs.h: s/u16/unsigned short/
From: David Daney <>
Date: Fri, 06 Dec 2013 08:47:31 -0800
Cc: "" <>
Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed;; s=20120113; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=w+4M4i7pM7BpqJdRmz8xDCjyexklPeZxS1nCYqhBnH8=; b=GaQZeuwtXWCJMzQGza+TdJzBBNhI/vPcYLWibn3eQUWWh8QIvphT/u6xljYk/TBf5M 9XsZqRKsGo/BY/QWGq3J4UJDvpCDsvxae1dZdx9TMPc3cslSX3Py94qSWZ7DxsxkDqdy f0L64ydp8rQU0m5SOyYjLrGB5E++xm6PRKhyf5ExSy9haV5OQcN7v9olYEkSGaRqv2RL rAup0bvagzJSgbD/H6hbFDAcMsnbqbQDa0Bh6VWNrEJ5yPDWNiovefGlJKUkkxVf86s9 MEqTXvG5Gz8sGCFNgsHwD5mgi4P8BMf/hvZJEqqufo8S9Y1xFoEjPE/w6QGLP/ZDrcTj Ppeg==
In-reply-to: <>
List-archive: <>
List-help: <>
List-id: linux-mips <>
List-owner: <>
List-post: <>
List-software: Ecartis version 1.0.0
List-subscribe: <>
List-unsubscribe: <>
Original-recipient: rfc822;
References: <> <> <>
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130625 Thunderbird/17.0.7
On 12/06/2013 08:35 AM, Qais Yousef wrote:
-----Original Message-----
From: David Daney []
Sent: 06 December 2013 16:32
To: Qais Yousef
Subject: Re: [PATCH] mips/include/asm/mipsregs.h: s/u16/unsigned short/

On 12/06/2013 01:20 AM, Qais Yousef wrote:
I was getting this error when including this header in my driver:

    arch/mips/include/asm/mipsregs.h:644:33: error: unknown type name ‘u16’

since the use of u16 is not really necessary, convert it to unsigned short.

Signed-off-by: Qais Yousef <>
Reviewed-by: Steven J. Hill <>


Just #include <linux/types.h> at the top of asm/mipsregs.h instead.

Funnily that was my first solution before I changed it to this :)

I'll resend but can you please give some explanation why changing u16 to 
unsigned short is bad?

This is the linux kernel. People expect to see fixed width integer type definitions using the conventional u8, u16, u32, etc.

If you are doing something tricky enough that you need to explicitly use a type of a given width, don't hide the fact, bring it to our attention by using the kernel standard type.

If you don't need exactly a u16, just make it an unsigned int and be done with it.

It would appear that micro-MIPS instructions are 16 bit, so use u16 everywhere for them.

Also it looks like this function really should be declared as returning type bool, not int. For the same reason: It cannot return any integer, only truth values. Don't hide this fact. Bring it to our attention by using the proper types.

David Daney


David Daney

   arch/mips/include/asm/mipsregs.h |    4 ++--
   1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/mips/include/asm/mipsregs.h
index e033141..0a2d6ef 100644
--- a/arch/mips/include/asm/mipsregs.h
+++ b/arch/mips/include/asm/mipsregs.h
@@ -641,9 +641,9 @@
    * microMIPS instructions can be 16-bit or 32-bit in length. This
    * returns a 1 if the instruction is 16-bit and a 0 if 32-bit.
-static inline int mm_insn_16bit(u16 insn)
+static inline int mm_insn_16bit(unsigned short insn)
-       u16 opcode = (insn >> 10) & 0x7;
+       unsigned short opcode = (insn >> 10) & 0x7;

        return (opcode >= 1 && opcode <= 3) ? 1 : 0;

<Prev in Thread] Current Thread [Next in Thread>