Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/spi Pass the device_t into spi_configure(), and make...
details: https://anonhg.NetBSD.org/src/rev/e8de49094dc4
branches: trunk
changeset: 359729:e8de49094dc4
user: thorpej <thorpej%NetBSD.org@localhost>
date: Wed Jan 19 05:21:44 2022 +0000
description:
Pass the device_t into spi_configure(), and make the API contract that
spi_configure() will print errors if they occur; the driver is off the
hook.
diffstat:
sys/arch/evbarm/mpcsa/mpcsa_leds.c | 10 ++++------
sys/dev/spi/m25p.c | 8 +++-----
sys/dev/spi/mcp23xxxgpio_spi.c | 8 +++-----
sys/dev/spi/mcp3k.c | 6 ++----
sys/dev/spi/mcp48x1.c | 8 +++-----
sys/dev/spi/oj6sh.c | 8 +++-----
sys/dev/spi/scmdspi.c | 8 +++-----
sys/dev/spi/spi.c | 9 ++++++---
sys/dev/spi/spivar.h | 4 ++--
sys/dev/spi/ssdfb_spi.c | 8 +++-----
sys/dev/spi/tmp121.c | 8 +++-----
11 files changed, 35 insertions(+), 50 deletions(-)
diffs (truncated from 316 to 300 lines):
diff -r b17803897221 -r e8de49094dc4 sys/arch/evbarm/mpcsa/mpcsa_leds.c
--- a/sys/arch/evbarm/mpcsa/mpcsa_leds.c Wed Jan 19 05:05:45 2022 +0000
+++ b/sys/arch/evbarm/mpcsa/mpcsa_leds.c Wed Jan 19 05:21:44 2022 +0000
@@ -1,5 +1,5 @@
-/* $Id: mpcsa_leds.c,v 1.8 2022/01/19 05:05:45 thorpej Exp $ */
-/* $NetBSD: mpcsa_leds.c,v 1.8 2022/01/19 05:05:45 thorpej Exp $ */
+/* $Id: mpcsa_leds.c,v 1.9 2022/01/19 05:21:44 thorpej Exp $ */
+/* $NetBSD: mpcsa_leds.c,v 1.9 2022/01/19 05:21:44 thorpej Exp $ */
/*
* Copyright (c) 2007 Embedtronics Oy. All rights reserved.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: mpcsa_leds.c,v 1.8 2022/01/19 05:05:45 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mpcsa_leds.c,v 1.9 2022/01/19 05:21:44 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -139,10 +139,8 @@
aprint_naive(": output buffer\n");
aprint_normal(": 74HC595 or compatible shift register(s)\n");
- error = spi_configure(sa->sa_handle, SPI_MODE_0, 10000000);
+ error = spi_configure(self, sa->sa_handle, SPI_MODE_0, 10000000);
if (error) {
- aprint_error_dev(self,
- "failed to set Mode 0 @ 10MHz, error=%d\n", error);
return;
}
diff -r b17803897221 -r e8de49094dc4 sys/dev/spi/m25p.c
--- a/sys/dev/spi/m25p.c Wed Jan 19 05:05:45 2022 +0000
+++ b/sys/dev/spi/m25p.c Wed Jan 19 05:21:44 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: m25p.c,v 1.19 2022/01/19 05:05:45 thorpej Exp $ */
+/* $NetBSD: m25p.c,v 1.20 2022/01/19 05:21:44 thorpej Exp $ */
/*-
* Copyright (c) 2006 Urbana-Champaign Independent Media Center.
@@ -42,7 +42,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: m25p.c,v 1.19 2022/01/19 05:05:45 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: m25p.c,v 1.20 2022/01/19 05:21:44 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -142,10 +142,8 @@
aprint_naive("\n");
/* configure for 20MHz, which is the max for normal reads */
- error = spi_configure(sa->sa_handle, SPI_MODE_0, 20000000);
+ error = spi_configure(self, sa->sa_handle, SPI_MODE_0, 20000000);
if (error) {
- aprint_error_dev(self,
- "failed to set Mode 0 @ 20MHz, error=%d\n", error);
return;
}
diff -r b17803897221 -r e8de49094dc4 sys/dev/spi/mcp23xxxgpio_spi.c
--- a/sys/dev/spi/mcp23xxxgpio_spi.c Wed Jan 19 05:05:45 2022 +0000
+++ b/sys/dev/spi/mcp23xxxgpio_spi.c Wed Jan 19 05:21:44 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mcp23xxxgpio_spi.c,v 1.3 2022/01/19 05:05:45 thorpej Exp $ */
+/* $NetBSD: mcp23xxxgpio_spi.c,v 1.4 2022/01/19 05:21:44 thorpej Exp $ */
/*-
* Copyright (c) 2014, 2022 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: mcp23xxxgpio_spi.c,v 1.3 2022/01/19 05:05:45 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mcp23xxxgpio_spi.c,v 1.4 2022/01/19 05:21:44 thorpej Exp $");
/*
* Driver for Microchip serial I/O expanders:
@@ -203,10 +203,8 @@
aprint_normal(": %s I/O Expander\n", sc->sc_variant->name);
/* run at 10MHz */
- error = spi_configure(sa->sa_handle, SPI_MODE_0, 10000000);
+ error = spi_configure(self, sa->sa_handle, SPI_MODE_0, 10000000);
if (error) {
- aprint_error_dev(self,
- "failed to set Mode 0 @ 10MHz, error=%d\n", error);
return;
}
diff -r b17803897221 -r e8de49094dc4 sys/dev/spi/mcp3k.c
--- a/sys/dev/spi/mcp3k.c Wed Jan 19 05:05:45 2022 +0000
+++ b/sys/dev/spi/mcp3k.c Wed Jan 19 05:21:44 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mcp3k.c,v 1.3 2022/01/19 05:05:45 thorpej Exp $ */
+/* $NetBSD: mcp3k.c,v 1.4 2022/01/19 05:21:44 thorpej Exp $ */
/*-
* Copyright (c) 2015 The NetBSD Foundation, Inc.
@@ -205,10 +205,8 @@
(unsigned)model->bits);
/* configure for 1MHz */
- error = spi_configure(sa->sa_handle, SPI_MODE_0, 1000000);
+ error = spi_configure(self, sa->sa_handle, SPI_MODE_0, 1000000);
if (error) {
- aprint_error_dev(self,
- "failed to set Mode 0 @ 1MHz, error=%d\n", error);
return;
}
diff -r b17803897221 -r e8de49094dc4 sys/dev/spi/mcp48x1.c
--- a/sys/dev/spi/mcp48x1.c Wed Jan 19 05:05:45 2022 +0000
+++ b/sys/dev/spi/mcp48x1.c Wed Jan 19 05:21:44 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mcp48x1.c,v 1.2 2022/01/19 05:05:45 thorpej Exp $ */
+/* $NetBSD: mcp48x1.c,v 1.3 2022/01/19 05:21:44 thorpej Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: mcp48x1.c,v 1.2 2022/01/19 05:05:45 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mcp48x1.c,v 1.3 2022/01/19 05:21:44 thorpej Exp $");
/*
* Driver for Microchip MCP4801/MCP4811/MCP4821 DAC.
@@ -139,10 +139,8 @@
sc->sc_dm = &mcp48x1_models[cf_flags]; /* flag value defines model */
- error = spi_configure(sa->sa_handle, SPI_MODE_0, 20000000);
+ error = spi_configure(self, sa->sa_handle, SPI_MODE_0, 20000000);
if (error) {
- aprint_error_dev(self,
- "failed to set Mode 0 @ 20MHz, error=%d\n", error);
return;
}
diff -r b17803897221 -r e8de49094dc4 sys/dev/spi/oj6sh.c
--- a/sys/dev/spi/oj6sh.c Wed Jan 19 05:05:45 2022 +0000
+++ b/sys/dev/spi/oj6sh.c Wed Jan 19 05:21:44 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: oj6sh.c,v 1.10 2022/01/19 05:05:45 thorpej Exp $ */
+/* $NetBSD: oj6sh.c,v 1.11 2022/01/19 05:21:44 thorpej Exp $ */
/*
* Copyright (c) 2014 Genetec Corporation. All rights reserved.
@@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: oj6sh.c,v 1.10 2022/01/19 05:05:45 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: oj6sh.c,v 1.11 2022/01/19 05:21:44 thorpej Exp $");
#include "opt_oj6sh.h"
@@ -187,10 +187,8 @@
aprint_naive("\n");
aprint_normal(": OJ6SH-T25 Optical Joystick\n");
- error = spi_configure(sa->sa_handle, SPI_MODE_0, 2500000);
+ error = spi_configure(self, sa->sa_handle, SPI_MODE_0, 2500000);
if (error) {
- aprint_error_dev(self,
- "failed to set Mode 0 @ 2.5MHz, error=%d\n", error);
return;
}
diff -r b17803897221 -r e8de49094dc4 sys/dev/spi/scmdspi.c
--- a/sys/dev/spi/scmdspi.c Wed Jan 19 05:05:45 2022 +0000
+++ b/sys/dev/spi/scmdspi.c Wed Jan 19 05:21:44 2022 +0000
@@ -1,5 +1,5 @@
-/* $NetBSD: scmdspi.c,v 1.2 2022/01/19 05:05:45 thorpej Exp $ */
+/* $NetBSD: scmdspi.c,v 1.3 2022/01/19 05:21:44 thorpej Exp $ */
/*
* Copyright (c) 2021 Brad Spencer <brad%anduin.eldar.org@localhost>
@@ -18,7 +18,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: scmdspi.c,v 1.2 2022/01/19 05:05:45 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: scmdspi.c,v 1.3 2022/01/19 05:21:44 thorpej Exp $");
/*
* SPI driver for the Sparkfun Serial motor controller.
@@ -205,10 +205,8 @@
cv_init(&sc->sc_cond_dying, "scmdspidc");
/* configure for 1MHz and SPI mode 0 according to the data sheet */
- error = spi_configure(sa->sa_handle, SPI_MODE_0, 1000000);
+ error = spi_configure(self, sa->sa_handle, SPI_MODE_0, 1000000);
if (error) {
- aprint_error(": failed to set Mode 0 @ 1MHz, error=%d\n",
- error);
return;
}
diff -r b17803897221 -r e8de49094dc4 sys/dev/spi/spi.c
--- a/sys/dev/spi/spi.c Wed Jan 19 05:05:45 2022 +0000
+++ b/sys/dev/spi/spi.c Wed Jan 19 05:21:44 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: spi.c,v 1.19 2021/08/07 16:19:16 thorpej Exp $ */
+/* $NetBSD: spi.c,v 1.20 2022/01/19 05:21:44 thorpej Exp $ */
/*-
* Copyright (c) 2006 Urbana-Champaign Independent Media Center.
@@ -42,7 +42,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: spi.c,v 1.19 2021/08/07 16:19:16 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: spi.c,v 1.20 2022/01/19 05:21:44 thorpej Exp $");
#include "locators.h"
@@ -428,11 +428,14 @@
* returned.
*/
int
-spi_configure(struct spi_handle *sh, int mode, int speed)
+spi_configure(device_t dev __unused, struct spi_handle *sh, int mode, int speed)
{
sh->sh_mode = mode;
sh->sh_speed = speed;
+
+ /* No need to report errors; no failures. */
+
return 0;
}
diff -r b17803897221 -r e8de49094dc4 sys/dev/spi/spivar.h
--- a/sys/dev/spi/spivar.h Wed Jan 19 05:05:45 2022 +0000
+++ b/sys/dev/spi/spivar.h Wed Jan 19 05:21:44 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: spivar.h,v 1.10 2020/08/04 13:20:45 kardel Exp $ */
+/* $NetBSD: spivar.h,v 1.11 2022/01/19 05:21:44 thorpej Exp $ */
/*-
* Copyright (c) 2006 Urbana-Champaign Independent Media Center.
@@ -142,7 +142,7 @@
int spi_compatible_match(const struct spi_attach_args *, const cfdata_t,
const struct device_compatible_entry *);
-int spi_configure(struct spi_handle *, int, int);
+int spi_configure(device_t, struct spi_handle *, int, int);
int spi_transfer(struct spi_handle *, struct spi_transfer *);
void spi_transfer_init(struct spi_transfer *);
void spi_chunk_init(struct spi_chunk *, int, const uint8_t *, uint8_t *);
diff -r b17803897221 -r e8de49094dc4 sys/dev/spi/ssdfb_spi.c
--- a/sys/dev/spi/ssdfb_spi.c Wed Jan 19 05:05:45 2022 +0000
+++ b/sys/dev/spi/ssdfb_spi.c Wed Jan 19 05:21:44 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ssdfb_spi.c,v 1.12 2022/01/19 05:05:45 thorpej Exp $ */
+/* $NetBSD: ssdfb_spi.c,v 1.13 2022/01/19 05:21:44 thorpej Exp $ */
/*
* Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ssdfb_spi.c,v 1.12 2022/01/19 05:05:45 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ssdfb_spi.c,v 1.13 2022/01/19 05:21:44 thorpej Exp $");
#include <sys/param.h>
#include <sys/device.h>
@@ -130,10 +130,8 @@
/*
* SSD1306 and SSD1322 data sheets specify 100ns cycle time.
*/
- error = spi_configure(sa->sa_handle, SPI_MODE_0, 10000000);
+ error = spi_configure(self, sa->sa_handle, SPI_MODE_0, 10000000);
if (error) {
- aprint_error(": failed to set Mode 0 @ 10MHz, error=%d\n",
- error);
return;
}
diff -r b17803897221 -r e8de49094dc4 sys/dev/spi/tmp121.c
--- a/sys/dev/spi/tmp121.c Wed Jan 19 05:05:45 2022 +0000
+++ b/sys/dev/spi/tmp121.c Wed Jan 19 05:21:44 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tmp121.c,v 1.6 2022/01/19 05:05:45 thorpej Exp $ */
+/* $NetBSD: tmp121.c,v 1.7 2022/01/19 05:21:44 thorpej Exp $ */
/*-
* Copyright (c) 2006 Urbana-Champaign Independent Media Center.
@@ -42,7 +42,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tmp121.c,v 1.6 2022/01/19 05:05:45 thorpej Exp $");
Home |
Main Index |
Thread Index |
Old Index