Skip to content

Commit 331f567

Browse files
pcercueinunojsa
authored andcommitted
iio: buffer-dma: sync write support with upstream
This is one more syncup with upstream for the write support. The public APIs (and users of it) were also properly updated to use the same API#s as upstream. Ony difference is because of the cf_axi_dds driver where we need custom ops and driver_data. Changes are also done taking into account legacy MMAP support. Signed-off-by: Nuno Sa <nuno.sa@analog.com>
1 parent 16dd49b commit 331f567

22 files changed

+294
-433
lines changed

drivers/iio/adc/ad4000.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -988,8 +988,7 @@ static int ad4000_probe(struct spi_device *spi)
988988
dev_err_probe(dev, ret, "PWM setup failed\n");
989989

990990
ret = devm_iio_dmaengine_buffer_setup(indio_dev->dev.parent,
991-
indio_dev, "rx",
992-
IIO_BUFFER_DIRECTION_IN);
991+
indio_dev, "rx");
993992
if (ret)
994993
return ret;
995994

drivers/iio/adc/ad4134.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -444,8 +444,7 @@ static int ad4134_probe(struct spi_device *spi)
444444
if (ret)
445445
return ret;
446446

447-
ret = devm_iio_dmaengine_buffer_setup(dev, indio_dev, "rx",
448-
IIO_BUFFER_DIRECTION_IN);
447+
ret = devm_iio_dmaengine_buffer_setup(dev, indio_dev, "rx");
449448
if (ret)
450449
return dev_err_probe(dev, ret,
451450
"Failed to allocate IIO DMA buffer\n");

drivers/iio/adc/ad4630.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1546,8 +1546,7 @@ static int ad4630_probe(struct spi_device *spi)
15461546
indio_dev->available_scan_masks = st->chip->available_masks;
15471547
indio_dev->setup_ops = &ad4630_buffer_setup_ops;
15481548

1549-
ret = devm_iio_dmaengine_buffer_setup(dev, indio_dev, "rx",
1550-
IIO_BUFFER_DIRECTION_IN);
1549+
ret = devm_iio_dmaengine_buffer_setup(dev, indio_dev, "rx");
15511550
if (ret)
15521551
return dev_err_probe(dev, ret,
15531552
"Failed to get DMA buffer\n");

drivers/iio/adc/ad7768-1.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -848,8 +848,7 @@ static int ad7768_hardware_buffer_alloc(struct iio_dev *indio_dev)
848848
{
849849
indio_dev->setup_ops = &ad7768_buffer_ops;
850850
return devm_iio_dmaengine_buffer_setup(indio_dev->dev.parent,
851-
indio_dev, "rx",
852-
IIO_BUFFER_DIRECTION_IN);
851+
indio_dev, "rx");
853852
}
854853

855854
static int ad7768_set_channel_label(struct iio_dev *indio_dev,

drivers/iio/adc/ad7768.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -666,7 +666,7 @@ static int ad7768_register(struct ad7768_state *st, struct iio_dev *indio_dev)
666666
indio_dev->available_scan_masks = ad7768_available_scan_masks;
667667

668668
ret = devm_iio_dmaengine_buffer_setup(indio_dev->dev.parent, indio_dev,
669-
"rx", IIO_BUFFER_DIRECTION_IN);
669+
"rx");
670670
if (ret)
671671
return ret;
672672

drivers/iio/adc/ad7944.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -740,8 +740,7 @@ static int ad7944_probe(struct spi_device *spi)
740740
return dev_err_probe(dev, ret,
741741
"failed to apply PWM state\n");
742742

743-
ret = devm_iio_dmaengine_buffer_setup(dev, indio_dev, "rx",
744-
IIO_BUFFER_DIRECTION_IN);
743+
ret = devm_iio_dmaengine_buffer_setup(dev, indio_dev, "rx");
745744
if (ret)
746745
return ret;
747746
} else {

drivers/iio/adc/ad_adc.c

Lines changed: 1 addition & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -343,44 +343,6 @@ static int axiadc_hw_consumer_postenable(struct iio_dev *indio_dev)
343343
return iio_hw_consumer_enable(st->frontend);
344344
}
345345

346-
static int axiadc_hw_submit_block(struct iio_dma_buffer_queue *queue,
347-
struct iio_dma_buffer_block *block)
348-
{
349-
struct iio_dev *indio_dev = queue->driver_data;
350-
struct axiadc_state *st = iio_priv(indio_dev);
351-
352-
iio_dmaengine_buffer_submit_block(queue, block);
353-
354-
axiadc_write(st, ADI_REG_STATUS, ~0);
355-
axiadc_write(st, ADI_REG_DMA_STATUS, ~0);
356-
357-
return 0;
358-
}
359-
360-
static const struct iio_dma_buffer_ops axiadc_dma_buffer_ops = {
361-
.submit = axiadc_hw_submit_block,
362-
.abort = iio_dmaengine_buffer_abort,
363-
};
364-
365-
static int axiadc_configure_ring_stream(struct iio_dev *indio_dev,
366-
const char *dma_name)
367-
{
368-
struct iio_buffer *buffer;
369-
370-
if (dma_name == NULL)
371-
dma_name = "rx";
372-
373-
buffer = devm_iio_dmaengine_buffer_alloc(indio_dev->dev.parent, dma_name,
374-
&axiadc_dma_buffer_ops, indio_dev);
375-
if (IS_ERR(buffer))
376-
return PTR_ERR(buffer);
377-
378-
indio_dev->modes |= INDIO_BUFFER_HARDWARE;
379-
iio_device_attach_buffer(indio_dev, buffer);
380-
381-
return 0;
382-
}
383-
384346
static int axiadc_hw_consumer_predisable(struct iio_dev *indio_dev)
385347
{
386348
struct axiadc_state *st = iio_priv(indio_dev);
@@ -793,7 +755,7 @@ static int adc_probe(struct platform_device *pdev)
793755
indio_dev->num_channels = info->num_channels;
794756
}
795757

