Received: by 10.192.165.156 with SMTP id m28csp305403imm; Tue, 17 Apr 2018 10:24:33 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/2aPhFPhC4ZCI1InSEdi4xktRn5tmK+I4cq9zW9lZa1QC+29jhSwnCViu59EyMp5AWVAlG X-Received: by 2002:a17:902:2f:: with SMTP id 44-v6mr2897455pla.187.1523985873040; Tue, 17 Apr 2018 10:24:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523985873; cv=none; d=google.com; s=arc-20160816; b=fhxVhTE19ontoO/2z9f4INa2cNFCsj1+WxJdmqt/Q6soM16JSR/CUwdnt/fmkIp4Ls 9w9HWih9qUdqThIKgHQ+1LHQMJZf8HXY2g9JWK1wpFpJrzXf+xPZLvwIfEqlKQ7E14qz 4uhbb4duXawI4KxlxYulOsqYC/UrdemVYQvXF+MYnhmQ/8fqpsWezPT9PVXILT4x1TV/ ZKYt6z/WDWFidj5+QRE7xNmqhSYAVAOs0u3hcVfU9weGIzwUcxSaYpGTg/0xxEBdN+9j GRTCYjppu6pwFrmqqo+Q/0wUn9sOLCt31uroVoQPZ4+o99CSJqg2AWFujiaCHVnBiStB 3ihw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dmarc-filter:dkim-signature:dkim-signature :arc-authentication-results; bh=ZAAXlZGgw7UexnanGEqeduMxsmb66DgVngM1HDbuiyk=; b=Ah59LrqbqnPUhZ/6YPPDFV1MMD+ovC1GHHyLrygeEZ2MJoJDE+gpAa3YoTWGU4UWEO EP0dV0oPRAif9Fn2zUouclei1qnU7GIaJwEGKY+elydp1OzzbU/bvTrjsdNrFtE+Uwcz f3eULrfiCZl1BuWCdH+6R4dXxkkpqRCLOF4jIIqCXXAUabj3paRuKMG3meLk4CBX+dtx 6gD88r2Tti5RUp1llQOY1xoTayjCSPTqWeSLSqnrgaVP0Q6AyMhl0XioxS4tEXeV7b4D Nz+nGGLsvOLFnXvKl6IAg4rrQunvK3KF76C/Pnvp9dqV/ASN06txEhDBW2HV1edWr+RB DaVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=HTYnAqNM; dkim=pass header.i=@codeaurora.org header.s=default header.b=fJMfzTQt; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t12-v6si14937870plq.547.2018.04.17.10.24.19; Tue, 17 Apr 2018 10:24:32 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=HTYnAqNM; dkim=pass header.i=@codeaurora.org header.s=default header.b=fJMfzTQt; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752786AbeDQRWo (ORCPT + 99 others); Tue, 17 Apr 2018 13:22:44 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:44206 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752632AbeDQRWl (ORCPT ); Tue, 17 Apr 2018 13:22:41 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id A14BB60310; Tue, 17 Apr 2018 17:22:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1523985759; bh=ViBm4SNFMEoFOlXLErKgVX+mU1KlqSJM9jjOKta393U=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=HTYnAqNMRJgD8piL50voquRdGuSlseFkYUQEfT2dHazgh7Cyhj5EGLJmNyV/gXYvf 9aw3qHb1lig22nqR+x3R22RGy6lSrHmJmEwwNgXUOiOVuTx0vrL9jkm4+Mkh9230et UyT0zxM6wHlDF6ht5YskzqlXXB2ybXw+skjFgkHM= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on pdx-caf-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,T_DKIM_INVALID autolearn=no autolearn_force=no version=3.4.0 Received: from localhost (i-global254.qualcomm.com [199.106.103.254]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: ilina@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 2419E60310; Tue, 17 Apr 2018 17:22:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1523985755; bh=ViBm4SNFMEoFOlXLErKgVX+mU1KlqSJM9jjOKta393U=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=fJMfzTQtrk/AZUrKiYvttOIuhfPBARHThMJn3tU4qjliNktViRJVP1GSPALtPc3Vc ra8rt1W/XqPloiyyzlPgs1AdwefZQWxQZzxbutnXDGqCnZKuOai1rw52pIvEjRbV8A Qd6fRgCcUeGs6iemmf9ocB5gCjdTUmr4Os57gcNQ= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 2419E60310 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=ilina@codeaurora.org Date: Tue, 17 Apr 2018 11:22:34 -0600 From: Lina Iyer To: Stephen Boyd Cc: Andy Gross , linux-arm-msm@vger.kernel.org, linux-soc@vger.kernel.org, linux-kernel@vger.kernel.org, Mahesh Sivasubramanian , Bjorn Andersson , Evan Green Subject: Re: [PATCH] soc: qcom: cmd-db: Make endian-agnostic Message-ID: <20180417172234.GA29077@codeaurora.org> References: <20180412224111.35216-1-swboyd@chromium.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <20180412224111.35216-1-swboyd@chromium.org> User-Agent: Mutt/1.9.5 (2018-04-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Apr 12 2018 at 16:41 -0600, Stephen Boyd wrote: >This driver deals with memory that is stored in little-endian format. >Update the structures with the proper little-endian types and then >do the proper conversions when reading the fields. Note that we compare >the ids with a memcmp() because we already pad out the string 'id' field >to exactly 8 bytes with the strncpy() onto the stack. > >Cc: Mahesh Sivasubramanian >Cc: Lina Iyer >Cc: Bjorn Andersson >Cc: Evan Green >Signed-off-by: Stephen Boyd >--- > >Changes from inline patch: > * Fixed magic > * Made function for memcmp() > * > > drivers/soc/qcom/cmd-db.c | 116 +++++++++++++++++++++----------------- > 1 file changed, 65 insertions(+), 51 deletions(-) > >@@ -99,8 +90,34 @@ struct cmd_db_header { > * h/w accelerator and request a resource state. > */ > >+static const char CMD_DB_MAGIC[] = { 0xdb, 0x30, 0x03, 0x0c }; >+ This works now. >+static bool cmd_db_magic_matches(struct cmd_db_header *header) >+{ >+ __le32 *magic = &header->magic_num; >+ >+ return memcmp(magic, CMD_DB_MAGIC, sizeof(CMD_DB_MAGIC)) == 0; >+} >+ > static struct cmd_db_header *cmd_db_header; Could you move this up, along with other declarations? > >+ >+static inline void *rsc_to_entry_header(struct rsc_hdr *hdr) >+{ >+ u16 offset = le16_to_cpu(hdr->header_offset); >+ >+ return cmd_db_header->data + offset; I noticed that the data was incorrect, with the above and I did it to read the correct data. return ((void*)cmd_db_header + sizeof(*cmd_db_header) + offset); >+} >+ >+static inline void * >+rsc_offset(struct rsc_hdr *hdr, struct entry_header *ent) >+{ >+ u16 offset = le16_to_cpu(hdr->header_offset); >+ u16 loffset = le16_to_cpu(ent->offset); >+ >+ return cmd_db_header->data + offset + loffset; As well here - return ((void*)cmd_db_header + sizeof(*cmd_db_header) + offset + loffset); >+} >+ Thanks, Lina