| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * X-Gene SLIMpro I2C Driver |
|---|
| 3 | 4 | * |
|---|
| .. | .. |
|---|
| 5 | 6 | * Author: Feng Kan <fkan@apm.com> |
|---|
| 6 | 7 | * Author: Hieu Le <hnle@apm.com> |
|---|
| 7 | 8 | * |
|---|
| 8 | | - * This program is free software; you can redistribute it and/or |
|---|
| 9 | | - * modify it under the terms of the GNU General Public License as |
|---|
| 10 | | - * published by the Free Software Foundation; either version 2 of |
|---|
| 11 | | - * the License, or (at your option) any later version. |
|---|
| 12 | | - * |
|---|
| 13 | | - * This program is distributed in the hope that it will be useful, |
|---|
| 14 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 15 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 16 | | - * GNU General Public License for more details. |
|---|
| 17 | | - * |
|---|
| 18 | | - * You should have received a copy of the GNU General Public License |
|---|
| 19 | | - * along with this program; if not, see <http://www.gnu.org/licenses/>. |
|---|
| 20 | | - * |
|---|
| 21 | 9 | * This driver provides support for X-Gene SLIMpro I2C device access |
|---|
| 22 | 10 | * using the APM X-Gene SLIMpro mailbox driver. |
|---|
| 23 | | - * |
|---|
| 24 | 11 | */ |
|---|
| 25 | 12 | #include <acpi/pcc.h> |
|---|
| 26 | 13 | #include <linux/acpi.h> |
|---|
| .. | .. |
|---|
| 321 | 308 | u32 msg[3]; |
|---|
| 322 | 309 | int rc; |
|---|
| 323 | 310 | |
|---|
| 311 | + if (writelen > I2C_SMBUS_BLOCK_MAX) |
|---|
| 312 | + return -EINVAL; |
|---|
| 313 | + |
|---|
| 324 | 314 | memcpy(ctx->dma_buffer, data, writelen); |
|---|
| 325 | 315 | paddr = dma_map_single(ctx->dev, ctx->dma_buffer, writelen, |
|---|
| 326 | 316 | DMA_TO_DEVICE); |
|---|