From patchwork Thu Sep 7 00:21:11 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 9941501 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 0F675602CC for ; Thu, 7 Sep 2017 00:22:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 03E942654B for ; Thu, 7 Sep 2017 00:22:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E9FD1274A3; Thu, 7 Sep 2017 00:21:59 +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.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID 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 9082D2654B for ; Thu, 7 Sep 2017 00:21:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753375AbdIGAVp (ORCPT ); Wed, 6 Sep 2017 20:21:45 -0400 Received: from mail-pf0-f195.google.com ([209.85.192.195]:34259 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751538AbdIGAVU (ORCPT ); Wed, 6 Sep 2017 20:21:20 -0400 Received: by mail-pf0-f195.google.com with SMTP id y68so3736897pfd.1; Wed, 06 Sep 2017 17:21:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=GxlnA/B2RYumz436I1fiI9Ry+oGubW74ctZBhOKmYl0=; b=A9CDx3wu3v36a6fnl5KZPdnvVcDBTdoq2DmW86SA18QIBqT9FMfghQ94Dpmi4JvxQ3 n3/SvZ9MahZCCENcJzBi6MvwZ/sJF9QJhRlgztJY/DDt7u9NfafBeaKZ3sjoV3sS4nzC bZYZCYKphaHgaTLPSKCx6bOSpIwpnpQDreH/AHL9oDN5XKk+BGbG665SVxkRY7+M0X5H Dfkg2iotwNVeZLz27ux3TTJ8CWxeXxPDVke47YzkBqVYBm7OZRGkxQkxrQArCy/9vIY0 Rfy4vd46KbKUGehxJP4vHxuU04LHIqVPtK73jHPJuDBGL4RjaJjQsREuIhV0a8+SNZNE iMfw== 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; bh=GxlnA/B2RYumz436I1fiI9Ry+oGubW74ctZBhOKmYl0=; b=uWpLdgE3GcCMVM5aplbZ6F5fNGzz9DQKlJyD/QytQq4KLoB34xl3mz5tm0wCoWNSGO BjqB/ikE8CR5j8oaPMunzPZIK5MTZ3Cwj0CfHCOHpjk6TCUWsMYMqqAnuLnGN/Ks9A+i exV7BLYRqfMI+VF8TrwbkucWhFEvRGhV46VrJUFEyDrDz2EqIeTbdTcjuP0czSuFVGyc r2lXTqTSN/JNAUyJ9YSqf/P5+AYAVOxhCyQ7ahka7nm8WRDX8cNrldJCvyEDFruKaiVs Oek/CxvyghI0VEqnyvZBIitXgqjTThVRjSWAzfFGd9QfWtcnffaGN7RkN8lDC5FfzkJv laog== X-Gm-Message-State: AHPjjUhp+cBG0aSWVjzcbjAUoTkTTG9tQxYeIKsYDlOLX8BeocrbFiJO SaQ2ahf4K64nc4+WckE= X-Google-Smtp-Source: ADKCNb4H44gF72I8XUPLbSLTbZyLHo5tJy+xSRBWqRbXmhN1rLpUZYqrOvnZPrCwacqUJBe2SVsfwA== X-Received: by 10.84.238.143 with SMTP id v15mr993941plk.303.1504743679308; Wed, 06 Sep 2017 17:21:19 -0700 (PDT) Received: from dtor-ws.mtv.corp.google.com ([100.98.112.21]) by smtp.gmail.com with ESMTPSA id d25sm1282515pfb.1.2017.09.06.17.21.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 06 Sep 2017 17:21:18 -0700 (PDT) From: Dmitry Torokhov To: linux-input@vger.kernel.org Cc: Rodrigo Rivas Costa , =?UTF-8?q?Cl=C3=A9ment=20VUCHENER?= , Elias Vanderstuyft , linux-kernel@vger.kernel.org Subject: [PATCH 5/6] Input: uinput - remove uinput_allocate_device() Date: Wed, 6 Sep 2017 17:21:11 -0700 Message-Id: <20170907002112.14097-5-dmitry.torokhov@gmail.com> X-Mailer: git-send-email 2.14.1.581.gf28d330327-goog In-Reply-To: <20170907002112.14097-1-dmitry.torokhov@gmail.com> References: <20170907002112.14097-1-dmitry.torokhov@gmail.com> 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 There is no need for this wrapper; let's use input_allocate_device() directly, and complete initialization in uinput_create_device(). Signed-off-by: Dmitry Torokhov --- drivers/input/misc/uinput.c | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/drivers/input/misc/uinput.c b/drivers/input/misc/uinput.c index 09549eddfcd4..06f3ac67dde1 100644 --- a/drivers/input/misc/uinput.c +++ b/drivers/input/misc/uinput.c @@ -324,6 +324,10 @@ static int uinput_create_device(struct uinput_device *udev) dev->flush = uinput_dev_flush; } + dev->event = uinput_dev_event; + + input_set_drvdata(udev->dev, udev); + error = input_register_device(udev->dev); if (error) goto fail2; @@ -406,18 +410,6 @@ static int uinput_validate_absbits(struct input_dev *dev) return 0; } -static int uinput_allocate_device(struct uinput_device *udev) -{ - udev->dev = input_allocate_device(); - if (!udev->dev) - return -ENOMEM; - - udev->dev->event = uinput_dev_event; - input_set_drvdata(udev->dev, udev); - - return 0; -} - static int uinput_dev_setup(struct uinput_device *udev, struct uinput_setup __user *arg) { @@ -493,9 +485,9 @@ static int uinput_setup_device_legacy(struct uinput_device *udev, return -EINVAL; if (!udev->dev) { - retval = uinput_allocate_device(udev); - if (retval) - return retval; + udev->dev = input_allocate_device(); + if (!udev->dev) + return -ENOMEM; } dev = udev->dev; @@ -826,9 +818,9 @@ static long uinput_ioctl_handler(struct file *file, unsigned int cmd, return retval; if (!udev->dev) { - retval = uinput_allocate_device(udev); - if (retval) - goto out; + udev->dev = input_allocate_device(); + if (!udev->dev) + return -ENOMEM; } switch (cmd) {