public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 1/3] Initial mflash support
Date: Tue, 17 Feb 2009 09:41:24 +0100	[thread overview]
Message-ID: <20090217084124.GC7712@game.jcrosoft.org> (raw)
In-Reply-To: <499A62B2.7060803@gmail.com>

On 16:09 Tue 17 Feb     , unsik Kim wrote:
> Hello?
>
> Thanks for comments.
> Some patches will be posted for your requests.
> Also I wrote my opinion for some comments.
>
>>> diff --git a/drivers/block/Makefile b/drivers/block/Makefile
>>> index 59388d9..eccefc1 100644
>>> --- a/drivers/block/Makefile
>>> +++ b/drivers/block/Makefile
>>> @@ -25,13 +25,14 @@ include $(TOPDIR)/config.mk
>>>   LIB	:= $(obj)libblock.a
>>>  -COBJS-$(CONFIG_SCSI_AHCI) += ahci.o
>> why?
> This list badly sorted before I add. I just resort it to
> alphabetical order and add new option. Nothing removed.
>
>>>  COBJS-$(CONFIG_ATA_PIIX) += ata_piix.o
>>> +COBJS-$(CONFIG_CMD_MG_DISK) += mg_disk.o
>>>  COBJS-$(CONFIG_FSL_SATA) += fsl_sata.o
>>> +COBJS-$(CONFIG_IDE_SIL680) += sil680.o
>>>  COBJS-$(CONFIG_LIBATA) += libata.o
>>>  COBJS-$(CONFIG_PATA_BFIN) += pata_bfin.o
>>>  COBJS-$(CONFIG_SATA_SIL3114) += sata_sil3114.o
>>> -COBJS-$(CONFIG_IDE_SIL680) += sil680.o
>>> +COBJS-$(CONFIG_SCSI_AHCI) += ahci.o
>>>  COBJS-$(CONFIG_SCSI_SYM53C8XX) += sym53c8xx.o
>>>  COBJS-$(CONFIG_SYSTEMACE) += systemace.o
>>>  diff --git a/drivers/block/mg_disk.c b/drivers/block/mg_disk.c
>>> new file mode 100644
>>> index 0000000..4454fca
>>> --- /dev/null
>>> +++ b/drivers/block/mg_disk.c
>>> +
>>> +#define MG_BASE	(host.drv_data->base)
>> an inline function will be better
>  This isn't a function.
yes but please use an inline function which will allow better compiler check
and error message
as done in a lots of the linux drivers as example the netdev with this
static inline void *netdev_priv(const struct net_device *dev)
{
	return dev->priv;
}
>>> +
>
>>> +
>>> +/*
>>> + * copy src to dest, skipping leading and trailing blanks and null
>>> + * terminate the string
>>> + * "len" is the size of available memory including the terminating '\0'
>>> + */
>>> +static void mg_ident_cpy (unsigned char *dst, unsigned char *src,
>>> +		unsigned int len)
>>> +{
>>> +	unsigned char *end, *last;
>>> +
>>> +	last = dst;
>>> +	end  = src + len - 1;
>>> +
>>> +	/* reserve space for '\0' */
>>> +	if (len < 2)
>>> +		goto OUT;
>>> +
>>> +	/* skip leading white space */
>>> +	while ((*src) && (src<end) && (*src==' '))
>> please add a space before and after '<' '==' & co
>>> +		++src;
>>> +
>>> +	/* copy string, omitting trailing white space */
>>> +	while ((*src) && (src<end)) {
>>> +		*dst++ = *src;
>>> +		if (*src++ != ' ')
>>> +			last = dst;
>>> +	}
>>> +OUT:
>>> +	*last = '\0';
>>> +}
>> why do you need this?
> for parsing string parts of ATAID
it's mflash specific??
>
>>> +static unsigned int mg_do_read_sects(void *buff, u32 sect_num, u32 sect_cnt)
>>> +{
>>> +	u32 i, j, err;
>>> +	u8 *buff_ptr = buff;
>>> +
>>> +	err = mg_out(sect_num, sect_cnt, MG_CMD_RD);
>>> +	if (err)
>>> +		return err;
>>> +
>>> +	for (i = 0; i < sect_cnt; i++) {
>>> +		err = mg_wait(MG_REG_STATUS_BIT_DATA_REQ, 3000);
>>> +		if (err)
>>> +			return err;
>>> +
>>> +		/* TODO : u16 unaligned case */
>>> +		for(j = 0; j < MG_SECTOR_SIZE >> 1; j++) {
>>> +			*(u16 *)buff_ptr =
>>> +				readw(MG_BASE + MG_BUFF_OFFSET + (j << 1));
>> ??
> I can't guess your intention. Please write more clearly
you store a u16 in a u8 :(
>>> +			buff_ptr += 2;
>>> +		}
>>> +
>>> +		writeb(MG_CMD_RD_CONF, MG_BASE + MG_REG_COMMAND);
>>> +
>>> +		MG_DBG("%u (0x%8.8x) sector read", sect_num + i,
>>> +			(sect_num + i) * MG_SECTOR_SIZE);
>>> +	}
>>> +
>>> +	return err;
>>> +}
>
>>> +unsigned int mg_disk_read_sects(void *buff, u32 sect_num, u32 sect_cnt)
>>> +{
>>> +	u32 quotient, residue, i, err;
>>> +	u8 *buff_ptr = buff;
>>> +
>>> +	quotient = sect_cnt >> 8;
>>> +	residue = sect_cnt % 256;
>>> +
>>> +	for (i = 0; i < quotient; i++) {
>>> +		MG_DBG("sect num : %u buff : 0x%8.8x", sect_num, (u32)buff_ptr);
>>> +		err = mg_do_read_sects(buff_ptr, sect_num, 256);
>>> +		if (err)
>>> +			return err;
>>> +		sect_num += 256;
>>> +		buff_ptr += 256 * MG_SECTOR_SIZE;
>>> +	}
>>> +
>>> +	if (residue) {
>>> +		MG_DBG("sect num : %u buff : %8.8x", sect_num, (u32)buff_ptr);
>> please use debug(x)
> MG_DBG prints lots of messages. I think changing MG_DBG to debug might
> confuse other driver's debug message.
> If u-boot policy only allow debug(x), I'll follow.
>>> +		err = mg_do_read_sects(buff_ptr, sect_num, residue);
>>> +	}
>>> +
>>> +	return err;
>>> +}
>
>>> +/* must override this function */
>>> +struct mg_drv_data * __attribute__((weak)) mg_get_drv_data (void)
>>> +{
>>> +	puts ("### WARNING ### port mg_get_drv_data function\n");
>>> +	return NULL;
>>> +}
>> please do an compile error not a run time error
> IMHO, compile error (or warning) is not a good choice for this case.
sorry no beacause everyone does not have the board to test it, a compile error
will at least help use to check if we brake the board or not
> Compile time error always generate error even though override function
> exist.
not necessarely
does you driver allow multiple instance of mflash?
if no you does not implement the function

Best Regards,
J.

  reply	other threads:[~2009-02-17  8:41 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-02-13 11:06 [U-Boot] [U-BOOT][PATCH 1/3] Initial mflash support unsik Kim
2009-02-14 11:51 ` Jean-Christophe PLAGNIOL-VILLARD
2009-02-17  7:09   ` [U-Boot] [PATCH " unsik Kim
2009-02-17  8:41     ` Jean-Christophe PLAGNIOL-VILLARD [this message]
2009-02-18  3:32       ` unsik Kim

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=20090217084124.GC7712@game.jcrosoft.org \
    --to=plagnioj@jcrosoft.com \
    --cc=u-boot@lists.denx.de \
    /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