Compare

d5a821f66047c2effd06147b84775f9b2ce0f4aa..4eac392e48fc0ddc6d5ac10d57aac7245c17d0d9

spi: spi-fsl-lpspi: pass struct fsl_lpspi_data instead of struct spi_controller if possible

Instead of passing a spi_controller pointer to functions and using
spi_controller_get_devdata() to get the struct fsl_lpspi_data pointer,
directly pass a struct fsl_lpspi_data pointer.

Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Reviewed-by: Frank Li <Frank.Li@nxp.com>
Link: https://patch.msgid.link/20261009-spi-fsl-lpspi-more-cleanups-v1-1-2d4549d5205e@pengutronix.de
Signed-off-by: Mark Brown <broonie@kernel.org>

Marc Kleine-Budde <mkl@pengutronix.de> · 2026-10-09 10:16 UTC · committed by Mark Brown

Browse files
9 files changed, +32 −34
modified drivers/base/regmap/regcache-maple.c
@@ -312,21 +312,16 @@ static void regcache_maple_exit(struct regmap *map)
312 312 struct maple_tree *mt = map->cache;
313 313 MA_STATE(mas, mt, 0, UINT_MAX);
314 314 unsigned int *entry;
315 - unsigned long flags;
316 315
317 316 /* if we've already been called then just return */
318 317 if (!mt)
319 318 return;
320 319
321 - /*
322 - * Register access may take the Maple lock from hard IRQ context, so
323 - * preserve its IRQ-safe lockdep state during teardown.
324 - */
325 - mas_lock_irqsave(&mas, flags);
320 + mas_lock(&mas);
326 321 mas_for_each(&mas, entry, UINT_MAX)
327 322 kfree(entry);
328 323 __mt_destroy(mt);
329 - mas_unlock_irqrestore(&mas, flags);
324 + mas_unlock(&mas);
330 325
331 326 kfree(mt);
332 327 map->cache = NULL;
modified drivers/base/regmap/regcache.c
@@ -225,7 +225,9 @@ int regcache_init(struct regmap *map, const struct regmap_config *config)
225 225 if (map->cache_ops->init) {
226 226 dev_dbg(map->dev, "Initializing %s cache\n",
227 227 map->cache_ops->name);
228 + map->lock(map->lock_arg);
228 229 ret = map->cache_ops->init(map);
230 + map->unlock(map->lock_arg);
229 231 if (ret)
230 232 goto err_free_reg_defaults;
231 233 }
@@ -257,7 +259,9 @@ err_free:
257 259 err_exit:
258 260 if (map->cache_ops->exit) {
259 261 dev_dbg(map->dev, "Destroying %s cache\n", map->cache_ops->name);
262 + map->lock(map->lock_arg);
260 263 map->cache_ops->exit(map);
264 + map->unlock(map->lock_arg);
261 265 }
262 266 err_free_reg_defaults:
263 267 kfree(map->reg_defaults);
@@ -277,7 +281,9 @@ void regcache_exit(struct regmap *map)
277 281 if (map->cache_ops->exit) {
278 282 dev_dbg(map->dev, "Destroying %s cache\n",
279 283 map->cache_ops->name);
284 + map->lock(map->lock_arg);
280 285 map->cache_ops->exit(map);
286 + map->unlock(map->lock_arg);
281 287 }
282 288
283 289 kfree(map->reg_defaults);
modified drivers/base/regmap/regmap-debugfs.c
@@ -664,7 +664,6 @@ void regmap_debugfs_exit(struct regmap *map)
664 664 {
665 665 if (map->debugfs) {
666 666 debugfs_remove_recursive(map->debugfs);
667 - map->debugfs = NULL;
668 667 mutex_lock(&map->cache_lock);
669 668 regmap_debugfs_free_dump_cache(map);
670 669 mutex_unlock(&map->cache_lock);
modified drivers/base/regmap/regmap-irq.c
@@ -963,7 +963,7 @@ int regmap_add_irq_chip_fwnode(struct fwnode_handle *fwnode,
963 963 return 0;
964 964
965 965 err_domain:
966 - irq_domain_remove(d->domain);
966 + /* Should really dispose of the domain but... */
967 967 err_mutex:
968 968 mutex_destroy(&d->lock);
969 969 lockdep_unregister_key(&d->lock_key);
modified drivers/base/regmap/regmap.c
@@ -1422,8 +1422,8 @@ int regmap_reinit_cache(struct regmap *map, const struct regmap_config *config)
1422 1422 {
1423 1423 int ret;
1424 1424
1425 - regmap_debugfs_exit(map);
1426 1425 regcache_exit(map);
1426 + regmap_debugfs_exit(map);
1427 1427
1428 1428 map->max_register = config->max_register;
1429 1429 map->max_register_is_set = map->max_register ?: config->max_register_is_0;
@@ -1440,16 +1440,12 @@ int regmap_reinit_cache(struct regmap *map, const struct regmap_config *config)
1440 1440 if (ret)
1441 1441 return ret;
1442 1442
1443 + regmap_debugfs_init(map);
1444 +
1443 1445 map->cache_bypass = false;
1444 1446 map->cache_only = false;
1445 1447
1446 - ret = regcache_init(map, config);
1447 - if (ret)
1448 - return ret;
1449 -
1450 - regmap_debugfs_init(map);
1451 -
1452 - return 0;
1448 + return regcache_init(map, config);
1453 1449 }
1454 1450 EXPORT_SYMBOL_GPL(regmap_reinit_cache);
1455 1451
@@ -1463,8 +1459,9 @@ void regmap_exit(struct regmap *map)
1463 1459 struct regmap_async *async;
1464 1460
1465 1461 regmap_detach_dev(map->dev, map);
1466 - regmap_debugfs_exit(map);
1467 1462 regcache_exit(map);
1463 +
1464 + regmap_debugfs_exit(map);
1468 1465 regmap_range_exit(map);
1469 1466 if (map->bus && map->bus->free_context)
1470 1467 map->bus->free_context(map->bus_context);
modified drivers/spi/spi-fsl-lpspi.c
@@ -550,11 +550,8 @@ static int fsl_lpspi_target_abort(struct spi_controller *controller)
550 550 return 0;
551 551 }
552 552
553 - static int fsl_lpspi_wait_for_completion(struct spi_controller *controller)
553 + static int fsl_lpspi_wait_for_completion(struct fsl_lpspi_data *fsl_lpspi)
554 554 {
555 - struct fsl_lpspi_data *fsl_lpspi =
556 - spi_controller_get_devdata(controller);
557 -
558 555 if (fsl_lpspi->is_target) {
559 556 if (wait_for_completion_interruptible(&fsl_lpspi->xfer_done) ||
560 557 fsl_lpspi->target_aborted) {
@@ -758,11 +755,9 @@ err:
758 755 return ret;
759 756 }
760 757
761 - static int fsl_lpspi_pio_transfer(struct spi_controller *controller,
758 + static int fsl_lpspi_pio_transfer(struct fsl_lpspi_data *fsl_lpspi,
762 759 struct spi_transfer *t)
763 760 {
764 - struct fsl_lpspi_data *fsl_lpspi =
765 - spi_controller_get_devdata(controller);
766 761 int ret;
767 762
768 763 fsl_lpspi->tx_buf = t->tx_buf;
@@ -774,7 +769,7 @@ static int fsl_lpspi_pio_transfer(struct spi_controller *controller,
774 769
775 770 fsl_lpspi_write_tx_fifo(fsl_lpspi);
776 771
777 - ret = fsl_lpspi_wait_for_completion(controller);
772 + ret = fsl_lpspi_wait_for_completion(fsl_lpspi);
778 773
779 774 fsl_lpspi_reset(fsl_lpspi);
780 775
@@ -803,7 +798,7 @@ static int fsl_lpspi_transfer_one(struct spi_controller *controller,
803 798 if (fsl_lpspi->usedma)
804 799 ret = fsl_lpspi_dma_transfer(controller, fsl_lpspi, t);
805 800 else
806 - ret = fsl_lpspi_pio_transfer(controller, t);
801 + ret = fsl_lpspi_pio_transfer(fsl_lpspi, t);
807 802 if (ret < 0)
808 803 return ret;
809 804
modified drivers/spi/spi-imx.c
@@ -1578,11 +1578,13 @@ static int spi_imx_dma_tx_data_handle(struct spi_imx_data *spi_imx,
1578 1578 dma_data->dma_len = ALIGN(dma_data->data_len, BYTES_PER_32BITS_WORD);
1579 1579 }
1580 1580
1581 - dma_data->dma_tx_buf = kzalloc(dma_data->dma_len, GFP_KERNEL);
1581 + dma_data->dma_tx_buf = kzalloc(DMA_CACHE_ALIGNED_LEN(dma_data->dma_len),
1582 + GFP_KERNEL);
1582 1583 if (!dma_data->dma_tx_buf)
1583 1584 return -ENOMEM;
1584 1585
1585 - dma_data->dma_rx_buf = kzalloc(dma_data->dma_len, GFP_KERNEL);
1586 + dma_data->dma_rx_buf = kzalloc(DMA_CACHE_ALIGNED_LEN(dma_data->dma_len),
1587 + GFP_KERNEL);
1586 1588 if (!dma_data->dma_rx_buf) {
1587 1589 kfree(dma_data->dma_tx_buf);
1588 1590 return -ENOMEM;
@@ -1920,7 +1922,8 @@ static int spi_imx_dma_package_transfer(struct spi_imx_data *spi_imx,
1920 1922
1921 1923 /* Trim the DMA RX buffer and copy the actual data to rx_buf */
1922 1924 dma_sync_single_for_cpu(controller->dma_rx->device->dev, dma_data->dma_rx_addr,
1923 - dma_data->dma_len, DMA_FROM_DEVICE);
1925 + DMA_CACHE_ALIGNED_LEN(dma_data->dma_len),
1926 + DMA_FROM_DEVICE);
1924 1927 spi_imx_dma_rx_data_handle(spi_imx, dma_data, transfer->rx_buf + spi_imx->rx_offset,
1925 1928 word_delay);
1926 1929 spi_imx->rx_offset += dma_data->data_len;
modified drivers/spi/spi-tegra114.c
@@ -859,6 +859,13 @@ static u32 tegra_spi_setup_transfer_one(struct spi_device *spi,
859 859 command1 |= SPI_BIT_LENGTH(bits_per_word - 1);
860 860 }
861 861
862 + /*
863 + * Re-assert the CS GPIO for every transfer: transfer_end() drops it
864 + * on cs_change, and the assert above only covers is_first_of_msg.
865 + */
866 + if (spi_get_csgpiod(spi, 0))
867 + gpiod_set_value(spi_get_csgpiod(spi, 0), 1);
868 +
862 869 return command1;
863 870 }
864 871
modified include/linux/maple_tree.h
@@ -507,13 +507,9 @@ struct ma_wr_state {
507 507 };
508 508
509 509 #define mas_lock(mas) spin_lock(&((mas)->tree->ma_lock))
510 - #define mas_lock_irqsave(mas, flags) \
511 - spin_lock_irqsave(&((mas)->tree->ma_lock), flags)
512 510 #define mas_lock_nested(mas, subclass) \
513 511 spin_lock_nested(&((mas)->tree->ma_lock), subclass)
514 512 #define mas_unlock(mas) spin_unlock(&((mas)->tree->ma_lock))
515 - #define mas_unlock_irqrestore(mas, flags) \
516 - spin_unlock_irqrestore(&((mas)->tree->ma_lock), flags)
517 513
518 514 /*
519 515 * Special values for ma_state.node.