| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * |
|---|
| 3 | 4 | * TWL4030 MADC module driver-This driver monitors the real time |
|---|
| 4 | 5 | * conversion of analog signals like battery temperature, |
|---|
| 5 | 6 | * battery type, battery level etc. |
|---|
| 6 | 7 | * |
|---|
| 7 | | - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/ |
|---|
| 8 | + * Copyright (C) 2011 Texas Instruments Incorporated - https://www.ti.com/ |
|---|
| 8 | 9 | * J Keerthy <j-keerthy@ti.com> |
|---|
| 9 | 10 | * |
|---|
| 10 | 11 | * Based on twl4030-madc.c |
|---|
| .. | .. |
|---|
| 12 | 13 | * Mikko Ylinen <mikko.k.ylinen@nokia.com> |
|---|
| 13 | 14 | * |
|---|
| 14 | 15 | * Amit Kucheria <amit.kucheria@canonical.com> |
|---|
| 15 | | - * |
|---|
| 16 | | - * This program is free software; you can redistribute it and/or |
|---|
| 17 | | - * modify it under the terms of the GNU General Public License |
|---|
| 18 | | - * version 2 as published by the Free Software Foundation. |
|---|
| 19 | | - * |
|---|
| 20 | | - * This program is distributed in the hope that it will be useful, but |
|---|
| 21 | | - * WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 22 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|---|
| 23 | | - * General Public License for more details. |
|---|
| 24 | | - * |
|---|
| 25 | | - * You should have received a copy of the GNU General Public License |
|---|
| 26 | | - * along with this program; if not, write to the Free Software |
|---|
| 27 | | - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA |
|---|
| 28 | | - * 02110-1301 USA |
|---|
| 29 | | - * |
|---|
| 30 | 16 | */ |
|---|
| 31 | 17 | |
|---|
| 32 | 18 | #include <linux/device.h> |
|---|
| .. | .. |
|---|
| 167 | 153 | * struct twl4030_madc_data - a container for madc info |
|---|
| 168 | 154 | * @dev: Pointer to device structure for madc |
|---|
| 169 | 155 | * @lock: Mutex protecting this data structure |
|---|
| 170 | | - * @regulator: Pointer to bias regulator for madc |
|---|
| 156 | + * @usb3v1: Pointer to bias regulator for madc |
|---|
| 171 | 157 | * @requests: Array of request struct corresponding to SW1, SW2 and RT |
|---|
| 172 | 158 | * @use_second_irq: IRQ selection (main or co-processor) |
|---|
| 173 | 159 | * @imr: Interrupt mask register of MADC |
|---|
| .. | .. |
|---|
| 175 | 161 | */ |
|---|
| 176 | 162 | struct twl4030_madc_data { |
|---|
| 177 | 163 | struct device *dev; |
|---|
| 178 | | - struct mutex lock; /* mutex protecting this data structure */ |
|---|
| 164 | + struct mutex lock; |
|---|
| 179 | 165 | struct regulator *usb3v1; |
|---|
| 180 | 166 | struct twl4030_madc_request requests[TWL4030_MADC_NUM_METHODS]; |
|---|
| 181 | 167 | bool use_second_irq; |
|---|
| .. | .. |
|---|
| 486 | 472 | struct twl4030_madc_data *madc = _madc; |
|---|
| 487 | 473 | const struct twl4030_madc_conversion_method *method; |
|---|
| 488 | 474 | u8 isr_val, imr_val; |
|---|
| 489 | | - int i, len, ret; |
|---|
| 475 | + int i, ret; |
|---|
| 490 | 476 | struct twl4030_madc_request *r; |
|---|
| 491 | 477 | |
|---|
| 492 | 478 | mutex_lock(&madc->lock); |
|---|
| .. | .. |
|---|
| 509 | 495 | ret = twl4030_madc_disable_irq(madc, i); |
|---|
| 510 | 496 | if (ret < 0) |
|---|
| 511 | 497 | dev_dbg(madc->dev, "Disable interrupt failed %d\n", i); |
|---|
| 512 | | - madc->requests[i].result_pending = 1; |
|---|
| 498 | + madc->requests[i].result_pending = true; |
|---|
| 513 | 499 | } |
|---|
| 514 | 500 | for (i = 0; i < TWL4030_MADC_NUM_METHODS; i++) { |
|---|
| 515 | 501 | r = &madc->requests[i]; |
|---|
| .. | .. |
|---|
| 518 | 504 | continue; |
|---|
| 519 | 505 | method = &twl4030_conversion_methods[r->method]; |
|---|
| 520 | 506 | /* Read results */ |
|---|
| 521 | | - len = twl4030_madc_read_channels(madc, method->rbase, |
|---|
| 522 | | - r->channels, r->rbuf, r->raw); |
|---|
| 507 | + twl4030_madc_read_channels(madc, method->rbase, |
|---|
| 508 | + r->channels, r->rbuf, r->raw); |
|---|
| 523 | 509 | /* Free request */ |
|---|
| 524 | | - r->result_pending = 0; |
|---|
| 525 | | - r->active = 0; |
|---|
| 510 | + r->result_pending = false; |
|---|
| 511 | + r->active = false; |
|---|
| 526 | 512 | } |
|---|
| 527 | 513 | mutex_unlock(&madc->lock); |
|---|
| 528 | 514 | |
|---|
| .. | .. |
|---|
| 535 | 521 | */ |
|---|
| 536 | 522 | for (i = 0; i < TWL4030_MADC_NUM_METHODS; i++) { |
|---|
| 537 | 523 | r = &madc->requests[i]; |
|---|
| 538 | | - if (r->active == 0) |
|---|
| 524 | + if (!r->active) |
|---|
| 539 | 525 | continue; |
|---|
| 540 | 526 | method = &twl4030_conversion_methods[r->method]; |
|---|
| 541 | 527 | /* Read results */ |
|---|
| 542 | | - len = twl4030_madc_read_channels(madc, method->rbase, |
|---|
| 543 | | - r->channels, r->rbuf, r->raw); |
|---|
| 528 | + twl4030_madc_read_channels(madc, method->rbase, |
|---|
| 529 | + r->channels, r->rbuf, r->raw); |
|---|
| 544 | 530 | /* Free request */ |
|---|
| 545 | | - r->result_pending = 0; |
|---|
| 546 | | - r->active = 0; |
|---|
| 531 | + r->result_pending = false; |
|---|
| 532 | + r->active = false; |
|---|
| 547 | 533 | } |
|---|
| 548 | 534 | mutex_unlock(&madc->lock); |
|---|
| 549 | 535 | |
|---|
| .. | .. |
|---|
| 666 | 652 | ret = twl4030_madc_start_conversion(twl4030_madc, req->method); |
|---|
| 667 | 653 | if (ret < 0) |
|---|
| 668 | 654 | goto out; |
|---|
| 669 | | - twl4030_madc->requests[req->method].active = 1; |
|---|
| 655 | + twl4030_madc->requests[req->method].active = true; |
|---|
| 670 | 656 | /* Wait until conversion is ready (ctrl register returns EOC) */ |
|---|
| 671 | 657 | ret = twl4030_madc_wait_conversion_ready(twl4030_madc, 5, method->ctrl); |
|---|
| 672 | 658 | if (ret) { |
|---|
| 673 | | - twl4030_madc->requests[req->method].active = 0; |
|---|
| 659 | + twl4030_madc->requests[req->method].active = false; |
|---|
| 674 | 660 | goto out; |
|---|
| 675 | 661 | } |
|---|
| 676 | 662 | ret = twl4030_madc_read_channels(twl4030_madc, method->rbase, |
|---|
| 677 | 663 | req->channels, req->rbuf, req->raw); |
|---|
| 678 | | - twl4030_madc->requests[req->method].active = 0; |
|---|
| 664 | + twl4030_madc->requests[req->method].active = false; |
|---|
| 679 | 665 | |
|---|
| 680 | 666 | out: |
|---|
| 681 | 667 | mutex_unlock(&twl4030_madc->lock); |
|---|
| .. | .. |
|---|
| 786 | 772 | madc->dev = &pdev->dev; |
|---|
| 787 | 773 | |
|---|
| 788 | 774 | iio_dev->name = dev_name(&pdev->dev); |
|---|
| 789 | | - iio_dev->dev.parent = &pdev->dev; |
|---|
| 790 | | - iio_dev->dev.of_node = pdev->dev.of_node; |
|---|
| 791 | 775 | iio_dev->info = &twl4030_madc_iio_info; |
|---|
| 792 | 776 | iio_dev->modes = INDIO_DIRECT_MODE; |
|---|
| 793 | 777 | iio_dev->channels = twl4030_madc_iio_channels; |
|---|