Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp4847290imj; Wed, 13 Feb 2019 02:03:13 -0800 (PST) X-Google-Smtp-Source: AHgI3IZeYlae+TWDR4wUzoVOv6ymhr73TKW1wKl+mmlsrw5Iwpf91VDw/+84CS51oQxJA5CzQnfL X-Received: by 2002:a62:1b03:: with SMTP id b3mr8979647pfb.218.1550052193728; Wed, 13 Feb 2019 02:03:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550052193; cv=none; d=google.com; s=arc-20160816; b=VDIbaDViOm+I7jeP6BFF5zecy8BCgVHzJvLOzrFpuWpXkcB3a0YYhib0zfjqUOGDPd j5/Xfd0nXtPGdh1/pUsIMXPW0oiIp0LPL+Zz5uRqAxZx/VKoYBDqK8Vb2BeFyclEjFlc dHvdmAD25kB0wcmDnNzDH0t8BqIzfpK5/tO1V52Y7c6KhjbO71QU9Px10WV8sYXBK3Dj UHOz9wxLYtUSZ4NXQokTHQaqKJMcfi8CS4Ob+V4u7B6oExsX7fOaCMfCHa5kQE4DJOnS 8fXCoDhqruQKWlU4xWsUDFmeieS0b8VuHQKKaL8U/ggzGWXcSvXVlYsFYMNLcazJbqcI l1BA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=/PGOtFQP2glJh8X2lYD7XOqlwPMjpkV+z0GGZhUQueM=; b=h31AGwOXvAg3DSqEEVz4zvZRCYUp6Ms2yVN18VHyigamwCTj7JtH3WPO4BYoooF4BN 3c0cEV3PEbaaVMy7GStYmmZtXha5TossDAHfZdmnogbKNTqK/Rs3SVeYHK2+qCbpr3gb j9uXmz4Lk0FmPm6krbor1YU8LIyfgNP1qZNBgqWu2cUhRCNUl6weHIW2MZIUxBznlgLP LvgJqEgdaqNiwgtIFntruJkWLfRowFXIOdrLhAtH48QdMbOmNqi4B5n2ZKGjUJ/O7V1w Yg0SAk0lsOZ3f6Lqwadn98D4yNSAy1JaAi6BnIkoY6AzXb2sZUyCY5EZBVPMPqcxCDuu 0UfQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=OMI05su8; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d1si342243pls.164.2019.02.13.02.02.55; Wed, 13 Feb 2019 02:03:13 -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=@gmail.com header.s=20161025 header.b=OMI05su8; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389683AbfBMHab (ORCPT + 99 others); Wed, 13 Feb 2019 02:30:31 -0500 Received: from mail-it1-f196.google.com ([209.85.166.196]:34106 "EHLO mail-it1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732822AbfBMHab (ORCPT ); Wed, 13 Feb 2019 02:30:31 -0500 Received: by mail-it1-f196.google.com with SMTP id j17so885701ita.1; Tue, 12 Feb 2019 23:30:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=/PGOtFQP2glJh8X2lYD7XOqlwPMjpkV+z0GGZhUQueM=; b=OMI05su8Y6mGlUPLyMHePKvd66LqGIi5rhwHBSNFOUS8y2saTp0eCjCxgwHZc/RfkE sx6tuYIVwUbd0ak8yiwaJ91VI5MVVxGKG8tem7pL1gn8WGhY4K4wa4bVcKQGYjpQaBpM FfI7289nZ0HuoWunkOJjBbdvSXKg89ykakqgJq9BJPcWvh1o0H3Rmi3UiNlKUVYPZd59 EQddw2uCWckrqoVHrxWdFnXAXbwpCsreWInU2zALfpoGiP4MJlejob9CoZCjvdTnXODi tzZyqKSJE15gZ3YL6CbeKDaa/Lf2n4JI6qazC1Hm1YuCLBPIm2GBStqw8WuP4QHZTdjv sEyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=/PGOtFQP2glJh8X2lYD7XOqlwPMjpkV+z0GGZhUQueM=; b=Nsd+tdqIV+uTtVLwjc2fuuXuE00RJYpuB3AsC/gWFFiEiyRClMazufQ7fPaaUph8wt 5a1llvelpeVc1V6HKXSjFnOPOS61sPDXXFEYc/3AmrwSHoBPQT/WBEJpGQFrD++33pom zey5SETDbxZcREAGT2IK1/ZWXCpPkmMtAJDAm0EP5eypqZ7KQduFnANmjRR2imtrOx63 hjkscXQSJ6+w68oKIIQZD4Iyg+2vlylj3SDJIjYDvpVG61XcDZulZHalrhWkIdgcKmZl rraY6PAcJgOTP41pA+9V6ir2A2JB0u3OVpfpORIhByn82+84xnXDc4OHVR6w0I+lWKsm PZDw== X-Gm-Message-State: AHQUAuYo8pze6s/RdwDXkiFKRk3FjOv7NHZwmuZ8osqnrkBtu/2ipSs8 MSNpIbvkBtL3i/65RSc9LdCGmTuSsZWXH2NKY8E= X-Received: by 2002:a6b:9106:: with SMTP id t6mr4847187iod.298.1550043029362; Tue, 12 Feb 2019 23:30:29 -0800 (PST) MIME-Version: 1.0 References: <20190118134244.22253-1-brgl@bgdev.pl> <20190118134244.22253-13-brgl@bgdev.pl> <20190119090318.GB187380@dtor-ws> <20190212203408.GA1863@dell> In-Reply-To: <20190212203408.GA1863@dell> From: Dmitry Torokhov Date: Tue, 12 Feb 2019 23:30:17 -0800 Message-ID: Subject: Re: [PATCH 12/13] input: max77650: add onkey support To: Lee Jones 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 Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Thanks. -- Dmitry