From patchwork Tue Apr 19 16:53:25 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 8881691 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.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 0BC7C9F39A for ; Tue, 19 Apr 2016 16:53:34 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1A413202BE for ; Tue, 19 Apr 2016 16:53:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 06092202E5 for ; Tue, 19 Apr 2016 16:53:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753913AbcDSQxa (ORCPT ); Tue, 19 Apr 2016 12:53:30 -0400 Received: from mail-pa0-f44.google.com ([209.85.220.44]:33321 "EHLO mail-pa0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753303AbcDSQx3 (ORCPT ); Tue, 19 Apr 2016 12:53:29 -0400 Received: by mail-pa0-f44.google.com with SMTP id zm5so8364046pac.0; Tue, 19 Apr 2016 09:53:29 -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:references:mime-version :content-disposition:in-reply-to:user-agent; bh=YXY0nmgRDgBgXPNiar/XXVOAYmF8jInywd8NsSmIeqI=; b=B4itj3tIpFppplQAfD6Am4DmvqThBqy+PywMaYgUCbvwi9BJsREsyLvBxpICaQX3Q/ gQxujRVvl9pTU7/Rp3zT3wO2B2s20W9eVgO0chhLBOIrFGnYAUPLlDCwVO/j1FC+iJZK ZBf0kL9YoAGoamy8JawiyQ3JPdhIDgEbEnd0BGo1ZfVudhZzs+3B75CN31VtvE96VXIL sAWTG59DMig1ZCAgrMAMVzMSzdRcuyKTCf4NAZ4XjVrWNCEblW3/P/CultfPE0xU2Nf2 5vDbfX54ezxChbwk5V3cgGoDaRPOFYyqnL4/emCW3Cyd6rJDCFt9qdmltsSvtv8Z43hr kn3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=YXY0nmgRDgBgXPNiar/XXVOAYmF8jInywd8NsSmIeqI=; b=La6OZe6hcFje4iCjldUgx/Up7QQ/7xNsrCQQNZD7Y8+MjfGzboFcpwTBziqDMCD0LP XBK3OJLDTxPIBw6oFgHbLelFX8uULSMHRRldp41ffhSyszEronBes+5SzjeN4buen/LU oWT5HtvYvUyxyAcZ+2W8K3ZepfsekHm3fheAFKgYoRljPiTKCap6OhWeZj5MRK7DPDWo PMTCzqd+8xrAQJ5MmoDZ5+LKt/yjbemaIaKOfPb4C+6zGn063MTS9SUupOvmYRW8bkpk xUGzc7vbXG+77Xw6W4ZXhH75DCwz3T2A/hIqeq67SibbhTLVxBGVnEr+TeYMOzQ0g3gM IhUQ== X-Gm-Message-State: AOPr4FXmmt2nws+YCv3BuxoDAMnM5c/MlZ74/wbdhRV9edlQDNiNVUK98x3+h+4hzqdg/w== X-Received: by 10.66.132.72 with SMTP id os8mr5478723pab.63.1461084808819; Tue, 19 Apr 2016 09:53:28 -0700 (PDT) Received: from dtor-ws ([2620:0:1000:1311:7d3a:fe53:1d4b:289f]) by smtp.gmail.com with ESMTPSA id q72sm92120746pfa.70.2016.04.19.09.53.27 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Tue, 19 Apr 2016 09:53:27 -0700 (PDT) Date: Tue, 19 Apr 2016 09:53:25 -0700 From: Dmitry Torokhov To: "H. Nikolaus Schaller" Cc: Fabio Estevam , Peter Ujfalusi , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, kernel@pyra-handheld.com, letux-kernel@openphoenux.org Subject: Re: [PATCH 2/5] input: twl6040-vibra: add handler to unregister input if module is removed Message-ID: <20160419165325.GA2881@dtor-ws> References: <89f53877b821049c789256dd1b0c0b1dbb604de9.1461009340.git.hns@goldelico.com> <20160418211257.GA1006@dtor-ws> <20160419075705.GA13933@dtor-ws> <2C8A7B47-516D-4AA0-8231-16015387FA86@goldelico.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <2C8A7B47-516D-4AA0-8231-16015387FA86@goldelico.com> 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.8 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 On Tue, Apr 19, 2016 at 10:05:08AM +0200, H. Nikolaus Schaller wrote: > > > Am 19.04.2016 um 09:57 schrieb Dmitry Torokhov : > > > > On Tue, Apr 19, 2016 at 09:33:10AM +0200, H. Nikolaus Schaller wrote: > >> > >>> Am 18.04.2016 um 23:12 schrieb Dmitry Torokhov : > >>> > >>> On Mon, Apr 18, 2016 at 09:55:38PM +0200, H. Nikolaus Schaller wrote: > >>>> commit 1f9e1470ab34 ("Input: twl6040-vibra - use devm functions") > >>>> > >>>> converted everything to devm but we still need to call > >>>> input_unregister_device(info->input_dev) > >>> > >>> No, this is not needed, because devm-managed input devices will be > >>> unregistered automatically. > >> > >> Well, it would, if the current driver would use devm for registration. But it appears not to do it that way (line 375): > >> > >> https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/drivers/input/misc/twl6040-vibra.c?id=refs/tags/v4.6-rc4#n375 > >> > >> So we either have to fix line 375 or add the proposed explicit unregister call. > >> > >> Research shows me that you did propose devm_input_register_device() some years ago but this API was never included: > >> > >> https://lkml.org/lkml/2012/10/29/855 > > > > That's because we have what I mentioned in _OR_ portion of that email: > > > > /** > > * devm_input_allocate_device - allocate managed input device > > * @dev: device owning the input device being created > > * > > * Returns prepared struct input_dev or %NULL. > > * > > * Managed input devices do not need to be explicitly unregistered or > > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > > * freed as it will be done automatically when owner device unbinds from > > * its driver (or binding fails). Once managed input device is allocated, > > * it is ready to be set up and registered in the same fashion as regular > > * input device. There are no special devm_input_device_[un]register() > > * variants, regular ones work with both managed and unmanaged devices, > > * should you need them. In most cases however, managed input device need > > * not be explicitly unregistered or freed. > > * > > * NOTE: the owner device is set up as parent of input device and users > > * should not override it. > > */ > > > > Hm. If I remember correctly (it is a while ago) we had to add this explicit > unregister mechanism because we got ugly kernel panics otherwise. Indicating > that the input device was still registered and *not* unregistered automatically. Ah, it is probably because we are messing up with input device's parent. Can you please try the patch below? Thanks. diff --git a/drivers/input/misc/twl6040-vibra.c b/drivers/input/misc/twl6040-vibra.c index 0c853c2..53e33fa 100644 --- a/drivers/input/misc/twl6040-vibra.c +++ b/drivers/input/misc/twl6040-vibra.c @@ -357,7 +357,6 @@ static int twl6040_vibra_probe(struct platform_device *pdev) info->input_dev->name = "twl6040:vibrator"; info->input_dev->id.version = 1; - info->input_dev->dev.parent = pdev->dev.parent; info->input_dev->close = twl6040_vibra_close; __set_bit(FF_RUMBLE, info->input_dev->ffbit);