Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp142681ybz; Wed, 15 Apr 2020 06:07:35 -0700 (PDT) X-Google-Smtp-Source: APiQypLiABi+rDwIwaspXxAFWrYoKN0T0mCYv+l5cu9VVcqjlw2hwcSqa8VSF0HtVcB3IffOYvg3 X-Received: by 2002:a17:906:cb92:: with SMTP id mf18mr5010754ejb.366.1586956055460; Wed, 15 Apr 2020 06:07:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586956055; cv=none; d=google.com; s=arc-20160816; b=02iKXWxWFC9wt+hfmjiY+scQoqPVg0aFOrM/shD7+V/QXzI+rgkwHDp/syaGv/Qn3D f5YucpQFl34GhKeFRYmndCU9Mk0MZ85ibK2OYGER7pd7a2z8/sM7o5wNO1WzdWO1zpL6 8Z1Y0q0OTa2WzYOLh+BnxVUQmxBpkXMfX8sZJ1dJZQlpvMrJVQdU2+O95sjO2XVDba2O BnOLfwL1HJG3X2+fiXoBdqOh/dZ/GoFqct5NK4yCKOhgs5wp61d93Oj4px/W1EtDN1Sc 1+lCT9PgJpgmp+/r1kfpEnQ5aQAoAQmZYJJVFYDA40JGiW16h1j7ZNpH/dEYVWRxuW0O SgWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:message-id:references :in-reply-to:subject:cc:to:from:date:content-transfer-encoding :mime-version:dkim-signature; bh=l8iSoKOFISTm7e3WSV4reMrghBve1U8G6s6rKNmMUNA=; b=fLmTDKPHckqK5NutygwToD4s0fj+daIxHwmKYZuUuXBe8URLx6Mt+ROEklSnCGoKKe tvZr7gudsTYKg9fDcJOoebEEQkpNFoV3dAGcH+VXrapfEEycHm7QdVVEfjCX+CDf/XBj g4abyWpr0knOgozMpC2ZjUw0BHiqJb/7qm6Y54zqvpNcIfR7vM6K/3pH48CBWLUHxdc3 7iw2w4thTT0veYvyl9gHpFTFQY85yjF9P7KK61YbUJRK3qDcqADZRMNxXNWm7dk0aTRx YMKu84IvjqWhaaQgFofhgr+tDJoV8DJA/RQHJupO53ahm5zA5C5YAb0LKTo20c8K7Qud xHRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@walle.cc header.s=mail2016061301 header.b=rtveXxXS; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cb8si4482038ejb.96.2020.04.15.06.07.10; Wed, 15 Apr 2020 06:07:35 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@walle.cc header.s=mail2016061301 header.b=rtveXxXS; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2504163AbgDNSmB (ORCPT + 99 others); Tue, 14 Apr 2020 14:42:01 -0400 Received: from ssl.serverraum.org ([176.9.125.105]:42151 "EHLO ssl.serverraum.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729777AbgDNSlw (ORCPT ); Tue, 14 Apr 2020 14:41:52 -0400 Received: from ssl.serverraum.org (web.serverraum.org [172.16.0.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ssl.serverraum.org (Postfix) with ESMTPSA id 02BB72222E; Tue, 14 Apr 2020 20:41:46 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=walle.cc; s=mail2016061301; t=1586889706; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=l8iSoKOFISTm7e3WSV4reMrghBve1U8G6s6rKNmMUNA=; b=rtveXxXS06F/NYmV9F2bGS5feXtMfE9gJBoboXZn8qEe9Lv/Pdw+PkB3WYbQaCUuxLEI6I 01s6XbVlOTMD8dnUpTguXYKOq3sSaQOCnztQCPF9doXoASZlztSVASr7gO1ILou1R9B2WC mzBh5hFIxbe65adMWQoMX24W8N21isE= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Date: Tue, 14 Apr 2020 20:41:45 +0200 From: Michael Walle To: Bartosz Golaszewski Cc: linux-gpio , linux-devicetree , LKML , linux-hwmon@vger.kernel.org, linux-pwm@vger.kernel.org, LINUXWATCHDOG , arm-soc , Linus Walleij , Rob Herring , Jean Delvare , Guenter Roeck , Lee Jones , Thierry Reding , =?UTF-8?Q?Uwe_Kleine-K=C3=B6nig?= , Wim Van Sebroeck , Shawn Guo , Li Yang , Thomas Gleixner , Jason Cooper , Marc Zyngier , Mark Brown , Greg Kroah-Hartman Subject: Re: [PATCH v2 10/16] gpio: add a reusable generic gpio_chip using regmap In-Reply-To: References: <20200402203656.27047-1-michael@walle.cc> <20200402203656.27047-11-michael@walle.cc> <80bd8661ec8a1f5eda3f09a267846eaa@walle.cc> Message-ID: <62d157198a75a59ada15c496deeab49b@walle.cc> X-Sender: michael@walle.cc User-Agent: Roundcube Webmail/1.3.10 X-Spamd-Bar: + X-Spam-Level: * X-Rspamd-Server: web X-Spam-Status: No, score=1.40 X-Spam-Score: 1.40 X-Rspamd-Queue-Id: 02BB72222E X-Spamd-Result: default: False [1.40 / 15.00]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; FREEMAIL_ENVRCPT(0.00)[gmail.com]; TO_MATCH_ENVRCPT_ALL(0.00)[]; TAGGED_RCPT(0.00)[dt]; MIME_GOOD(-0.10)[text/plain]; DKIM_SIGNED(0.00)[]; RCPT_COUNT_TWELVE(0.00)[23]; NEURAL_HAM(-0.00)[-1.082]; RCVD_COUNT_ZERO(0.00)[0]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; FREEMAIL_CC(0.00)[vger.kernel.org,lists.infradead.org,linaro.org,kernel.org,suse.com,roeck-us.net,gmail.com,pengutronix.de,linux-watchdog.org,nxp.com,linutronix.de,lakedaemon.net,linuxfoundation.org]; MID_RHS_MATCH_FROM(0.00)[]; SUSPICIOUS_RECIPS(1.50)[] Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Am 2020-04-14 19:00, schrieb Bartosz Golaszewski: > wt., 14 kwi 2020 o 12:07 Michael Walle napisaƂ(a): >> >> >> >> So the best from a user perspective I've could come up with was: >> >> >> >> ->base_reg = GPIO_REGMAP_ADDR(addr); >> >> >> >> I'm open for suggestions. >> >> >> > >> > Maybe setting the pointer to ERR_PTR(-ENOENT) which will result in >> > IS_ERR() returning true? >> >> Unfortunatly, its not a pointer, but only a regular unsigned int (ie >> the type the regmap API has for its "reg" property). It could be a >> pointer of course but then the user would have to allocate additional >> memory. >> >> -michael >> > > Eek, of course it's not a pointer. If possible I'd like to avoid this > GPIO_REGMAP_ADDR() macro, so how about having some separate field for > invalid offsets making every offset 'valid' by default? IMHO this has the same problems as mentioned in the response to Mark's idea. Normally, the user sets only some addresses, thus he has to mark all other as invalid. And if you add another address, you have to touch all the drivers to mark it as invalid. We could add some force bits like the "use_ack" flag in the bgpio driver, where you can force the use of the value 0. But I'd really like to find a better way.. -michael > > Linus: do you have a better idea? > > Bart