Hello Andrew, please don't remove the list and Christian from Cc, please don't top post.
Andrew Pushkin wrote:
> There are no problems without patch, but code" while ((mcp251x_read_reg(spi,
> CANSTAT) & CANCTRL_REQOP_MASK) != CANCTRL_REQOP_CONF) " is hard to
> undestend, because REQOP bits present in CANCTRL, but no CANSTAT register
that's correct.
> (In CANSTAT present OPMOD bits (see page 53 MCP2510 datasheet)). We maybe
> need change name CANCTRL_REQOP_MASK and to CANCTRL_OPMOD_MASK and
to make it consistent we can add a define CANSTAT_OPMODE_MASK, because
it's for the CANSTAT register.
> CANCTRL_REQOP_CONF to CANCTRL_OPMOD_CONF or apply my patch. Without patch
> code is good by work, but not is good by reading.
should be CANSTAT_OPMOD_CONF
>>> --- a/drivers/net/can/mcp251x.c
>>> +++ b/drivers/net/can/mcp251x.c
>>> @@ -587,7 +587,7 @@ static int mcp251x_hw_reset(struct spi_device *spi)
>>> /* Wait for reset to finish */
>>> timeout = jiffies + HZ;
>>> mdelay(10);
>>> - while ((mcp251x_read_reg(spi, CANSTAT) & CANCTRL_REQOP_MASK)
>>> + while ((mcp251x_read_reg(spi, CANCTRL) & CANCTRL_REQOP_MASK)
>>> != CANCTRL_REQOP_CONF) {
>>> schedule();
>>> if (time_after(jiffies, timeout)) {
NACK,
If you have a look at your patch you change the register which is read
from. Original it's CANSTAT, but you change it to CANCTRL. Have a look
at page 51 of the datasheet:
> The operational mode is selected via the CANCTRL.
> REQOP bits (see Register 9-1). When changing
> modes, the mode will not actually change until all pending
> message transmissions are complete. Because of
> this, the user must verify that the device has actually
> changed into the requested mode before further operations
> are executed. Verification of the current operating
> mode is done by reading the CANSTAT. OPMODE
> bits (see Register 9-2).
However you can prepare another patch which adds and uses the missing
CANSTAT_ defines.
cheers, Marc
--
Pengutronix e.K. | Marc Kleine-Budde |
Industrial Linux Solutions | Phone: +49-231-2826-924 |
Vertretung West/Dortmund | Fax: +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686 | http://www.pengutronix.de |
signature.asc
Description: OpenPGP digital signature
_______________________________________________ Socketcan-core mailing list [email protected] https://lists.berlios.de/mailman/listinfo/socketcan-core
