linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] staging: gdm724: adding kernel endianness header
@ 2015-05-08 23:29 Jaime Arrocha
  2015-05-09 10:59 ` Dan Carpenter
  0 siblings, 1 reply; 3+ messages in thread
From: Jaime Arrocha @ 2015-05-08 23:29 UTC (permalink / raw)
  To: gregkh; +Cc: devel, linux-kernel, jonathankim, deanahn, jarrocha

>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



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] staging: gdm724: adding kernel endianness header
  2015-05-08 23:29 [PATCH] staging: gdm724: adding kernel endianness header Jaime Arrocha
@ 2015-05-09 10:59 ` Dan Carpenter
  2015-05-09 16:55   ` Jaime Arrocha
  0 siblings, 1 reply; 3+ messages in thread
From: Dan Carpenter @ 2015-05-09 10:59 UTC (permalink / raw)
  To: Jaime Arrocha; +Cc: gregkh, devel, deanahn, jonathankim, linux-kernel, jarrocha

On Fri, May 08, 2015 at 06:29:24PM -0500, Jaime Arrocha wrote:
> >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.
> 

No.  This isn't really an improvement.  We need to get rid of ->host_ed
entirely.  Which is actually easy.  Basically change gdm_cpu_to_dev16()
and friends to do so something:

u16 gdm_cpu_to_dev16(struct gdm_endian *ed, u16 x)
{
	if (ed->dev_ed == ENDIANNESS_LITTLE)
		return cpu_to_le16(x);
	else
		return cpu_to_be16(x);
}

regards,
dan carpenter


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Re: [PATCH] staging: gdm724: adding kernel endianness header
  2015-05-09 10:59 ` Dan Carpenter
@ 2015-05-09 16:55   ` Jaime Arrocha
  0 siblings, 0 replies; 3+ messages in thread
From: Jaime Arrocha @ 2015-05-09 16:55 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: gregkh, devel, deanahn, jonathankim, linux-kernel, jarrocha



---- On Sat, 09 May 2015 05:59:40 -0500 Dan Carpenter <dan.carpenter@oracle.com> wrote ---- 

 > On Fri, May 08, 2015 at 06:29:24PM -0500, Jaime Arrocha wrote: 
 > > >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. 
 > >  
 >  
 > No.  This isn't really an improvement.  We need to get rid of ->host_ed 
 > entirely.  Which is actually easy.  Basically change gdm_cpu_to_dev16() 
 > and friends to do so something: 
 >  
 > u16 gdm_cpu_to_dev16(struct gdm_endian *ed, u16 x) 
 > { 
 >     if (ed->dev_ed == ENDIANNESS_LITTLE) 
 >         return cpu_to_le16(x); 
 >     else 
 >         return cpu_to_be16(x); 
 > } 
 >  
 > regards, 
 > dan carpenter 
 >  
 > 

You are right, I will dive a little further to find out the use for host_ed and eliminate it. I did
read an email from a while ago where one author mentioned that he needed to keep this function.

Also, the kernel already has functions to swap numbers for endianness. Will you rather use those?

Thanks for your feedback,
Jaime


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-05-09 16:55 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-08 23:29 [PATCH] staging: gdm724: adding kernel endianness header Jaime Arrocha
2015-05-09 10:59 ` Dan Carpenter
2015-05-09 16:55   ` Jaime Arrocha

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).