| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Char device for device raw access |
|---|
| 3 | 4 | * |
|---|
| 4 | 5 | * Copyright (C) 2005-2007 Kristian Hoegsberg <krh@bitplanet.net> |
|---|
| 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. |
|---|
| 10 | | - * |
|---|
| 11 | | - * This program is distributed in the hope that it will be useful, |
|---|
| 12 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 13 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 14 | | - * GNU General Public License for more details. |
|---|
| 15 | | - * |
|---|
| 16 | | - * You should have received a copy of the GNU General Public License |
|---|
| 17 | | - * along with this program; if not, write to the Free Software Foundation, |
|---|
| 18 | | - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|---|
| 19 | 6 | */ |
|---|
| 20 | 7 | |
|---|
| 21 | 8 | #include <linux/bug.h> |
|---|
| .. | .. |
|---|
| 130 | 117 | struct descriptor_resource { |
|---|
| 131 | 118 | struct client_resource resource; |
|---|
| 132 | 119 | struct fw_descriptor descriptor; |
|---|
| 133 | | - u32 data[0]; |
|---|
| 120 | + u32 data[]; |
|---|
| 134 | 121 | }; |
|---|
| 135 | 122 | |
|---|
| 136 | 123 | struct iso_resource { |
|---|
| .. | .. |
|---|
| 1094 | 1081 | return -EINVAL; |
|---|
| 1095 | 1082 | |
|---|
| 1096 | 1083 | p = (struct fw_cdev_iso_packet __user *)u64_to_uptr(a->packets); |
|---|
| 1097 | | - if (!access_ok(VERIFY_READ, p, a->size)) |
|---|
| 1098 | | - return -EFAULT; |
|---|
| 1099 | 1084 | |
|---|
| 1100 | 1085 | end = (void __user *)p + a->size; |
|---|
| 1101 | 1086 | count = 0; |
|---|
| .. | .. |
|---|
| 1133 | 1118 | &p->header[transmit_header_bytes / 4]; |
|---|
| 1134 | 1119 | if (next > end) |
|---|
| 1135 | 1120 | return -EINVAL; |
|---|
| 1136 | | - if (__copy_from_user |
|---|
| 1121 | + if (copy_from_user |
|---|
| 1137 | 1122 | (u.packet.header, p->header, transmit_header_bytes)) |
|---|
| 1138 | 1123 | return -EFAULT; |
|---|
| 1139 | 1124 | if (u.packet.skip && ctx->type == FW_ISO_CONTEXT_TRANSMIT && |
|---|
| .. | .. |
|---|
| 1495 | 1480 | { |
|---|
| 1496 | 1481 | struct outbound_phy_packet_event *e = |
|---|
| 1497 | 1482 | container_of(packet, struct outbound_phy_packet_event, p); |
|---|
| 1483 | + struct client *e_client; |
|---|
| 1498 | 1484 | |
|---|
| 1499 | 1485 | switch (status) { |
|---|
| 1500 | 1486 | /* expected: */ |
|---|
| .. | .. |
|---|
| 1511 | 1497 | } |
|---|
| 1512 | 1498 | e->phy_packet.data[0] = packet->timestamp; |
|---|
| 1513 | 1499 | |
|---|
| 1500 | + e_client = e->client; |
|---|
| 1514 | 1501 | queue_event(e->client, &e->event, &e->phy_packet, |
|---|
| 1515 | 1502 | sizeof(e->phy_packet) + e->phy_packet.length, NULL, 0); |
|---|
| 1516 | | - client_put(e->client); |
|---|
| 1503 | + client_put(e_client); |
|---|
| 1517 | 1504 | } |
|---|
| 1518 | 1505 | |
|---|
| 1519 | 1506 | static int ioctl_send_phy_packet(struct client *client, union ioctl_arg *arg) |
|---|
| .. | .. |
|---|
| 1659 | 1646 | return dispatch_ioctl(file->private_data, cmd, (void __user *)arg); |
|---|
| 1660 | 1647 | } |
|---|
| 1661 | 1648 | |
|---|
| 1662 | | -#ifdef CONFIG_COMPAT |
|---|
| 1663 | | -static long fw_device_op_compat_ioctl(struct file *file, |
|---|
| 1664 | | - unsigned int cmd, unsigned long arg) |
|---|
| 1665 | | -{ |
|---|
| 1666 | | - return dispatch_ioctl(file->private_data, cmd, compat_ptr(arg)); |
|---|
| 1667 | | -} |
|---|
| 1668 | | -#endif |
|---|
| 1669 | | - |
|---|
| 1670 | 1649 | static int fw_device_op_mmap(struct file *file, struct vm_area_struct *vma) |
|---|
| 1671 | 1650 | { |
|---|
| 1672 | 1651 | struct client *client = file->private_data; |
|---|
| .. | .. |
|---|
| 1707 | 1686 | if (ret < 0) |
|---|
| 1708 | 1687 | goto fail; |
|---|
| 1709 | 1688 | |
|---|
| 1710 | | - ret = fw_iso_buffer_map_vma(&client->buffer, vma); |
|---|
| 1689 | + ret = vm_map_pages_zero(vma, client->buffer.pages, |
|---|
| 1690 | + client->buffer.page_count); |
|---|
| 1711 | 1691 | if (ret < 0) |
|---|
| 1712 | 1692 | goto fail; |
|---|
| 1713 | 1693 | |
|---|
| .. | .. |
|---|
| 1808 | 1788 | .mmap = fw_device_op_mmap, |
|---|
| 1809 | 1789 | .release = fw_device_op_release, |
|---|
| 1810 | 1790 | .poll = fw_device_op_poll, |
|---|
| 1811 | | -#ifdef CONFIG_COMPAT |
|---|
| 1812 | | - .compat_ioctl = fw_device_op_compat_ioctl, |
|---|
| 1813 | | -#endif |
|---|
| 1791 | + .compat_ioctl = compat_ptr_ioctl, |
|---|
| 1814 | 1792 | }; |
|---|