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
Kirill Smelkov
linux
Commits
bc645099
Commit
bc645099
authored
Aug 31, 2015
by
Mark Brown
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'spi/topic/core' into spi-next
parents
af211211
63ab645f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
8 deletions
+21
-8
drivers/spi/spi.c
drivers/spi/spi.c
+21
-8
No files found.
drivers/spi/spi.c
View file @
bc645099
...
@@ -1740,6 +1740,20 @@ EXPORT_SYMBOL_GPL(spi_busnum_to_master);
...
@@ -1740,6 +1740,20 @@ EXPORT_SYMBOL_GPL(spi_busnum_to_master);
* other core methods are currently defined as inline functions.
* other core methods are currently defined as inline functions.
*/
*/
static
int
__spi_validate_bits_per_word
(
struct
spi_master
*
master
,
u8
bits_per_word
)
{
if
(
master
->
bits_per_word_mask
)
{
/* Only 32 bits fit in the mask */
if
(
bits_per_word
>
32
)
return
-
EINVAL
;
if
(
!
(
master
->
bits_per_word_mask
&
SPI_BPW_MASK
(
bits_per_word
)))
return
-
EINVAL
;
}
return
0
;
}
/**
/**
* spi_setup - setup SPI mode and clock rate
* spi_setup - setup SPI mode and clock rate
* @spi: the device whose settings are being modified
* @spi: the device whose settings are being modified
...
@@ -1798,6 +1812,9 @@ int spi_setup(struct spi_device *spi)
...
@@ -1798,6 +1812,9 @@ int spi_setup(struct spi_device *spi)
if
(
!
spi
->
bits_per_word
)
if
(
!
spi
->
bits_per_word
)
spi
->
bits_per_word
=
8
;
spi
->
bits_per_word
=
8
;
if
(
__spi_validate_bits_per_word
(
spi
->
master
,
spi
->
bits_per_word
))
return
-
EINVAL
;
if
(
!
spi
->
max_speed_hz
)
if
(
!
spi
->
max_speed_hz
)
spi
->
max_speed_hz
=
spi
->
master
->
max_speed_hz
;
spi
->
max_speed_hz
=
spi
->
master
->
max_speed_hz
;
...
@@ -1860,19 +1877,15 @@ static int __spi_validate(struct spi_device *spi, struct spi_message *message)
...
@@ -1860,19 +1877,15 @@ static int __spi_validate(struct spi_device *spi, struct spi_message *message)
if
(
!
xfer
->
speed_hz
)
if
(
!
xfer
->
speed_hz
)
xfer
->
speed_hz
=
spi
->
max_speed_hz
;
xfer
->
speed_hz
=
spi
->
max_speed_hz
;
if
(
!
xfer
->
speed_hz
)
xfer
->
speed_hz
=
master
->
max_speed_hz
;
if
(
master
->
max_speed_hz
&&
if
(
master
->
max_speed_hz
&&
xfer
->
speed_hz
>
master
->
max_speed_hz
)
xfer
->
speed_hz
>
master
->
max_speed_hz
)
xfer
->
speed_hz
=
master
->
max_speed_hz
;
xfer
->
speed_hz
=
master
->
max_speed_hz
;
if
(
master
->
bits_per_word_mask
)
{
if
(
__spi_validate_bits_per_word
(
master
,
xfer
->
bits_per_word
))
/* Only 32 bits fit in the mask */
return
-
EINVAL
;
if
(
xfer
->
bits_per_word
>
32
)
return
-
EINVAL
;
if
(
!
(
master
->
bits_per_word_mask
&
BIT
(
xfer
->
bits_per_word
-
1
)))
return
-
EINVAL
;
}
/*
/*
* SPI transfer length should be multiple of SPI word size
* SPI transfer length should be multiple of SPI word size
...
...
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