Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
linux
Commits
db04e170
Commit
db04e170
authored
Sep 01, 2013
by
Mark Brown
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'spi/topic/checks' into spi-next
parents
788a7396
56ede94a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
1 deletion
+24
-1
drivers/spi/spi.c
drivers/spi/spi.c
+18
-1
include/linux/spi/spi.h
include/linux/spi/spi.h
+6
-0
No files found.
drivers/spi/spi.c
View file @
db04e170
...
...
@@ -1351,6 +1351,11 @@ static int __spi_async(struct spi_device *spi, struct spi_message *message)
struct
spi_master
*
master
=
spi
->
master
;
struct
spi_transfer
*
xfer
;
if
(
list_empty
(
&
message
->
transfers
))
return
-
EINVAL
;
if
(
!
message
->
complete
)
return
-
EINVAL
;
/* Half-duplex links include original MicroWire, and ones with
* only one data pin like SPI_3WIRE (switches direction) or where
* either MOSI or MISO is missing. They can also be caused by
...
...
@@ -1377,8 +1382,13 @@ static int __spi_async(struct spi_device *spi, struct spi_message *message)
list_for_each_entry
(
xfer
,
&
message
->
transfers
,
transfer_list
)
{
if
(
!
xfer
->
bits_per_word
)
xfer
->
bits_per_word
=
spi
->
bits_per_word
;
if
(
!
xfer
->
speed_hz
)
if
(
!
xfer
->
speed_hz
)
{
xfer
->
speed_hz
=
spi
->
max_speed_hz
;
if
(
master
->
max_speed_hz
&&
xfer
->
speed_hz
>
master
->
max_speed_hz
)
xfer
->
speed_hz
=
master
->
max_speed_hz
;
}
if
(
master
->
bits_per_word_mask
)
{
/* Only 32 bits fit in the mask */
if
(
xfer
->
bits_per_word
>
32
)
...
...
@@ -1387,6 +1397,13 @@ static int __spi_async(struct spi_device *spi, struct spi_message *message)
BIT
(
xfer
->
bits_per_word
-
1
)))
return
-
EINVAL
;
}
if
(
xfer
->
speed_hz
&&
master
->
min_speed_hz
&&
xfer
->
speed_hz
<
master
->
min_speed_hz
)
return
-
EINVAL
;
if
(
xfer
->
speed_hz
&&
master
->
max_speed_hz
&&
xfer
->
speed_hz
>
master
->
max_speed_hz
)
return
-
EINVAL
;
}
message
->
spi
=
spi
;
...
...
include/linux/spi/spi.h
View file @
db04e170
...
...
@@ -233,6 +233,8 @@ static inline void spi_unregister_driver(struct spi_driver *sdrv)
* suported. If set, the SPI core will reject any transfer with an
* unsupported bits_per_word. If not set, this value is simply ignored,
* and it's up to the individual driver to perform any validation.
* @min_speed_hz: Lowest supported transfer speed
* @max_speed_hz: Highest supported transfer speed
* @flags: other constraints relevant to this driver
* @bus_lock_spinlock: spinlock for SPI bus locking
* @bus_lock_mutex: mutex for SPI bus locking
...
...
@@ -312,6 +314,10 @@ struct spi_master {
#define SPI_BIT_MASK(bits) (((bits) == 32) ? ~0U : (BIT(bits) - 1))
#define SPI_BPW_RANGE_MASK(min, max) (SPI_BIT_MASK(max) - SPI_BIT_MASK(min - 1))
/* limits on transfer speed */
u32
min_speed_hz
;
u32
max_speed_hz
;
/* other constraints relevant to this driver */
u16
flags
;
#define SPI_MASTER_HALF_DUPLEX BIT(0)
/* can't do full duplex */
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment