All of lore.kernel.org
 help / color / mirror / Atom feed
From: 敬锐 <micky_ching@realsil.com.cn>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: "sameo@linux.intel.com" <sameo@linux.intel.com>,
	"lee.jones@linaro.org" <lee.jones@linaro.org>,
	"chris@printf.net" <chris@printf.net>,
	"ulf.hansson@linaro.org" <ulf.hansson@linaro.org>,
	"gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>,
	"linux-mmc@vger.kernel.org" <linux-mmc@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	王炜 <wei_wang@realsil.com.cn>,
	"rogerable@realtek.com" <rogerable@realtek.com>,
	"devel@linuxdriverproject.org" <devel@linuxdriverproject.org>
Subject: Re: [PATCH 1/2] mfd: rtsx: add func to split u32 into register
Date: Fri, 28 Nov 2014 02:10:36 +0000	[thread overview]
Message-ID: <5477D99C.3050903@realsil.com.cn> (raw)
In-Reply-To: <20141127152342.GA4860@mwanda>

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="gb2312", Size: 1285 bytes --]


On 11/27/2014 11:23 PM, Dan Carpenter wrote:
>> +static inline void rtsx_pci_write_be32(struct rtsx_pcr *pcr, u16 reg, u32 val)
>> >+{
>> >+	rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, reg,     0xFF, val >> 24);
>> >+	rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, reg + 1, 0xFF, val >> 16);
>> >+	rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, reg + 2, 0xFF, val >> 8);
>> >+	rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, reg + 3, 0xFF, val);
> This assumes the cpu is little endian.  First convert to big endian
> using cpu_to_be32() and then write it out.
>
> 	__be32 be_val = cpu_to_be32()
>
> 	rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, reg,     0xFF, be_val);
> 	rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, reg + 1, 0xFF, be_val >> 8);
> 	rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, reg + 2, 0xFF, be_val >> 16);
> 	rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, reg + 3, 0xFF, be_val >> 24);
>
> (Written hurredly in my mail client.  May be wrong).
>
I think we better not use cpu_to_be32() here, leave the work to caller
may be better.

eg, in sd_ops.c the cmd.arg is constructed bit by bit, we can put the right
byte to the right register by shift, so the endian check is not need.ÿôèº{.nÇ+‰·Ÿ®‰­†+%ŠËÿ±éݶ\x17¥Šwÿº{.nÇ+‰·¥Š{±þG«éÿŠ{ayº\x1dʇڙë,j\a­¢f£¢·hšïêÿ‘êçz_è®\x03(­éšŽŠÝ¢j"ú\x1a¶^[m§ÿÿ¾\a«þG«éÿ¢¸?™¨è­Ú&£ø§~á¶iO•æ¬z·švØ^\x14\x04\x1a¶^[m§ÿÿÃ\fÿ¶ìÿ¢¸?–I¥

WARNING: multiple messages have this Message-ID (diff)
From: 敬锐 <micky_ching@realsil.com.cn>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: "ulf.hansson@linaro.org" <ulf.hansson@linaro.org>,
	"sameo@linux.intel.com" <sameo@linux.intel.com>,
	"gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>,
	"linux-mmc@vger.kernel.org" <linux-mmc@vger.kernel.org>,
	"chris@printf.net" <chris@printf.net>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	王炜 <wei_wang@realsil.com.cn>,
	"devel@linuxdriverproject.org" <devel@linuxdriverproject.org>,
	"rogerable@realtek.com" <rogerable@realtek.com>,
	"lee.jones@linaro.org" <lee.jones@linaro.org>
Subject: Re: [PATCH 1/2] mfd: rtsx: add func to split u32 into register
Date: Fri, 28 Nov 2014 02:10:36 +0000	[thread overview]
Message-ID: <5477D99C.3050903@realsil.com.cn> (raw)
In-Reply-To: <20141127152342.GA4860@mwanda>


On 11/27/2014 11:23 PM, Dan Carpenter wrote:
>> +static inline void rtsx_pci_write_be32(struct rtsx_pcr *pcr, u16 reg, u32 val)
>> >+{
>> >+	rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, reg,     0xFF, val >> 24);
>> >+	rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, reg + 1, 0xFF, val >> 16);
>> >+	rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, reg + 2, 0xFF, val >> 8);
>> >+	rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, reg + 3, 0xFF, val);
> This assumes the cpu is little endian.  First convert to big endian
> using cpu_to_be32() and then write it out.
>
> 	__be32 be_val = cpu_to_be32()
>
> 	rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, reg,     0xFF, be_val);
> 	rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, reg + 1, 0xFF, be_val >> 8);
> 	rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, reg + 2, 0xFF, be_val >> 16);
> 	rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, reg + 3, 0xFF, be_val >> 24);
>
> (Written hurredly in my mail client.  May be wrong).
>
I think we better not use cpu_to_be32() here, leave the work to caller
may be better.

eg, in sd_ops.c the cmd.arg is constructed bit by bit, we can put the right
byte to the right register by shift, so the endian check is not need.

  reply	other threads:[~2014-11-28  2:11 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-27  2:53 [PATCH 0/2] mmc: rtsx: add support for sdio card micky_ching
2014-11-27  2:53 ` micky_ching
2014-11-27  2:53 ` [PATCH 1/2] mfd: rtsx: add func to split u32 into register micky_ching
2014-11-27  2:53   ` micky_ching
2014-11-27 15:23   ` Dan Carpenter
2014-11-27 15:23     ` Dan Carpenter
2014-11-28  2:10     ` 敬锐 [this message]
2014-11-28  2:10       ` 敬锐
2014-11-28  8:54       ` Dan Carpenter
2014-11-28  8:54         ` Dan Carpenter
2014-11-28  9:54     ` 敬锐
2014-11-28  9:54       ` 敬锐
2014-11-28 14:57       ` Dan Carpenter
2014-11-28 14:57         ` Dan Carpenter
2014-12-01 12:16   ` Lee Jones
2014-11-27  2:53 ` [PATCH 2/2] mmc: rtsx: add support for sdio card micky_ching
2014-11-27  2:53   ` micky_ching
2014-11-27 15:43   ` Dan Carpenter
2014-11-27 15:43     ` Dan Carpenter
2014-11-28  1:57     ` 敬锐
2014-11-28  1:57       ` 敬锐

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=5477D99C.3050903@realsil.com.cn \
    --to=micky_ching@realsil.com.cn \
    --cc=chris@printf.net \
    --cc=dan.carpenter@oracle.com \
    --cc=devel@linuxdriverproject.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=lee.jones@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mmc@vger.kernel.org \
    --cc=rogerable@realtek.com \
    --cc=sameo@linux.intel.com \
    --cc=ulf.hansson@linaro.org \
    --cc=wei_wang@realsil.com.cn \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.