public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jaime Arrocha <jarr@kerneldev.net>
To: gregkh@linuxfoundation.org
Cc: devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org,
	jonathankim@gctsemi.com, deanahn@gctsemi.com, jarrocha@linux.com
Subject: [PATCH] staging: gdm724: adding kernel endianness header
Date: Fri, 8 May 2015 18:29:24 -0500	[thread overview]
Message-ID: <20150508232924.GA30574@localhost.localdomain> (raw)

>From TODO list: remove test for host endian
Included header to gather information about host endianness.
Please let me know if the code addition requires corrections
to meet standards.

Signed-off-by: Jaime Arrocha <jarr@kerneldev.net>
---
 drivers/staging/gdm724x/gdm_endian.c |   22 ++++++++++------------
 1 file changed, 10 insertions(+), 12 deletions(-)

diff --git a/drivers/staging/gdm724x/gdm_endian.c b/drivers/staging/gdm724x/gdm_endian.c
index f6cc90a..5dfd9d3 100644
--- a/drivers/staging/gdm724x/gdm_endian.c
+++ b/drivers/staging/gdm724x/gdm_endian.c
@@ -11,27 +11,25 @@
  * GNU General Public License for more details.
  */
 
-#include <linux/slab.h>
+#include<asm/byteorder.h>
+#ifdef __LITTLE_ENDIAN
+#include<linux/byteorder/little_endian.h>
+#define H_ENDIAN ENDIANNESS_LITTLE
+#else
+#include<linux/byteorder/big_endian.h>
+#define H_ENDIAN ENDIANNESS_BIG
+#endif
+
 #include "gdm_endian.h"
 
 void gdm_set_endian(struct gdm_endian *ed, u8 dev_endian)
 {
-	u8 a[2] = {0x12, 0x34};
-	u8 b[2] = {0, };
-	u16 c = 0x1234;
-
 	if (dev_endian == ENDIANNESS_BIG)
 		ed->dev_ed = ENDIANNESS_BIG;
 	else
 		ed->dev_ed = ENDIANNESS_LITTLE;
 
-	memcpy(b, &c, 2);
-
-	if (a[0] != b[0])
-		ed->host_ed = ENDIANNESS_LITTLE;
-	else
-		ed->host_ed = ENDIANNESS_BIG;
-
+	ed->host_ed = H_ENDIAN;
 }
 
 u16 gdm_cpu_to_dev16(struct gdm_endian *ed, u16 x)
-- 
1.7.10.4



             reply	other threads:[~2015-05-08 23:29 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-08 23:29 Jaime Arrocha [this message]
2015-05-09 10:59 ` [PATCH] staging: gdm724: adding kernel endianness header Dan Carpenter
2015-05-09 16:55   ` Jaime Arrocha

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150508232924.GA30574@localhost.localdomain \
    --to=jarr@kerneldev.net \
    --cc=deanahn@gctsemi.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=jarrocha@linux.com \
    --cc=jonathankim@gctsemi.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox