From: "Peter Hüwe" <PeterHuewe@gmx.de>
To: tpmdd-devel@lists.sourceforge.net
Cc: Matthias Leblanc <mathias.leblanc@st.com>,
Kent Yoder <key@linux.vnet.ibm.com>,
Rajiv Andrade <mail@srajiv.net>,
Marcel Selhorst <tpmdd@selhorst.net>,
Sirrix AG <tpmdd@sirrix.com>,
"Jean-Luc Blanc" <jean-luc.blanc@st.com>,
linux-kernel@vger.kernel.org
Subject: Re: [tpmdd-devel] [PATCH 1/1] TPM: STMicroelectronics st33 driver SPI
Date: Thu, 16 May 2013 00:29:06 +0200 [thread overview]
Message-ID: <201305160029.07073.PeterHuewe@gmx.de> (raw)
In-Reply-To: <1368625999-1963-1-git-send-email-mathias.leblanc@st.com>
Hi Matthias,
Am Mittwoch, 15. Mai 2013, 15:53:19 schrieb Matthias Leblanc:
> +static inline int spi_read_write(struct spi_device *spi,
> + struct spi_transfer xfer) {
> + struct spi_message msg;
> + spi_message_init(&msg);
> + spi_message_add_tail(&xfer, &msg);
> + return spi_sync(spi, &msg);
> +}
This looks extremely like the predefined spi_sync_transfer in include/linux/spi.h
/**
* spi_sync_transfer - synchronous SPI data transfer
* @spi: device with which data will be exchanged
* @xfers: An array of spi_transfers
* @num_xfers: Number of items in the xfer array
* Context: can sleep
*
* Does a synchronous SPI data transfer of the given spi_transfer array.
*
* For more specific semantics see spi_sync().
*
* It returns zero on success, else a negative error code.
*/
static inline int
spi_sync_transfer(struct spi_device *spi, struct spi_transfer *xfers,
unsigned int num_xfers)
{
struct spi_message msg;
spi_message_init_with_transfers(&msg, xfers, num_xfers);
return spi_sync(spi, &msg);
}
where spi_message_init_with_transfers is defined as
static inline void
spi_message_init_with_transfers(struct spi_message *m,
struct spi_transfer *xfers, unsigned int num_xfers)
{
unsigned int i;
spi_message_init(m);
for (i = 0; i < num_xfers; ++i)
spi_message_add_tail(&xfers[i], m);
}
If you combine these functions you end up (more or less) with your implementation
So please use spi_sync_transfer
OR as an alternative use spi_write / spi_read as an alternative as mentioned in a previous email
And here is a rather subjective remark:
> + for (; nbr_dummy_bytes < total_length &&
> + ((u8 *)xfer.rx_buf)[nbr_dummy_bytes] == 0;
> + nbr_dummy_bytes++)
> + ;
Not sure if it would be easier to read using a while and putting the increment
into the loop body
>+ while (nbr_dummy_bytes < total_length &&
>+ ((u8 *)xfer.rx_buf)[nbr_dummy_bytes] == 0)
>+ nbr_dummy_bytes++;
I usually don't like empty loop bodies, as they tend to be overlooked.
> +module_spi_driver(tpm_st33_spi_driver);
> +
> +MODULE_AUTHOR("Christophe Ricard (tpmsupport@st.com)");
> +MODULE_DESCRIPTION("STM TPM SPI ST33 Driver");
> +MODULE_VERSION("1.2.0");
> +MODULE_LICENSE("GPL");
Something is strange here - if I apply your patch, the module license gets lost - so I get a compile warning:
WARNING: modpost: missing MODULE_LICENSE() in /data/data-old/linux-2.6/drivers/char/tpm/tpm_spi_stm_st33.o
Do you edit the patch by hand before sending?
Steps to reproduce:
drivers/char/tpm $ git reset --hard tpmdd/tpmdd-04-26-13
HEAD is now at d224213 tpm_tis: missing platform_driver_unregister() on error in init_tis()
drivers/char/tpm $ git am /tmp/\[tpmdd-devel\]\ \[PATCH\ 1_1\]\ TPM_STMicroelectronics\ st33\ driver\ SPI.mbox
Applying: TPM: STMicroelectronics st33 driver SPI
drivers/char/tpm $ tail tpm_spi_stm_st33.c },
.probe = tpm_st33_spi_probe,
.remove = tpm_st33_spi_remove,
};
module_spi_driver(tpm_st33_spi_driver);
MODULE_AUTHOR("Christophe Ricard (tpmsupport@st.com)");
MODULE_DESCRIPTION("STM TPM SPI ST33 Driver");
MODULE_VERSION("1.2.0");
And the usual sparse warnings ;)
drivers/char/tpm $ make M=`pwd` -C /data/data-old/linux-2.6/ modules C=1 CHECK=sparse
make: Entering directory `/data/data-old/linux-2.6'
CHECK /data/data-old/linux-2.6/drivers/char/tpm/tpm_spi_stm_st33.c
/data/data-old/linux-2.6/drivers/char/tpm/tpm_spi_stm_st33.c:104:35: warning: cast removes address space of expression
/data/data-old/linux-2.6/drivers/char/tpm/tpm_spi_stm_st33.c:170:35: warning: cast removes address space of expression
/data/data-old/linux-2.6/drivers/char/tpm/tpm_spi_stm_st33.c:242:19: warning: cast removes address space of expression
/data/data-old/linux-2.6/drivers/char/tpm/tpm_spi_stm_st33.c:235:15: warning: symbol 'wait_for_serirq_timeout' was not declared. Should it be static?
/data/data-old/linux-2.6/drivers/char/tpm/tpm_spi_stm_st33.c:482:19: warning: cast removes address space of expression
Regards,
Peter
next prev parent reply other threads:[~2013-05-15 22:25 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-15 13:53 [PATCH 1/1] TPM: STMicroelectronics st33 driver SPI Matthias Leblanc
2013-05-15 22:29 ` Peter Hüwe [this message]
2013-05-16 8:45 ` [tpmdd-devel] " Mathias LEBLANC
2013-05-16 19:03 ` Peter Hüwe
2013-05-17 12:26 ` Mathias LEBLANC
-- strict thread matches above, loose matches on Subject: below --
2013-05-07 10:16 Matthias Leblanc
[not found] ` <-7985513476024686594@unknownmsgid>
2013-05-10 15:06 ` [tpmdd-devel] " Kent Yoder
2013-05-13 15:30 ` Mathias LEBLANC
2013-05-13 15:56 ` Kent Yoder
2013-04-22 8:50 Mathias Leblanc
2013-04-22 15:26 ` [tpmdd-devel] " Kent Yoder
2013-04-22 16:32 ` Mathias LEBLANC
2013-04-22 18:31 ` Kent Yoder
2013-04-25 15:40 ` Mathias LEBLANC
2013-04-26 14:29 ` Kent Yoder
2013-04-28 1:16 ` Peter Hüwe
2013-04-29 14:15 ` Kent Yoder
2013-04-12 8:44 Matthias Leblanc
2013-04-17 21:31 ` [tpmdd-devel] " Kent Yoder
2013-04-19 16:06 ` Mathias LEBLANC
2013-04-09 14:42 Matthias Leblanc
2013-04-10 20:32 ` [tpmdd-devel] " Peter Hüwe
2013-04-11 8:58 ` Mathias LEBLANC
2013-04-11 21:44 ` Peter Hüwe
2013-03-25 15:08 Matthias Leblanc
2013-03-25 16:44 ` [tpmdd-devel] " Kent Yoder
2013-03-25 16:48 ` Mathias LEBLANC
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=201305160029.07073.PeterHuewe@gmx.de \
--to=peterhuewe@gmx.de \
--cc=jean-luc.blanc@st.com \
--cc=key@linux.vnet.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mail@srajiv.net \
--cc=mathias.leblanc@st.com \
--cc=tpmdd-devel@lists.sourceforge.net \
--cc=tpmdd@selhorst.net \
--cc=tpmdd@sirrix.com \
/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.