| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * HID driver for the apple ir device |
|---|
| 3 | 4 | * |
|---|
| .. | .. |
|---|
| 12 | 13 | * Copyright (C) 2010, 2012 Bastien Nocera <hadess@hadess.net> |
|---|
| 13 | 14 | * Copyright (C) 2013 Benjamin Tissoires <benjamin.tissoires@gmail.com> |
|---|
| 14 | 15 | * Copyright (C) 2013 Red Hat Inc. All Rights Reserved |
|---|
| 15 | | - * |
|---|
| 16 | | - * This software is licensed under the terms of the GNU General Public |
|---|
| 17 | | - * License version 2, as published by the Free Software Foundation, and |
|---|
| 18 | | - * may be copied, distributed, and modified under those terms. |
|---|
| 19 | | - * |
|---|
| 20 | | - * This program is distributed in the hope that it will be useful, |
|---|
| 21 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 22 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 23 | | - * GNU General Public License for more details. |
|---|
| 24 | 16 | */ |
|---|
| 25 | 17 | |
|---|
| 26 | 18 | #include <linux/device.h> |
|---|
| .. | .. |
|---|
| 291 | 283 | int ret; |
|---|
| 292 | 284 | struct appleir *appleir; |
|---|
| 293 | 285 | |
|---|
| 294 | | - appleir = kzalloc(sizeof(struct appleir), GFP_KERNEL); |
|---|
| 295 | | - if (!appleir) { |
|---|
| 296 | | - ret = -ENOMEM; |
|---|
| 297 | | - goto allocfail; |
|---|
| 298 | | - } |
|---|
| 286 | + appleir = devm_kzalloc(&hid->dev, sizeof(struct appleir), GFP_KERNEL); |
|---|
| 287 | + if (!appleir) |
|---|
| 288 | + return -ENOMEM; |
|---|
| 299 | 289 | |
|---|
| 300 | 290 | appleir->hid = hid; |
|---|
| 301 | 291 | |
|---|
| .. | .. |
|---|
| 321 | 311 | |
|---|
| 322 | 312 | return 0; |
|---|
| 323 | 313 | fail: |
|---|
| 324 | | - kfree(appleir); |
|---|
| 325 | | -allocfail: |
|---|
| 314 | + devm_kfree(&hid->dev, appleir); |
|---|
| 326 | 315 | return ret; |
|---|
| 327 | 316 | } |
|---|
| 328 | 317 | |
|---|
| .. | .. |
|---|
| 331 | 320 | struct appleir *appleir = hid_get_drvdata(hid); |
|---|
| 332 | 321 | hid_hw_stop(hid); |
|---|
| 333 | 322 | del_timer_sync(&appleir->key_up_timer); |
|---|
| 334 | | - kfree(appleir); |
|---|
| 335 | 323 | } |
|---|
| 336 | 324 | |
|---|
| 337 | 325 | static const struct hid_device_id appleir_devices[] = { |
|---|