Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752473AbbHSVhS (ORCPT ); Wed, 19 Aug 2015 17:37:18 -0400 Received: from e06smtp16.uk.ibm.com ([195.75.94.112]:43017 "EHLO e06smtp16.uk.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751257AbbHSVhQ (ORCPT ); Wed, 19 Aug 2015 17:37:16 -0400 X-Helo: d06dlp03.portsmouth.uk.ibm.com X-MailFrom: ldufour@linux.vnet.ibm.com X-RcptTo: linux-kernel@vger.kernel.org Message-ID: <55D4F702.4020503@linux.vnet.ibm.com> Date: Wed, 19 Aug 2015 23:37:06 +0200 From: Laurent Dufour User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.8.0 MIME-Version: 1.0 To: David Laight , "linuxppc-dev@lists.ozlabs.org" CC: Greg Kroah-Hartman , Jiri Slaby , "linux-kernel@vger.kernel.org" , Ben Herrenschmidt Subject: Re: [PATCH] powerpc/hvsi: Fix endianness issues in the HVSI driver References: <1438334990-11765-1-git-send-email-ldufour@linux.vnet.ibm.com> <063D6719AE5E284EB5DD2968C1650D6D1CB71D3E@AcuExch.aculab.com> In-Reply-To: <063D6719AE5E284EB5DD2968C1650D6D1CB71D3E@AcuExch.aculab.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 15081921-0025-0000-0000-000006831D26 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1604 Lines: 44 On 03/08/2015 13:00, David Laight wrote: > From: Laurent Dufour >> Sent: 31 July 2015 10:30 >> This patch fixes several endianness issues detected when running the HVSI >> driver in little endian mode. >> >> These issues are raised in little endian mode because the data exchanged in >> memory between the kernel and the hypervisor has to be in big endian >> format. > ... >> diff --git a/drivers/tty/hvc/hvsi.c b/drivers/tty/hvc/hvsi.c >> index 41901997c0d6..a75146f600cb 100644 >> --- a/drivers/tty/hvc/hvsi.c >> +++ b/drivers/tty/hvc/hvsi.c >> @@ -240,9 +240,9 @@ static void hvsi_recv_control(struct hvsi_struct *hp, uint8_t *packet, >> { >> struct hvsi_control *header = (struct hvsi_control *)packet; >> >> - switch (header->verb) { >> + switch (be16_to_cpu(header->verb)) { >> case VSV_MODEM_CTL_UPDATE: >> - if ((header->word & HVSI_TSCD) == 0) { >> + if ((be32_to_cpu(header->word) & HVSI_TSCD) == 0) { > > It is generally best to byteswap constants. > > David Thanks David for your review. Regarding the byte swapping of the constants, I'm wondering if this the best way here. For instance, Benjamin wrote a similar patch to fix another endianness issue (99fc1d91b8fc) and he doesn't convert the constant neither. It think that byte swapping the constant value will impact more code, and may not ease code reading. Cheers, Laurent. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/