[riot-notifications] [RIOT-OS/RIOT] cpu/native: Allow Access to Hardware SPI Bus on Linux (#11352)

benpicco notifications at github.com
Mon Sep 30 17:17:49 CEST 2019


benpicco commented on this pull request.



> +    uint8_t spi_mode = mode | (hwcs ? 0 : SPI_NO_CS);
+
+    if (real_ioctl(fd, SPI_IOC_WR_MODE, &spi_mode) < 0) {
+        return SPI_NOMODE;
+    }
+    uint32_t ioctl_clk = clk;
+    if (real_ioctl(fd, SPI_IOC_WR_MAX_SPEED_HZ, &ioctl_clk) < 0) {
+        return SPI_NOCLK;
+    }
+    return SPI_OK;
+}
+
+void spi_transfer_bytes(spi_t bus, spi_cs_t cs, bool cont,
+                        const void *out, void *in, size_t len)
+{
+    if (bus < SPI_NUMOF && (cs == SPI_CS_UNDEF || cs < SPI_MAXCS)) {

Instead of wrapping the entire function in an if-condition, just return early if the condition is false.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/RIOT-OS/RIOT/pull/11352#pullrequestreview-295053703
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20190930/b6d00d6d/attachment.htm>


More information about the notifications mailing list