Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp1638413imj; Thu, 14 Feb 2019 09:32:41 -0800 (PST) X-Google-Smtp-Source: AHgI3IaPFz9iJWi+x+RbIHhH5CIsebGy4J1VFNyTXTu6iTmqpb1jkk+VzYeO1J1V44aCq7sJ85pj X-Received: by 2002:a17:902:f64:: with SMTP id 91mr5386927ply.132.1550165561905; Thu, 14 Feb 2019 09:32:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550165561; cv=none; d=google.com; s=arc-20160816; b=QT8ztkCk2xcMpn2S0gmy2BV5bixa2UIBZQR2gmn1WaZyi0sqK1FxWSDCOPrtf5PqJw /7opOfxIFML3vR6L9PUi6kbrYADho7nuUbRh4m9jEGmbiUg6A77JXvuElzQV53AhmK7l emuNVdHbqIOu30zneUGJYFqJdHGSJHnJQvcoo2tTZSJHgeW+tYcM4cGiQ064dM6mf2iu M3/RjLQnglpYX4eCiuwiFRcHrq8HvMxhke4v6p5DELRJmd11oxcjqFvmA4OnRPYrCa5d +AYZ2lAz36FJGL4prH0TJ6ykWieOxIfLhyJKqfsHXmZaGEz92ulhI5NikJhNs1oC3lCv 3x2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=LHtcHrnSQhmETBrAVX+/ROQ2NPjs6N4/2wSyqqigMag=; b=RPd9Ssuoge3sX6MH9E6K86X2Yi/Jo2NApYz3x9d3xaaGU0fRMS2NIH5fouU8GwRQc8 K7uSphBeyuVPJCyApJIUfJWvl+8EfUSzKdy3XzNRk+FADhwntHEHHImKH5CPM0g0ns8h tEZjGWX+ldXQ8EHsi5AjzMvF8uSKaVh7LiJhYAkUgYmIaKrevhTWlpwFZR/nzwxrMfSv z3UT0CGcH9OlwJuiv3aUGbBZvmv51MvfdwQunPLZiXWo2ypgqnHOmG2hi2FkECWCdUSn skC8iFFkBfr7uTtKNfpPmSENaUpcM7cfp1JNTW+ZUiPYZ8enYaCEgZMqkQHKU5bvNiiF 2sVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WK5g6dY5; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y3si2915950plt.333.2019.02.14.09.32.26; Thu, 14 Feb 2019 09:32:41 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WK5g6dY5; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2438027AbfBNJoP (ORCPT + 99 others); Thu, 14 Feb 2019 04:44:15 -0500 Received: from mail-wm1-f68.google.com ([209.85.128.68]:34931 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2395221AbfBNJmx (ORCPT ); Thu, 14 Feb 2019 04:42:53 -0500 Received: by mail-wm1-f68.google.com with SMTP id t200so5377879wmt.0 for ; Thu, 14 Feb 2019 01:42:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=LHtcHrnSQhmETBrAVX+/ROQ2NPjs6N4/2wSyqqigMag=; b=WK5g6dY52UdybYrWUhtCYhHZYev8lLHS8GhU3R8Zo96paK4X6Zq9iuHFQYmAjK3Et8 ORYCtUFsLw4pp6hOeQUkq+6edptz6ku7c16PVYMMt4p7m7un6gXqcNl6I4dgepd5Ef+k oKuaxBhLAT9fAceEG9k7LJrj9GM8pfav2WSsnb4dA5NIn1l8ijh/FhLR46gd2A254Jp2 hxRyEQN8c+dqegh1JrojYWFd+WSKcjOsC3fRt6oxzOYR1pWR/TGCylJmCV4QG6F082eg VX0eokjsoi/39ORsZ8TXJv4U/YRYgzs6TjsFOPHBCe1ZKutelvu0DzsQGgBxwTZDRb30 P+Qg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=LHtcHrnSQhmETBrAVX+/ROQ2NPjs6N4/2wSyqqigMag=; b=s44JIA2/dkKyhXhCP59iuzmfqB2HIFcKDWOOYGH9pq29kN3tUSuNeLsCe+4MpAbCto MxyXgnHW+aUi+vHgGSQHNL9N1Ff7Y45Tfk+k6qeW+sn7gNrAi9/fBE2iWAaQCST5xX7r 94/PO81iLGQ3V9u7RFLaqQmvBdeC+3p9EFXpB4la8FDaK51BwCJC45Abe+zjGcQcL8/f HWsPyRxGGMv5E6sxi1D+WP0033+I3ZKcnqfQKZ1z+DFWKgM6QZVZCBd/LuEzwWvdB9LQ AG8x6AFSIi8jjOc/fusCyw6Enld6vbQV4wj1jhhub8R/hjSZWdG9xJEqsbHZAC+/F8P8 xjHw== X-Gm-Message-State: AHQUAuY9/BhIP7XqpvWgYRlei+u0cZeVJ6179NnolguoaX8W29S9ENG9 HqO4IZ//wDHphCu9aoTY+561fQ== X-Received: by 2002:a1c:5656:: with SMTP id k83mr1954542wmb.125.1550137371660; Thu, 14 Feb 2019 01:42:51 -0800 (PST) Received: from dell ([2a01:4c8:c:28c9:4c60:37da:d7a:230]) by smtp.gmail.com with ESMTPSA id b197sm4158597wmd.23.2019.02.14.01.42.50 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 14 Feb 2019 01:42:51 -0800 (PST) Date: Thu, 14 Feb 2019 09:42:48 +0000 From: Lee Jones To: Dmitry Torokhov Cc: Bartosz Golaszewski , Rob Herring , Mark Rutland , Linus Walleij , Jacek Anaszewski , Pavel Machek , Sebastian Reichel , Liam Girdwood , Mark Brown , Greg Kroah-Hartman , lkml , "open list:GPIO SUBSYSTEM" , DTML , "linux-input@vger.kernel.org" , Linux LED Subsystem , Linux PM , Bartosz Golaszewski Subject: Re: [PATCH 12/13] input: max77650: add onkey support Message-ID: <20190214094248.GI13737@dell> References: <20190118134244.22253-1-brgl@bgdev.pl> <20190118134244.22253-13-brgl@bgdev.pl> <20190119090318.GB187380@dtor-ws> <20190212203408.GA1863@dell> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 12 Feb 2019, Dmitry Torokhov wrote: > Hi Lee, > > On Tue, Feb 12, 2019 at 12:34 PM Lee Jones wrote: > > > > > > From: Bartosz Golaszewski > > > > > > > > Add support for the push- and slide-button events for max77650. > > > > > > > > Signed-off-by: Bartosz Golaszewski > > > > --- > > > > drivers/input/misc/Kconfig | 9 ++ > > > > drivers/input/misc/Makefile | 1 + > > > > drivers/input/misc/max77650-onkey.c | 135 ++++++++++++++++++++++++++++ > > > > 3 files changed, 145 insertions(+) > > > > create mode 100644 drivers/input/misc/max77650-onkey.c > > > > [...] > > > > Moving things around a bit: > > > > > > +static int max77650_onkey_probe(struct platform_device *pdev) > > > > +{ > > > > > > + irq_f = regmap_irq_get_virq(irq_data, MAX77650_INT_nEN_F); > > > > + if (irq_f <= 0) > > > > + return -EINVAL; > > > > + > > > > + irq_r = regmap_irq_get_virq(irq_data, MAX77650_INT_nEN_R); > > > > + if (irq_r <= 0) > > > > + return -EINVAL; > > > > > > Ugh, it would be better if you handled IRQ mapping in the MFD piece and > > > passed it as resources of platform device. Then you'd simply call > > > platform_get_irq() here and did not have to reach into parent device for > > > "irq_dara". > > > > These device IRQs were defined and registered with the Regmap *set* > > (actually init()) APIs and thus should be pulled out using the > > appropriate reverse Regmap *get* APIs here in the device. > > > > Registering them with Regmap *and* pulling them back out again in the > > same (MFD in this case) driver, only to register them as platform data > > is certainly not how I see the API being designed/used. > > > > > > + struct regmap_irq_chip_data *irq_data; > > > > + struct device *dev, *parent; > > > > > > + dev = &pdev->dev; > > > > + parent = dev->parent; > > > > + i2c = to_i2c_client(parent); > > > > + irq_data = i2c_get_clientdata(i2c); > > > > + > > > > + map = dev_get_regmap(parent, NULL); > > > > + if (!map) > > > > + return -ENODEV; > > > > However, this hoop jumping is a bit crazy and for the most part > > superfluous. Instead, create a struct of attributes you wish to share > > with the child devices (containing both regmap (which you should call > > regmap and not map by the way) and irq_data) and pass it as either > > platform data (preferred) or as device data. > > > > If you choose the latter, you do not need to convert from 'device' to > > 'i2c' to do the look-up. Since this function (probe()) is provided > > with a platform_device, you can just use platform_get_drvdata() to > > achieve the same as above. > > > > If you go the preferred (platform data) route, then you should use > > dev_get_platdata() instead. > > By doing what you are suggesting (introducing platform data) you > introducing strong dependency between MFD and input piece for no > different reason. With the current implementation the parent can be > reworked completely without involving onkey driver. > > I find such clean separation desirable. We are trying to move away > form platform data where it makes sense. Never mind. We found a way forward where everyone wins! Thanks for your time. -- Lee Jones [李琼斯] Linaro Services Technical Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog