From patchwork Thu Jun 14 14:32:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hanno Zulla X-Patchwork-Id: 10464461 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 0B3896020F for ; Thu, 14 Jun 2018 14:32:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EEC0428B04 for ; Thu, 14 Jun 2018 14:32:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E372D28B18; Thu, 14 Jun 2018 14:32:35 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7DE2C28B04 for ; Thu, 14 Jun 2018 14:32:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965512AbeFNOcV (ORCPT ); Thu, 14 Jun 2018 10:32:21 -0400 Received: from zoot.epublica.de ([78.46.103.157]:59538 "EHLO zoot.epublica.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965475AbeFNOcT (ORCPT ); Thu, 14 Jun 2018 10:32:19 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by zoot.epublica.de (Postfix) with ESMTP id C4E691840DF4; Thu, 14 Jun 2018 16:32:17 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at zoot.epublica.de Received: from zoot.epublica.de ([127.0.0.1]) by localhost (zoot.epublica.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id CmYDyNVdRzUi; Thu, 14 Jun 2018 16:32:17 +0200 (CEST) Received: from [10.1.0.41] (ip1f12a024.dynamic.kabel-deutschland.de [31.18.160.36]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by zoot.epublica.de (Postfix) with ESMTPSA id 1A8351840DF0; Thu, 14 Jun 2018 16:32:17 +0200 (CEST) Subject: [PATCH 5/5] HID: hid-sony.c: Use devm_ api to simplify sc->output_report_dmabuf From: Hanno Zulla Cc: Jiri Kosina , Benjamin Tissoires , linux-input References: <76bacb70-f61e-6b00-233b-92c43aff1fca@hanno.de> <27d9fd86-258d-261f-60c6-80020131a617@hanno.de> <2427d4aa-e364-7ffb-e040-47ac36dbcc2c@hanno.de> Message-ID: <8cb2bb47-ad92-611d-f364-e794f83d2afa@hanno.de> Date: Thu, 14 Jun 2018 16:32:16 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 In-Reply-To: <2427d4aa-e364-7ffb-e040-47ac36dbcc2c@hanno.de> Content-Language: de-LU To: unlisted-recipients:; (no To-header on input) Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP HID: hid-sony.c: Use devm_ api to simplify sc->output_report_dmabuf Using devm_ calls, the resources of the Sony game devices's features are tied to the main device handle, making it easier to handle errors and teardown inside the device driver. Altogether, this reduces complexity of the driver source. Signed-off-by: Hanno Zulla --- drivers/hid/hid-sony.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/drivers/hid/hid-sony.c b/drivers/hid/hid-sony.c index 9abdd77f16c9..9671a4bad643 100644 --- a/drivers/hid/hid-sony.c +++ b/drivers/hid/hid-sony.c @@ -2202,16 +2202,20 @@ static int sony_allocate_output_report(struct sony_sc *sc) if ((sc->quirks & SIXAXIS_CONTROLLER) || (sc->quirks & NAVIGATION_CONTROLLER)) sc->output_report_dmabuf = - kmalloc(sizeof(union sixaxis_output_report_01), + devm_kmalloc(&sc->hdev->dev, + sizeof(union sixaxis_output_report_01), GFP_KERNEL); else if (sc->quirks & DUALSHOCK4_CONTROLLER_BT) - sc->output_report_dmabuf = kmalloc(DS4_OUTPUT_REPORT_0x11_SIZE, + sc->output_report_dmabuf = devm_kmalloc(&sc->hdev->dev, + DS4_OUTPUT_REPORT_0x11_SIZE, GFP_KERNEL); else if (sc->quirks & (DUALSHOCK4_CONTROLLER_USB | DUALSHOCK4_DONGLE)) - sc->output_report_dmabuf = kmalloc(DS4_OUTPUT_REPORT_0x05_SIZE, + sc->output_report_dmabuf = devm_kmalloc(&sc->hdev->dev, + DS4_OUTPUT_REPORT_0x05_SIZE, GFP_KERNEL); else if (sc->quirks & MOTION_CONTROLLER) - sc->output_report_dmabuf = kmalloc(MOTION_REPORT_0x02_SIZE, + sc->output_report_dmabuf = devm_kmalloc(&sc->hdev->dev, + MOTION_REPORT_0x02_SIZE, GFP_KERNEL); else return 0; @@ -2791,7 +2795,6 @@ static int sony_input_configured(struct hid_device *hdev, if (sc->hw_version) device_remove_file(&sc->hdev->dev, &dev_attr_hardware_version); sony_cancel_work_sync(sc); - kfree(sc->output_report_dmabuf); sony_remove_dev_list(sc); sony_release_device_id(sc); hid_hw_stop(hdev); @@ -2879,8 +2882,6 @@ static void sony_remove(struct hid_device *hdev) sony_cancel_work_sync(sc); - kfree(sc->output_report_dmabuf); - sony_remove_dev_list(sc); sony_release_device_id(sc);