industrialio-buffer.c (248be5aafc7cfe860b8f310bfc3f433e51f9fb11) industrialio-buffer.c (fcc1b2f57d89142acf6173a8e6ffb19f5f5ec876)
1/* The industrial I/O core
2 *
3 * Copyright (c) 2008 Jonathan Cameron
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 as published by
7 * the Free Software Foundation.
8 *

--- 561 unchanged lines hidden (view full) ---

570 return;
571
572 bytes = iio_compute_scan_bytes(indio_dev, buffer->scan_mask,
573 buffer->scan_timestamp);
574
575 buffer->access->set_bytes_per_datum(buffer, bytes);
576}
577
1/* The industrial I/O core
2 *
3 * Copyright (c) 2008 Jonathan Cameron
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 as published by
7 * the Free Software Foundation.
8 *

--- 561 unchanged lines hidden (view full) ---

570 return;
571
572 bytes = iio_compute_scan_bytes(indio_dev, buffer->scan_mask,
573 buffer->scan_timestamp);
574
575 buffer->access->set_bytes_per_datum(buffer, bytes);
576}
577
578static int iio_buffer_request_update(struct iio_dev *indio_dev,
579 struct iio_buffer *buffer)
580{
581 int ret;
582
583 iio_buffer_update_bytes_per_datum(indio_dev, buffer);
584 if (buffer->access->request_update) {
585 ret = buffer->access->request_update(buffer);
586 if (ret) {
587 dev_dbg(&indio_dev->dev,
588 "Buffer not started: buffer parameter update failed (%d)\n",
589 ret);
590 return ret;
591 }
592 }
593
594 return 0;
595}
596
578static void iio_free_scan_mask(struct iio_dev *indio_dev,
579 const unsigned long *mask)
580{
581 /* If the mask is dynamically allocated free it, otherwise do nothing */
582 if (!indio_dev->available_scan_masks)
583 kfree(mask);
584}
585
586static int __iio_update_buffers(struct iio_dev *indio_dev,
587 struct iio_buffer *insert_buffer,
588 struct iio_buffer *remove_buffer)
589{
590 int ret;
591 int success = 0;
592 struct iio_buffer *buffer;
593 unsigned long *compound_mask;
594 const unsigned long *old_mask;
595
597static void iio_free_scan_mask(struct iio_dev *indio_dev,
598 const unsigned long *mask)
599{
600 /* If the mask is dynamically allocated free it, otherwise do nothing */
601 if (!indio_dev->available_scan_masks)
602 kfree(mask);
603}
604
605static int __iio_update_buffers(struct iio_dev *indio_dev,
606 struct iio_buffer *insert_buffer,
607 struct iio_buffer *remove_buffer)
608{
609 int ret;
610 int success = 0;
611 struct iio_buffer *buffer;
612 unsigned long *compound_mask;
613 const unsigned long *old_mask;
614
615 if (insert_buffer) {
616 ret = iio_buffer_request_update(indio_dev, insert_buffer);
617 if (ret)
618 return ret;
619 }
620
596 /* Wind down existing buffers - iff there are any */
597 if (!list_empty(&indio_dev->buffer_list)) {
598 if (indio_dev->setup_ops->predisable) {
599 ret = indio_dev->setup_ops->predisable(indio_dev);
600 if (ret)
601 return ret;
602 }
603 indio_dev->currentmode = INDIO_DIRECT_MODE;

--- 69 unchanged lines hidden (view full) ---

673 "Buffer not started: buffer preenable failed (%d)\n", ret);
674 goto error_remove_inserted;
675 }
676 }
677 indio_dev->scan_bytes =
678 iio_compute_scan_bytes(indio_dev,
679 indio_dev->active_scan_mask,
680 indio_dev->scan_timestamp);
621 /* Wind down existing buffers - iff there are any */
622 if (!list_empty(&indio_dev->buffer_list)) {
623 if (indio_dev->setup_ops->predisable) {
624 ret = indio_dev->setup_ops->predisable(indio_dev);
625 if (ret)
626 return ret;
627 }
628 indio_dev->currentmode = INDIO_DIRECT_MODE;

--- 69 unchanged lines hidden (view full) ---

698 "Buffer not started: buffer preenable failed (%d)\n", ret);
699 goto error_remove_inserted;
700 }
701 }
702 indio_dev->scan_bytes =
703 iio_compute_scan_bytes(indio_dev,
704 indio_dev->active_scan_mask,
705 indio_dev->scan_timestamp);
681 list_for_each_entry(buffer, &indio_dev->buffer_list, buffer_list) {
682 iio_buffer_update_bytes_per_datum(indio_dev, buffer);
683 if (buffer->access->request_update) {
684 ret = buffer->access->request_update(buffer);
685 if (ret) {
686 dev_dbg(&indio_dev->dev,
687 "Buffer not started: buffer parameter update failed (%d)\n", ret);
688 goto error_run_postdisable;
689 }
690 }
691 }
692 if (indio_dev->info->update_scan_mode) {
693 ret = indio_dev->info
694 ->update_scan_mode(indio_dev,
695 indio_dev->active_scan_mask);
696 if (ret < 0) {
697 dev_dbg(&indio_dev->dev,
698 "Buffer not started: update scan mode failed (%d)\n",
699 ret);

--- 568 unchanged lines hidden ---
706 if (indio_dev->info->update_scan_mode) {
707 ret = indio_dev->info
708 ->update_scan_mode(indio_dev,
709 indio_dev->active_scan_mask);
710 if (ret < 0) {
711 dev_dbg(&indio_dev->dev,
712 "Buffer not started: update scan mode failed (%d)\n",
713 ret);

--- 568 unchanged lines hidden ---