Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp1087439ybz; Thu, 16 Apr 2020 02:36:16 -0700 (PDT) X-Google-Smtp-Source: APiQypI9EKQH1OuWyDrUFSSPCtvxGzIpmsSyJjfdR2RePJo0b874k3S3j8m4F5T+XV7pcqyOqfRb X-Received: by 2002:a50:a642:: with SMTP id d60mr28943370edc.351.1587029776109; Thu, 16 Apr 2020 02:36:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587029776; cv=none; d=google.com; s=arc-20160816; b=zwAVVoYxBcj+4hftjYvb+KlbhtrFIrK72G6cdTY70DlEnU6TlhvRPAPKk+q82NVE7R A/SaIRAPPxshJvPZ/3E4QDQI5bNs8zewPPugaaacWOOYhTns7tH5Oeob/EVHlwDQLqWJ wwciRzA7cjOHABk4wBwLM6TdVht7SfhWRloGL2qH8XnNklLo0nwoKytP195Ele+27720 rQ9XjcQHgBavSR9TCdwzXQKo8mx0vmU/HxDcvvF1T2I0TRj6mdgWMkBSkw1d7gYMcfSb PfhVZrKAJvVHmdqVtm9N4idKoMl49rhV0U2LLEGCL7h9ZmpjIYNCbjwFQKF1qKCIDRB/ IKPw== 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=Wl0AyceV1HH2Bd5JaxMdDxBcxIXT6A+UuSLy9IcpOs4=; b=OVZyocMP1rY2YXCPpEFPpROUBxbv5iYPT0tQMXoNBsZpqDhBUCs5hLaFeFgXX+kRJt g3bOmis6Q4GiX7kNpIoHBIRxFVe0fQ1gbxJ3zoDMmPUxXUICIBcWf99Xp55GxeNHLyUW ME96G43q7zp731uomlTy1eNL6A+bhbhGXl0RB33irnBEBPV0u38FQwTHID0Q69ZzHSzT 6QamYW0AHNG3NNSLU6fKeWX+XsfkZmVypL5whg4K0oFrRh+wdt6Fov25w5uoqEVle3hI 6aDxqsChPSWoISJLHuWOMYeSyFLa9sc/YUoCbKlmENswryxM7LZI4GP2sGS/TBEM2VNE cVkA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@walle.cc header.s=mail2016061301 header.b=fdSgq9Lv; spf=pass (google.com: 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 g6si11489526edp.283.2020.04.16.02.35.53; Thu, 16 Apr 2020 02:36:16 -0700 (PDT) Received-SPF: pass (google.com: 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=fdSgq9Lv; spf=pass (google.com: 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 S2503607AbgDPJeq (ORCPT + 99 others); Thu, 16 Apr 2020 05:34:46 -0400 Received: from ssl.serverraum.org ([176.9.125.105]:55287 "EHLO ssl.serverraum.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2503587AbgDPJee (ORCPT ); Thu, 16 Apr 2020 05:34:34 -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 135AA22F53; Thu, 16 Apr 2020 11:34:26 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=walle.cc; s=mail2016061301; t=1587029666; 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=Wl0AyceV1HH2Bd5JaxMdDxBcxIXT6A+UuSLy9IcpOs4=; b=fdSgq9LvNOGqIy0gUfMq93deaPw6BZqZHdv+a38XnNPqqltZFNASH8ql6fitG2O9ld7Fhd 89CCvLeW9VQPPWsn6QhIAbe2kDBbC8GjtJta3+KazM2VUze0Fpwb1G7AZsv7C/L7/DB79C HBuO5V1WWdBRNC5k1tGvQI1iyeMkQhA= MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Thu, 16 Apr 2020 11:34:26 +0200 From: Michael Walle To: Linus Walleij Cc: Bartosz Golaszewski , linux-gpio , linux-devicetree , LKML , linux-hwmon@vger.kernel.org, linux-pwm@vger.kernel.org, LINUXWATCHDOG , arm-soc , 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> <62d157198a75a59ada15c496deeab49b@walle.cc> Message-ID: <576a6244fa3b996327c49023fe953215@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: 135AA22F53 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)[-0.404]; RCVD_COUNT_ZERO(0.00)[0]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; FREEMAIL_CC(0.00)[baylibre.com,vger.kernel.org,lists.infradead.org,kernel.org,suse.com,roeck-us.net,linaro.org,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-16 11:20, schrieb Linus Walleij: > On Tue, Apr 14, 2020 at 9:57 PM Michael Walle wrote: > >> So what about the following: >> >> #define GPIO_REGMAP_ADDR_ZERO (unsigned int)(-1) > > Yeah with regmap explicitly using int I guess we can't use > S32_MAX, so that is fair. > >> So this way the user might assign the base addresses the normal way >> except when he wants to use zero, in that case he has to use >> >> ->base_adr = GPIO_REGMAP_ADDR_ZERO; >> >> gpio-regmap.c could use then: >> >> if (base_addr) >> something_useful(gpio_regmap_addr(base_addr)); >> >> unsigned int gpio_regmap_addr(unsigned int addr) >> { >> return (addr == GPIO_REGMAP_ADDR_ZERO) ? 0 : addr; >> } > > That's reasonably clean. Ok, at least on that side. For my sl28 gpio driver I then have the problem that depending on 'base' I might have to use GPIO_REGMAP_ADDR_ZERO: #define GPIO_REG_DIR 0 config.reg_dir_out_base = base + GPIO_REG_DIR; So there is still a convenience macro: #define GPIO_REGMAP_ADDR(addr) ((addr) ? addr : GPIO_REGMAP_ADDR_ZERO) which you can use if you can't be sure that the address is not non-zero. So the code in my sl28 gpio driver looks like: config.reg_dir_out_base = GPIO_REGMAP_ADDR(base + GPIO_REG_DIR); I'll respin the patch with the current remarks. -michael