796-
ret = axiadc_configure_ring_stream(indio_dev, "rx");
758+
ret = devm_iio_dmaengine_buffer_setup(&pdev->dev, indio_dev, "rx");
797759
if (ret)
798760
return ret;
799761

drivers/iio/adc/ad_pulsar.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -932,8 +932,7 @@ static int ad_pulsar_probe(struct spi_device *spi)
932932
indio_dev->setup_ops = &ad_pulsar_buffer_ops;
933933

934934
ret = devm_iio_dmaengine_buffer_setup(indio_dev->dev.parent,
935-
indio_dev, "rx",
936-
IIO_BUFFER_DIRECTION_IN);
935+
indio_dev, "rx");
937936
if (ret)
938937
return ret;
939938

drivers/iio/adc/adi-axi-adc.c

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -124,26 +124,12 @@ static struct iio_buffer *axi_adc_request_buffer(struct iio_backend *back,
124124
struct iio_dev *indio_dev)
125125
{
126126
struct adi_axi_adc_state *st = iio_backend_get_priv(back);
127-
struct iio_buffer *buffer;
128127
const char *dma_name;
129-
int ret;
130128

131129
if (device_property_read_string(st->dev, "dma-names", &dma_name))
132130
dma_name = "rx";
133131

134-
buffer = iio_dmaengine_buffer_alloc(st->dev, dma_name, NULL, NULL);
135-
if (IS_ERR(buffer)) {
136-
dev_err(st->dev, "Could not get DMA buffer, %ld\n",
137-
PTR_ERR(buffer));
138-
return ERR_CAST(buffer);
139-
}
140-
141-
indio_dev->modes |= INDIO_BUFFER_HARDWARE;
142-
ret = iio_device_attach_buffer(indio_dev, buffer);
143-
if (ret)
144-
return ERR_PTR(ret);
145-
146-
return buffer;
132+
return iio_dmaengine_buffer_setup(st->dev, indio_dev, dma_name);
147133
}
148134

149135
static void axi_adc_free_buffer(struct iio_backend *back,

drivers/iio/adc/admc_adc.c

Lines changed: 1 addition & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -82,44 +82,6 @@ static inline unsigned int axiadc_read(struct axiadc_state *st, unsigned reg)
8282
return ioread32(st->regs + reg);
8383
}
8484

85-
static int axiadc_hw_submit_block(struct iio_dma_buffer_queue *queue,
86-
struct iio_dma_buffer_block *block)
87-
{
88-
struct iio_dev *indio_dev = queue->driver_data;
89-
struct axiadc_state *st = iio_priv(indio_dev);
90-
91-
iio_dmaengine_buffer_submit_block(queue, block);
92-
93-
axiadc_write(st, ADI_REG_STATUS, ~0);
94-
axiadc_write(st, ADI_REG_DMA_STATUS, ~0);
95-
96-
return 0;
97-
}
98-
99-
static const struct iio_dma_buffer_ops axiadc_dma_buffer_ops = {
100-
.submit = axiadc_hw_submit_block,
101-
.abort = iio_dmaengine_buffer_abort,
102-
};
103-
104-
static int axiadc_configure_ring_stream(struct iio_dev *indio_dev,
105-
const char *dma_name)
106-
{
107-
struct iio_buffer *buffer;
108-
109-
if (dma_name == NULL)
110-
dma_name = "rx";
111-
112-
buffer = devm_iio_dmaengine_buffer_alloc(indio_dev->dev.parent, dma_name,
113-
&axiadc_dma_buffer_ops, indio_dev);
114-
if (IS_ERR(buffer))
115-
return PTR_ERR(buffer);
116-
117-
indio_dev->modes |= INDIO_BUFFER_HARDWARE;
118-
iio_device_attach_buffer(indio_dev, buffer);
119-
120-
return 0;
121-
}
122-
12385
static int axiadc_reg_access(struct iio_dev *indio_dev,
12486
unsigned reg, unsigned writeval,
12587
unsigned *readval)
@@ -226,7 +188,7 @@ static int axiadc_probe(struct platform_device *pdev)
226188
st->iio_info = axiadc_info;
227189
indio_dev->info = &st->iio_info;
228190

229-
ret = axiadc_configure_ring_stream(indio_dev, "ad-mc-adc-dma");
191+
ret = devm_iio_dmaengine_buffer_setup(&pdev->dev, indio_dev, "ad-mc-adc-dma");
230192
if (ret < 0)
231193
return ret;
232194

0 commit comments

Comments
 (0)