hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/drivers/spi/spi-clps711x.c
....@@ -1,17 +1,13 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * CLPS711X SPI bus driver
34 *
45 * Copyright (C) 2012-2016 Alexander Shiyan <shc_work@mail.ru>
5
- *
6
- * This program is free software; you can redistribute it and/or modify
7
- * it under the terms of the GNU General Public License as published by
8
- * the Free Software Foundation; either version 2 of the License, or
9
- * (at your option) any later version.
106 */
117
128 #include <linux/io.h>
139 #include <linux/clk.h>
14
-#include <linux/gpio.h>
10
+#include <linux/gpio/consumer.h>
1511 #include <linux/module.h>
1612 #include <linux/interrupt.h>
1713 #include <linux/platform_device.h>
....@@ -35,25 +31,6 @@
3531 unsigned int bpw;
3632 int len;
3733 };
38
-
39
-static int spi_clps711x_setup(struct spi_device *spi)
40
-{
41
- if (!spi->controller_state) {
42
- int ret;
43
-
44
- ret = devm_gpio_request(&spi->master->dev, spi->cs_gpio,
45
- dev_name(&spi->master->dev));
46
- if (ret)
47
- return ret;
48
-
49
- spi->controller_state = spi;
50
- }
51
-
52
- /* We are expect that SPI-device is not selected */
53
- gpio_direction_output(spi->cs_gpio, !(spi->mode & SPI_CS_HIGH));
54
-
55
- return 0;
56
-}
5734
5835 static int spi_clps711x_prepare_message(struct spi_master *master,
5936 struct spi_message *msg)
....@@ -114,7 +91,6 @@
11491 {
11592 struct spi_clps711x_data *hw;
11693 struct spi_master *master;
117
- struct resource *res;
11894 int irq, ret;
11995
12096 irq = platform_get_irq(pdev, 0);
....@@ -125,11 +101,11 @@
125101 if (!master)
126102 return -ENOMEM;
127103
104
+ master->use_gpio_descriptors = true;
128105 master->bus_num = -1;
129106 master->mode_bits = SPI_CPHA | SPI_CS_HIGH;
130107 master->bits_per_word_mask = SPI_BPW_RANGE_MASK(1, 8);
131108 master->dev.of_node = pdev->dev.of_node;
132
- master->setup = spi_clps711x_setup;
133109 master->prepare_message = spi_clps711x_prepare_message;
134110 master->transfer_one = spi_clps711x_transfer_one;
135111
....@@ -148,8 +124,7 @@
148124 goto err_out;
149125 }
150126
151
- res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
152
- hw->syncio = devm_ioremap_resource(&pdev->dev, res);
127
+ hw->syncio = devm_platform_ioremap_resource(pdev, 0);
153128 if (IS_ERR(hw->syncio)) {
154129 ret = PTR_ERR(hw->syncio);
155130 goto err_out;