From: "Hänel-Baas, Alexander" <alexander.haenel-baas-2YRSn766l8rddJNmlsFzeA@public.gmane.org>
To: "linux-spi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
<linux-spi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
Subject: SPI_IOC_WR_MAX_SPEED_HZ was overwitten?
Date: Tue, 29 Aug 2017 14:13:22 +0000 [thread overview]
Message-ID: <9BA84827B30CBE4996725F98F7DC91236563EEE4@SMExchange01.siebmeyer.org> (raw)
Hi
> Is it possible that the ioctl SPI_IOC_WR_MODE call can
> overwrite the previous ioctl SPI_IOC_WR_MAX_SPEED_HZ speed setting?
Yes it is. Please take a look in spidev.c Line 488.
In the spidev_ioctl() function at the SPI_IOC_WR_MAX_SPEED_HZ case the
spi->max_speed_hz value was always overwritten with the old "save" value
regardless if the spi_setup call was successful or not.
--Snip--
else
dev_dbg(&spi->dev, "%d Hz (max)\n", tmp);
spi->max_speed_hz = save;
}
break;
--snip--
Every following ioctl call will restore the wrong speed value.
Here is my patch to correct this:
--- a/drivers/spi/spidev.c
+++ b/drivers/spi/spidev.c
@@ -480,11 +480,10 @@
spi->max_speed_hz = tmp;
retval = spi_setup(spi);
- if (retval >= 0)
- spidev->speed_hz = tmp;
+ if (retval < 0)
+ spidev->speed_hz = save;
else
dev_dbg(&spi->dev, "%d Hz (max)\n", tmp);
- spi->max_speed_hz = save;
}
break;
Can anybody review this please?
With this patch my program works fine with the spidev and the tool flashrom also.
Best regards,
Alexander
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next reply other threads:[~2017-08-29 14:13 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-29 14:13 Hänel-Baas, Alexander [this message]
-- strict thread matches above, loose matches on Subject: below --
2017-08-25 9:08 SPI_IOC_WR_MAX_SPEED_HZ was overwitten? Hänel-Baas, Alexander
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=9BA84827B30CBE4996725F98F7DC91236563EEE4@SMExchange01.siebmeyer.org \
--to=alexander.haenel-baas-2yrsn766l8rddjnmlsfzea@public.gmane.org \
--cc=linux-spi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
/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.