mirror of
https://git.proxmox.com/git/mirror_ubuntu-kernels.git
synced 2026-01-03 23:56:46 +00:00
spi: switch to use modern name
Merge series from Yang Yingliang <yangyingliang@huawei.com>: After introducing devm_spi_alloc_host/spi_alloc_host(), the legacy named function devm_spi_alloc_master/spi_alloc_master() can be replaced. And also change other legacy name master/slave to modern name host/target or controller.
This commit is contained in:
commit
cb0713e620
@ -61,7 +61,7 @@ static inline int ar934x_spi_clk_div(struct ar934x_spi *sp, unsigned int freq)
|
||||
|
||||
static int ar934x_spi_setup(struct spi_device *spi)
|
||||
{
|
||||
struct ar934x_spi *sp = spi_controller_get_devdata(spi->master);
|
||||
struct ar934x_spi *sp = spi_controller_get_devdata(spi->controller);
|
||||
|
||||
if ((spi->max_speed_hz == 0) ||
|
||||
(spi->max_speed_hz > (sp->clk_freq / 2))) {
|
||||
@ -74,10 +74,10 @@ static int ar934x_spi_setup(struct spi_device *spi)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ar934x_spi_transfer_one_message(struct spi_controller *master,
|
||||
static int ar934x_spi_transfer_one_message(struct spi_controller *ctlr,
|
||||
struct spi_message *m)
|
||||
{
|
||||
struct ar934x_spi *sp = spi_controller_get_devdata(master);
|
||||
struct ar934x_spi *sp = spi_controller_get_devdata(ctlr);
|
||||
struct spi_transfer *t = NULL;
|
||||
struct spi_device *spi = m->spi;
|
||||
unsigned long trx_done, trx_cur;
|
||||
@ -150,7 +150,7 @@ static int ar934x_spi_transfer_one_message(struct spi_controller *master,
|
||||
|
||||
msg_done:
|
||||
m->status = stat;
|
||||
spi_finalize_current_message(master);
|
||||
spi_finalize_current_message(ctlr);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -183,7 +183,7 @@ static int ar934x_spi_probe(struct platform_device *pdev)
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
ctlr = devm_spi_alloc_master(&pdev->dev, sizeof(*sp));
|
||||
ctlr = devm_spi_alloc_host(&pdev->dev, sizeof(*sp));
|
||||
if (!ctlr) {
|
||||
dev_info(&pdev->dev, "failed to allocate spi controller\n");
|
||||
ret = -ENOMEM;
|
||||
|
||||
@ -100,7 +100,7 @@
|
||||
#define A3700_SPI_CLK_CAPT_EDGE BIT(7)
|
||||
|
||||
struct a3700_spi {
|
||||
struct spi_master *master;
|
||||
struct spi_controller *host;
|
||||
void __iomem *base;
|
||||
struct clk *clk;
|
||||
unsigned int irq;
|
||||
@ -174,7 +174,7 @@ static int a3700_spi_pin_mode_set(struct a3700_spi *a3700_spi,
|
||||
val |= A3700_SPI_ADDR_PIN;
|
||||
break;
|
||||
default:
|
||||
dev_err(&a3700_spi->master->dev, "wrong pin mode %u", pin_mode);
|
||||
dev_err(&a3700_spi->host->dev, "wrong pin mode %u", pin_mode);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
@ -278,7 +278,7 @@ static int a3700_spi_fifo_flush(struct a3700_spi *a3700_spi)
|
||||
|
||||
static void a3700_spi_init(struct a3700_spi *a3700_spi)
|
||||
{
|
||||
struct spi_master *master = a3700_spi->master;
|
||||
struct spi_controller *host = a3700_spi->host;
|
||||
u32 val;
|
||||
int i;
|
||||
|
||||
@ -295,14 +295,14 @@ static void a3700_spi_init(struct a3700_spi *a3700_spi)
|
||||
|
||||
/* Disable AUTO_CS and deactivate all chip-selects */
|
||||
a3700_spi_auto_cs_unset(a3700_spi);
|
||||
for (i = 0; i < master->num_chipselect; i++)
|
||||
for (i = 0; i < host->num_chipselect; i++)
|
||||
a3700_spi_deactivate_cs(a3700_spi, i);
|
||||
|
||||
/* Enable FIFO mode */
|
||||
a3700_spi_fifo_mode_set(a3700_spi, true);
|
||||
|
||||
/* Set SPI mode */
|
||||
a3700_spi_mode_set(a3700_spi, master->mode_bits);
|
||||
a3700_spi_mode_set(a3700_spi, host->mode_bits);
|
||||
|
||||
/* Reset counters */
|
||||
spireg_write(a3700_spi, A3700_SPI_IF_HDR_CNT_REG, 0);
|
||||
@ -315,11 +315,11 @@ static void a3700_spi_init(struct a3700_spi *a3700_spi)
|
||||
|
||||
static irqreturn_t a3700_spi_interrupt(int irq, void *dev_id)
|
||||
{
|
||||
struct spi_master *master = dev_id;
|
||||
struct spi_controller *host = dev_id;
|
||||
struct a3700_spi *a3700_spi;
|
||||
u32 cause;
|
||||
|
||||
a3700_spi = spi_master_get_devdata(master);
|
||||
a3700_spi = spi_controller_get_devdata(host);
|
||||
|
||||
/* Get interrupt causes */
|
||||
cause = spireg_read(a3700_spi, A3700_SPI_INT_STAT_REG);
|
||||
@ -344,7 +344,7 @@ static bool a3700_spi_wait_completion(struct spi_device *spi)
|
||||
unsigned int ctrl_reg;
|
||||
unsigned long timeout_jiffies;
|
||||
|
||||
a3700_spi = spi_master_get_devdata(spi->master);
|
||||
a3700_spi = spi_controller_get_devdata(spi->controller);
|
||||
|
||||
/* SPI interrupt is edge-triggered, which means an interrupt will
|
||||
* be generated only when detecting a specific status bit changed
|
||||
@ -393,7 +393,7 @@ static bool a3700_spi_transfer_wait(struct spi_device *spi,
|
||||
{
|
||||
struct a3700_spi *a3700_spi;
|
||||
|
||||
a3700_spi = spi_master_get_devdata(spi->master);
|
||||
a3700_spi = spi_controller_get_devdata(spi->controller);
|
||||
a3700_spi->wait_mask = bit_mask;
|
||||
|
||||
return a3700_spi_wait_completion(spi);
|
||||
@ -417,7 +417,7 @@ static void a3700_spi_transfer_setup(struct spi_device *spi,
|
||||
{
|
||||
struct a3700_spi *a3700_spi;
|
||||
|
||||
a3700_spi = spi_master_get_devdata(spi->master);
|
||||
a3700_spi = spi_controller_get_devdata(spi->controller);
|
||||
|
||||
a3700_spi_clock_set(a3700_spi, xfer->speed_hz);
|
||||
|
||||
@ -434,7 +434,7 @@ static void a3700_spi_transfer_setup(struct spi_device *spi,
|
||||
|
||||
static void a3700_spi_set_cs(struct spi_device *spi, bool enable)
|
||||
{
|
||||
struct a3700_spi *a3700_spi = spi_master_get_devdata(spi->master);
|
||||
struct a3700_spi *a3700_spi = spi_controller_get_devdata(spi->controller);
|
||||
|
||||
if (!enable)
|
||||
a3700_spi_activate_cs(a3700_spi, spi->chip_select);
|
||||
@ -565,10 +565,10 @@ static void a3700_spi_transfer_abort_fifo(struct a3700_spi *a3700_spi)
|
||||
spireg_write(a3700_spi, A3700_SPI_IF_CFG_REG, val);
|
||||
}
|
||||
|
||||
static int a3700_spi_prepare_message(struct spi_master *master,
|
||||
static int a3700_spi_prepare_message(struct spi_controller *host,
|
||||
struct spi_message *message)
|
||||
{
|
||||
struct a3700_spi *a3700_spi = spi_master_get_devdata(master);
|
||||
struct a3700_spi *a3700_spi = spi_controller_get_devdata(host);
|
||||
struct spi_device *spi = message->spi;
|
||||
int ret;
|
||||
|
||||
@ -588,11 +588,11 @@ static int a3700_spi_prepare_message(struct spi_master *master,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int a3700_spi_transfer_one_fifo(struct spi_master *master,
|
||||
static int a3700_spi_transfer_one_fifo(struct spi_controller *host,
|
||||
struct spi_device *spi,
|
||||
struct spi_transfer *xfer)
|
||||
{
|
||||
struct a3700_spi *a3700_spi = spi_master_get_devdata(master);
|
||||
struct a3700_spi *a3700_spi = spi_controller_get_devdata(host);
|
||||
int ret = 0, timeout = A3700_SPI_TIMEOUT;
|
||||
unsigned int nbits = 0, byte_len;
|
||||
u32 val;
|
||||
@ -732,16 +732,16 @@ static int a3700_spi_transfer_one_fifo(struct spi_master *master,
|
||||
error:
|
||||
a3700_spi_transfer_abort_fifo(a3700_spi);
|
||||
out:
|
||||
spi_finalize_current_transfer(master);
|
||||
spi_finalize_current_transfer(host);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int a3700_spi_transfer_one_full_duplex(struct spi_master *master,
|
||||
static int a3700_spi_transfer_one_full_duplex(struct spi_controller *host,
|
||||
struct spi_device *spi,
|
||||
struct spi_transfer *xfer)
|
||||
{
|
||||
struct a3700_spi *a3700_spi = spi_master_get_devdata(master);
|
||||
struct a3700_spi *a3700_spi = spi_controller_get_devdata(host);
|
||||
u32 val;
|
||||
|
||||
/* Disable FIFO mode */
|
||||
@ -777,27 +777,27 @@ static int a3700_spi_transfer_one_full_duplex(struct spi_master *master,
|
||||
|
||||
}
|
||||
|
||||
spi_finalize_current_transfer(master);
|
||||
spi_finalize_current_transfer(host);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int a3700_spi_transfer_one(struct spi_master *master,
|
||||
static int a3700_spi_transfer_one(struct spi_controller *host,
|
||||
struct spi_device *spi,
|
||||
struct spi_transfer *xfer)
|
||||
{
|
||||
a3700_spi_transfer_setup(spi, xfer);
|
||||
|
||||
if (xfer->tx_buf && xfer->rx_buf)
|
||||
return a3700_spi_transfer_one_full_duplex(master, spi, xfer);
|
||||
return a3700_spi_transfer_one_full_duplex(host, spi, xfer);
|
||||
|
||||
return a3700_spi_transfer_one_fifo(master, spi, xfer);
|
||||
return a3700_spi_transfer_one_fifo(host, spi, xfer);
|
||||
}
|
||||
|
||||
static int a3700_spi_unprepare_message(struct spi_master *master,
|
||||
static int a3700_spi_unprepare_message(struct spi_controller *host,
|
||||
struct spi_message *message)
|
||||
{
|
||||
struct a3700_spi *a3700_spi = spi_master_get_devdata(master);
|
||||
struct a3700_spi *a3700_spi = spi_controller_get_devdata(host);
|
||||
|
||||
clk_disable(a3700_spi->clk);
|
||||
|
||||
@ -815,14 +815,14 @@ static int a3700_spi_probe(struct platform_device *pdev)
|
||||
{
|
||||
struct device *dev = &pdev->dev;
|
||||
struct device_node *of_node = dev->of_node;
|
||||
struct spi_master *master;
|
||||
struct spi_controller *host;
|
||||
struct a3700_spi *spi;
|
||||
u32 num_cs = 0;
|
||||
int irq, ret = 0;
|
||||
|
||||
master = spi_alloc_master(dev, sizeof(*spi));
|
||||
if (!master) {
|
||||
dev_err(dev, "master allocation failed\n");
|
||||
host = spi_alloc_host(dev, sizeof(*spi));
|
||||
if (!host) {
|
||||
dev_err(dev, "host allocation failed\n");
|
||||
ret = -ENOMEM;
|
||||
goto out;
|
||||
}
|
||||
@ -833,23 +833,23 @@ static int a3700_spi_probe(struct platform_device *pdev)
|
||||
goto error;
|
||||
}
|
||||
|
||||
master->bus_num = pdev->id;
|
||||
master->dev.of_node = of_node;
|
||||
master->mode_bits = SPI_MODE_3;
|
||||
master->num_chipselect = num_cs;
|
||||
master->bits_per_word_mask = SPI_BPW_MASK(8) | SPI_BPW_MASK(32);
|
||||
master->prepare_message = a3700_spi_prepare_message;
|
||||
master->transfer_one = a3700_spi_transfer_one;
|
||||
master->unprepare_message = a3700_spi_unprepare_message;
|
||||
master->set_cs = a3700_spi_set_cs;
|
||||
master->mode_bits |= (SPI_RX_DUAL | SPI_TX_DUAL |
|
||||
host->bus_num = pdev->id;
|
||||
host->dev.of_node = of_node;
|
||||
host->mode_bits = SPI_MODE_3;
|
||||
host->num_chipselect = num_cs;
|
||||
host->bits_per_word_mask = SPI_BPW_MASK(8) | SPI_BPW_MASK(32);
|
||||
host->prepare_message = a3700_spi_prepare_message;
|
||||
host->transfer_one = a3700_spi_transfer_one;
|
||||
host->unprepare_message = a3700_spi_unprepare_message;
|
||||
host->set_cs = a3700_spi_set_cs;
|
||||
host->mode_bits |= (SPI_RX_DUAL | SPI_TX_DUAL |
|
||||
SPI_RX_QUAD | SPI_TX_QUAD);
|
||||
|
||||
platform_set_drvdata(pdev, master);
|
||||
platform_set_drvdata(pdev, host);
|
||||
|
||||
spi = spi_master_get_devdata(master);
|
||||
spi = spi_controller_get_devdata(host);
|
||||
|
||||
spi->master = master;
|
||||
spi->host = host;
|
||||
|
||||
spi->base = devm_platform_ioremap_resource(pdev, 0);
|
||||
if (IS_ERR(spi->base)) {
|
||||
@ -878,23 +878,23 @@ static int a3700_spi_probe(struct platform_device *pdev)
|
||||
goto error;
|
||||
}
|
||||
|
||||
master->max_speed_hz = min_t(unsigned long, A3700_SPI_MAX_SPEED_HZ,
|
||||
host->max_speed_hz = min_t(unsigned long, A3700_SPI_MAX_SPEED_HZ,
|
||||
clk_get_rate(spi->clk));
|
||||
master->min_speed_hz = DIV_ROUND_UP(clk_get_rate(spi->clk),
|
||||
host->min_speed_hz = DIV_ROUND_UP(clk_get_rate(spi->clk),
|
||||
A3700_SPI_MAX_PRESCALE);
|
||||
|
||||
a3700_spi_init(spi);
|
||||
|
||||
ret = devm_request_irq(dev, spi->irq, a3700_spi_interrupt, 0,
|
||||
dev_name(dev), master);
|
||||
dev_name(dev), host);
|
||||
if (ret) {
|
||||
dev_err(dev, "could not request IRQ: %d\n", ret);
|
||||
goto error_clk;
|
||||
}
|
||||
|
||||
ret = devm_spi_register_master(dev, master);
|
||||
ret = devm_spi_register_controller(dev, host);
|
||||
if (ret) {
|
||||
dev_err(dev, "Failed to register master\n");
|
||||
dev_err(dev, "Failed to register host\n");
|
||||
goto error_clk;
|
||||
}
|
||||
|
||||
@ -903,15 +903,15 @@ static int a3700_spi_probe(struct platform_device *pdev)
|
||||
error_clk:
|
||||
clk_unprepare(spi->clk);
|
||||
error:
|
||||
spi_master_put(master);
|
||||
spi_controller_put(host);
|
||||
out:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int a3700_spi_remove(struct platform_device *pdev)
|
||||
{
|
||||
struct spi_master *master = platform_get_drvdata(pdev);
|
||||
struct a3700_spi *spi = spi_master_get_devdata(master);
|
||||
struct spi_controller *host = platform_get_drvdata(pdev);
|
||||
struct a3700_spi *spi = spi_controller_get_devdata(host);
|
||||
|
||||
clk_unprepare(spi->clk);
|
||||
|
||||
|
||||
@ -58,7 +58,7 @@ static inline void ath79_spi_wr(struct ath79_spi *sp, unsigned int reg, u32 val)
|
||||
|
||||
static inline struct ath79_spi *ath79_spidev_to_sp(struct spi_device *spi)
|
||||
{
|
||||
return spi_master_get_devdata(spi->master);
|
||||
return spi_controller_get_devdata(spi->controller);
|
||||
}
|
||||
|
||||
static inline void ath79_spi_delay(struct ath79_spi *sp, unsigned int nsecs)
|
||||
@ -120,7 +120,7 @@ static u32 ath79_spi_txrx_mode0(struct spi_device *spi, unsigned int nsecs,
|
||||
else
|
||||
out = ioc & ~AR71XX_SPI_IOC_DO;
|
||||
|
||||
/* setup MSB (to slave) on trailing edge */
|
||||
/* setup MSB (to target) on trailing edge */
|
||||
ath79_spi_wr(sp, AR71XX_SPI_REG_IOC, out);
|
||||
ath79_spi_delay(sp, nsecs);
|
||||
ath79_spi_wr(sp, AR71XX_SPI_REG_IOC, out | AR71XX_SPI_IOC_CLK);
|
||||
@ -168,28 +168,28 @@ static const struct spi_controller_mem_ops ath79_mem_ops = {
|
||||
|
||||
static int ath79_spi_probe(struct platform_device *pdev)
|
||||
{
|
||||
struct spi_master *master;
|
||||
struct spi_controller *host;
|
||||
struct ath79_spi *sp;
|
||||
unsigned long rate;
|
||||
int ret;
|
||||
|
||||
master = spi_alloc_master(&pdev->dev, sizeof(*sp));
|
||||
if (master == NULL) {
|
||||
dev_err(&pdev->dev, "failed to allocate spi master\n");
|
||||
host = spi_alloc_host(&pdev->dev, sizeof(*sp));
|
||||
if (host == NULL) {
|
||||
dev_err(&pdev->dev, "failed to allocate spi host\n");
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
sp = spi_master_get_devdata(master);
|
||||
master->dev.of_node = pdev->dev.of_node;
|
||||
sp = spi_controller_get_devdata(host);
|
||||
host->dev.of_node = pdev->dev.of_node;
|
||||
platform_set_drvdata(pdev, sp);
|
||||
|
||||
master->use_gpio_descriptors = true;
|
||||
master->bits_per_word_mask = SPI_BPW_RANGE_MASK(1, 32);
|
||||
master->flags = SPI_MASTER_GPIO_SS;
|
||||
master->num_chipselect = 3;
|
||||
master->mem_ops = &ath79_mem_ops;
|
||||
host->use_gpio_descriptors = true;
|
||||
host->bits_per_word_mask = SPI_BPW_RANGE_MASK(1, 32);
|
||||
host->flags = SPI_MASTER_GPIO_SS;
|
||||
host->num_chipselect = 3;
|
||||
host->mem_ops = &ath79_mem_ops;
|
||||
|
||||
sp->bitbang.master = master;
|
||||
sp->bitbang.master = host;
|
||||
sp->bitbang.chipselect = ath79_spi_chipselect;
|
||||
sp->bitbang.txrx_word[SPI_MODE_0] = ath79_spi_txrx_mode0;
|
||||
sp->bitbang.flags = SPI_CS_HIGH;
|
||||
@ -197,18 +197,18 @@ static int ath79_spi_probe(struct platform_device *pdev)
|
||||
sp->base = devm_platform_ioremap_resource(pdev, 0);
|
||||
if (IS_ERR(sp->base)) {
|
||||
ret = PTR_ERR(sp->base);
|
||||
goto err_put_master;
|
||||
goto err_put_host;
|
||||
}
|
||||
|
||||
sp->clk = devm_clk_get(&pdev->dev, "ahb");
|
||||
if (IS_ERR(sp->clk)) {
|
||||
ret = PTR_ERR(sp->clk);
|
||||
goto err_put_master;
|
||||
goto err_put_host;
|
||||
}
|
||||
|
||||
ret = clk_prepare_enable(sp->clk);
|
||||
if (ret)
|
||||
goto err_put_master;
|
||||
goto err_put_host;
|
||||
|
||||
rate = DIV_ROUND_UP(clk_get_rate(sp->clk), MHZ);
|
||||
if (!rate) {
|
||||
@ -231,8 +231,8 @@ err_disable:
|
||||
ath79_spi_disable(sp);
|
||||
err_clk_disable:
|
||||
clk_disable_unprepare(sp->clk);
|
||||
err_put_master:
|
||||
spi_master_put(sp->bitbang.master);
|
||||
err_put_host:
|
||||
spi_controller_put(host);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@ -244,7 +244,7 @@ static int ath79_spi_remove(struct platform_device *pdev)
|
||||
spi_bitbang_stop(&sp->bitbang);
|
||||
ath79_spi_disable(sp);
|
||||
clk_disable_unprepare(sp->clk);
|
||||
spi_master_put(sp->bitbang.master);
|
||||
spi_controller_put(sp->bitbang.master);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user