From patchwork Tue Apr 29 02:34:51 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 4084401 Return-Path: X-Original-To: patchwork-linux-input@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 67B569F38E for ; Tue, 29 Apr 2014 02:34:57 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 70133201F7 for ; Tue, 29 Apr 2014 02:34:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8248A201B4 for ; Tue, 29 Apr 2014 02:34:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750971AbaD2Cey (ORCPT ); Mon, 28 Apr 2014 22:34:54 -0400 Received: from mail-pa0-f42.google.com ([209.85.220.42]:59778 "EHLO mail-pa0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750820AbaD2Cey (ORCPT ); Mon, 28 Apr 2014 22:34:54 -0400 Received: by mail-pa0-f42.google.com with SMTP id bj1so3240290pad.29 for ; Mon, 28 Apr 2014 19:34:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:mime-version:content-type :content-disposition:user-agent; bh=1ASCGulz+LaflujfjWJjssqd9hu47VggU9QK//WgoKQ=; b=f2kLbk0aaaA0f7CI/+PvXVWcCHwBpu6vbC9+ReHKwPzMF6jn3vNO3n3/ZmMfwKkNtp XxV3eG9Gk2ibmd+rhFXnC1psyamm01lxMXthgTKRyENIhuxZhNjJ/eqwyBC45IIQ4H2j Jon6pP4hh/gGYG73op1jSmusvgV4Wsv51SOuaZbqyvTrwoA4vg1+XuDw5+4qklDoeJdw 6JkTCnvYjSjQ8zSSqYHyRO27DimtEe4Wo0taBUu9FiQ2KBwGpo8b38un6zmjulZgAhnO aT3h6n2rTLlwK8Ab/QVX+9DoSmR1oosObB6H2xEqYGy3Zj9H/DFF5aUxD/hMRf25y5JC n3xQ== X-Received: by 10.66.66.108 with SMTP id e12mr29897044pat.35.1398738893441; Mon, 28 Apr 2014 19:34:53 -0700 (PDT) Received: from mailhub.coreip.homeip.net (c-67-188-112-76.hsd1.ca.comcast.net. [67.188.112.76]) by mx.google.com with ESMTPSA id qq5sm38125413pbb.24.2014.04.28.19.34.52 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 28 Apr 2014 19:34:52 -0700 (PDT) Date: Mon, 28 Apr 2014 19:34:51 -0700 From: Dmitry Torokhov To: linux-input@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Alexander Shiyan Subject: [PATCH] Input: remove race when instantiating polled device attributes Message-ID: <20140429023449.GA13078@core.coreip.homeip.net> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Polled device's attributes controlling polling rate and whether polling is enabled are attached to input device. We should have device core instantiate them for us, so that they are created by the time new device notification is sent to userspace, instead of doing it ourselves afterwards. Signed-off-by: Dmitry Torokhov --- drivers/input/input-polldev.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/drivers/input/input-polldev.c b/drivers/input/input-polldev.c index 7f161d9..4b19190 100644 --- a/drivers/input/input-polldev.c +++ b/drivers/input/input-polldev.c @@ -147,6 +147,11 @@ static struct attribute_group input_polldev_attribute_group = { .attrs = sysfs_attrs }; +static const struct attribute_group *input_polldev_attribute_groups[] = { + &input_polldev_attribute_group, + NULL +}; + /** * input_allocate_polled_device - allocate memory for polled device * @@ -204,24 +209,21 @@ int input_register_polled_device(struct input_polled_dev *dev) input_set_drvdata(input, dev); INIT_DELAYED_WORK(&dev->work, input_polled_device_work); + if (!dev->poll_interval) dev->poll_interval = 500; if (!dev->poll_interval_max) dev->poll_interval_max = dev->poll_interval; + input->open = input_open_polled_device; input->close = input_close_polled_device; + input->dev.groups = input_polldev_attribute_groups; + error = input_register_device(input); if (error) return error; - error = sysfs_create_group(&input->dev.kobj, - &input_polldev_attribute_group); - if (error) { - input_unregister_device(input); - return error; - } - /* * Take extra reference to the underlying input device so * that it survives call to input_unregister_polled_device() @@ -245,9 +247,6 @@ EXPORT_SYMBOL(input_register_polled_device); */ void input_unregister_polled_device(struct input_polled_dev *dev) { - sysfs_remove_group(&dev->input->dev.kobj, - &input_polldev_attribute_group); - input_unregister_device(dev->input); } EXPORT_SYMBOL(input_unregister_polled_device);