--- zzzz-none-000/linux-3.10.107/drivers/spi/spi-sc18is602.c 2017-06-27 09:49:32.000000000 +0000 +++ scorpion-7490-727/linux-3.10.107/drivers/spi/spi-sc18is602.c 2021-02-04 17:41:59.000000000 +0000 @@ -12,10 +12,6 @@ * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include @@ -183,24 +179,9 @@ static int sc18is602_check_transfer(struct spi_device *spi, struct spi_transfer *t, int tlen) { - int bpw; - uint32_t hz; - if (t && t->len + tlen > SC18IS602_BUFSIZ) return -EINVAL; - bpw = spi->bits_per_word; - if (t && t->bits_per_word) - bpw = t->bits_per_word; - if (bpw != 8) - return -EINVAL; - - hz = spi->max_speed_hz; - if (t && t->speed_hz) - hz = t->speed_hz; - if (hz == 0) - return -EINVAL; - return 0; } @@ -212,22 +193,15 @@ struct spi_transfer *t; int status = 0; - /* SC18IS602 does not support CS2 */ - if (hw->id == sc18is602 && spi->chip_select == 2) { - status = -ENXIO; - goto error; - } - hw->tlen = 0; list_for_each_entry(t, &m->transfers, transfer_list) { - u32 hz = t->speed_hz ? : spi->max_speed_hz; bool do_transfer; status = sc18is602_check_transfer(spi, t, hw->tlen); if (status < 0) break; - status = sc18is602_setup_transfer(hw, hz, spi->mode); + status = sc18is602_setup_transfer(hw, t->speed_hz, spi->mode); if (status < 0) break; @@ -245,7 +219,6 @@ if (t->delay_usecs) udelay(t->delay_usecs); } -error: m->status = status; spi_finalize_current_message(master); @@ -254,13 +227,13 @@ static int sc18is602_setup(struct spi_device *spi) { - if (!spi->bits_per_word) - spi->bits_per_word = 8; + struct sc18is602 *hw = spi_master_get_devdata(spi->master); - if (spi->mode & ~(SPI_CPHA | SPI_CPOL | SPI_LSB_FIRST)) - return -EINVAL; + /* SC18IS602 does not support CS2 */ + if (hw->id == sc18is602 && spi->chip_select == 2) + return -ENXIO; - return sc18is602_check_transfer(spi, NULL, 0); + return 0; } static int sc18is602_probe(struct i2c_client *client, @@ -313,13 +286,16 @@ hw->freq = SC18IS602_CLOCK; break; } - master->bus_num = client->adapter->nr; + master->bus_num = np ? -1 : client->adapter->nr; master->mode_bits = SPI_CPHA | SPI_CPOL | SPI_LSB_FIRST; + master->bits_per_word_mask = SPI_BPW_MASK(8); master->setup = sc18is602_setup; master->transfer_one_message = sc18is602_transfer_one; master->dev.of_node = np; + master->min_speed_hz = hw->freq / 128; + master->max_speed_hz = hw->freq / 4; - error = spi_register_master(master); + error = devm_spi_register_master(dev, master); if (error) goto error_reg; @@ -330,16 +306,6 @@ return error; } -static int sc18is602_remove(struct i2c_client *client) -{ - struct sc18is602 *hw = i2c_get_clientdata(client); - struct spi_master *master = hw->master; - - spi_unregister_master(master); - - return 0; -} - static const struct i2c_device_id sc18is602_id[] = { { "sc18is602", sc18is602 }, { "sc18is602b", sc18is602b }, @@ -353,7 +319,6 @@ .name = "sc18is602", }, .probe = sc18is602_probe, - .remove = sc18is602_remove, .id_table = sc18is602_id, };