From patchwork Fri Feb 24 10:33:08 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?TWljaGHFgiBLxJlwaWXFhA==?= X-Patchwork-Id: 9589861 X-Patchwork-Delegate: andy.shevchenko@gmail.com 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 C805D6042B for ; Fri, 24 Feb 2017 10:34:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BB2D3287F7 for ; Fri, 24 Feb 2017 10:34:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AF3CF28911; Fri, 24 Feb 2017 10:34:20 +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=-6.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM 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 58EB0287F7 for ; Fri, 24 Feb 2017 10:34:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751271AbdBXKeN (ORCPT ); Fri, 24 Feb 2017 05:34:13 -0500 Received: from mail-lf0-f65.google.com ([209.85.215.65]:34721 "EHLO mail-lf0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751246AbdBXKdp (ORCPT ); Fri, 24 Feb 2017 05:33:45 -0500 Received: by mail-lf0-f65.google.com with SMTP id x142so292264lfd.1 for ; Fri, 24 Feb 2017 02:33:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kempniu.pl; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=IUeg98sDkZG5bwDos2FAn5zmoPmefnSSK7Gkb4Wq02w=; b=Pn+emv8PXeezZfJsGWbNXiOETG/Yz3x62BT9JnhF251vi29AtxiOpGu2Xs4YrhAJMg rtWTH5TTwBFFoHjrvHm9qsGbEsSUvjWhd5et3VCN5lRT/vsZq2MMWcizugJzpikoeraV Y8UnwO1R7qZc5q92cc17mb/A4TmQgo9FiXmPI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=IUeg98sDkZG5bwDos2FAn5zmoPmefnSSK7Gkb4Wq02w=; b=RScTRDK2xtfjtu4C1RimpxSScwANFfq7vhCaNfnBuC1YKdzQO87vasUeaQATFgn/HH VuvSNBwVWA85tCXdIoUHUD9y7Z4OGOydNZIB+KYfOEdyBRIfhFsnK0inLWz5thc0z/ht khfnTj0sXujmPOdawIBHMRxKnpO9Mm3DrgiX2+2keIYz1i3RfXuPED+8viabfu76Ho/8 g4USOwY/XJE6+NRFBI3XUcKwkqi4G5fhY57WtaIETmUtk37Dvfx/tnoCcv/xN2BxwNt0 5kuYETSSdwmOcQALt6ZBrWZ1We6aa0/cQBZsqc2qdhvmb2uMWZ6wRKNnsoRFyw84/yOY 7PEg== X-Gm-Message-State: AMke39k/aIBv/6VVY6z5wm3LbyWXXrC5clNkUneUrCZiZKoPuJ0iDomaS+CbojDwP291Fg== X-Received: by 10.25.25.8 with SMTP id 8mr646872lfz.164.1487932397131; Fri, 24 Feb 2017 02:33:17 -0800 (PST) Received: from ozzy.nask.waw.pl ([2001:a10:160:3::3]) by smtp.googlemail.com with ESMTPSA id x26sm8678538lja.10.2017.02.24.02.33.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 24 Feb 2017 02:33:16 -0800 (PST) From: =?UTF-8?q?Micha=C5=82=20K=C4=99pie=C5=84?= To: Alex Hung , Darren Hart , Andy Shevchenko Cc: platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/4] platform/x86: intel-hid: use devm_input_allocate_device() for HID events input device Date: Fri, 24 Feb 2017 11:33:08 +0100 Message-Id: <20170224103309.19463-4-kernel@kempniu.pl> X-Mailer: git-send-email 2.11.1 In-Reply-To: <20170224103309.19463-1-kernel@kempniu.pl> References: <20170224103309.19463-1-kernel@kempniu.pl> MIME-Version: 1.0 Sender: platform-driver-x86-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP intel_hid_input_setup() is only called from the platform driver's .probe callback. Use the devm variant of input_allocate_device() for allocating memory for the HID events input device in order to simplify two error paths and get rid of intel_hid_input_destroy(). Signed-off-by: Michał Kępień --- drivers/platform/x86/intel-hid.c | 31 +++++-------------------------- 1 file changed, 5 insertions(+), 26 deletions(-) diff --git a/drivers/platform/x86/intel-hid.c b/drivers/platform/x86/intel-hid.c index 89d1d98e3214..b17f33b832c2 100644 --- a/drivers/platform/x86/intel-hid.c +++ b/drivers/platform/x86/intel-hid.c @@ -144,28 +144,20 @@ static int intel_hid_input_setup(struct platform_device *device) struct intel_hid_priv *priv = dev_get_drvdata(&device->dev); int ret; - priv->input_dev = input_allocate_device(); + priv->input_dev = devm_input_allocate_device(&device->dev); if (!priv->input_dev) return -ENOMEM; ret = sparse_keymap_setup(priv->input_dev, intel_hid_keymap, NULL); if (ret) - goto err_free_device; + return ret; priv->input_dev->dev.parent = &device->dev; priv->input_dev->name = "Intel HID events"; priv->input_dev->id.bustype = BUS_HOST; set_bit(KEY_RFKILL, priv->input_dev->keybit); - ret = input_register_device(priv->input_dev); - if (ret) - goto err_free_device; - - return 0; - -err_free_device: - input_free_device(priv->input_dev); - return ret; + return input_register_device(priv->input_dev); } static int intel_button_array_input_setup(struct platform_device *device) @@ -189,13 +181,6 @@ static int intel_button_array_input_setup(struct platform_device *device) return input_register_device(priv->array); } -static void intel_hid_input_destroy(struct platform_device *device) -{ - struct intel_hid_priv *priv = dev_get_drvdata(&device->dev); - - input_unregister_device(priv->input_dev); -} - static void notify_handler(acpi_handle handle, u32 event, void *context) { struct platform_device *device = context; @@ -270,10 +255,8 @@ static int intel_hid_probe(struct platform_device *device) ACPI_DEVICE_NOTIFY, notify_handler, device); - if (ACPI_FAILURE(status)) { - err = -EBUSY; - goto err_remove_input; - } + if (ACPI_FAILURE(status)) + return -EBUSY; err = intel_hid_set_enable(&device->dev, true); if (err) @@ -294,9 +277,6 @@ static int intel_hid_probe(struct platform_device *device) err_remove_notify: acpi_remove_notify_handler(handle, ACPI_DEVICE_NOTIFY, notify_handler); -err_remove_input: - intel_hid_input_destroy(device); - return err; } @@ -305,7 +285,6 @@ static int intel_hid_remove(struct platform_device *device) acpi_handle handle = ACPI_HANDLE(&device->dev); acpi_remove_notify_handler(handle, ACPI_DEVICE_NOTIFY, notify_handler); - intel_hid_input_destroy(device); intel_hid_set_enable(&device->dev, false); intel_button_array_enable(&device->dev, false);