Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F32C0C05027 for ; Thu, 2 Feb 2023 15:09:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230021AbjBBPJB (ORCPT ); Thu, 2 Feb 2023 10:09:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49890 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232408AbjBBPIr (ORCPT ); Thu, 2 Feb 2023 10:08:47 -0500 Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1E82A93E3C for ; Thu, 2 Feb 2023 07:08:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1675350504; x=1706886504; h=date:from:to:cc:subject:message-id:references: mime-version:content-transfer-encoding:in-reply-to; bh=oNLoDCrNz5E3tpcWjxQu6H5DXL42C8IWrVoNuwWD2eI=; b=J1mO2SHR+hEbzcxD8mhLD3gkBA4yoKtATcfQHhbzlzGqrGSzMmqDMUMd 3INIReycQxAbZFERPobujjgzxBSJ/riLXJBm7bZPyUng3DxCmDYCCdakM Vo4d11Zz1KuEhji71r5+0lEdxTtpaVw6rq8ikJkX8Cz9ADUjps8Fy4djG HXWPZOCsdEjpfDB+Qw4OH34JO49asVbcEA5n1x4SaS1LEE+HFPTINK29E K5nzfdi7SEuSTuT8Z4ppOOiLZ1u0x5SfW7xNbnxAg736Zg2KmB8zz5MUz X917VKTlhvmojbaHTpg1KddVoakyjxipql+Q6QEfr6NUcHRRJZ/ey0cmo Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10608"; a="308805454" X-IronPort-AV: E=Sophos;i="5.97,267,1669104000"; d="scan'208";a="308805454" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Feb 2023 07:06:53 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10608"; a="789310975" X-IronPort-AV: E=Sophos;i="5.97,267,1669104000"; d="scan'208";a="789310975" Received: from smile.fi.intel.com ([10.237.72.54]) by orsmga004.jf.intel.com with ESMTP; 02 Feb 2023 07:06:50 -0800 Received: from andy by smile.fi.intel.com with local (Exim 4.96) (envelope-from ) id 1pNbAl-001E3s-2C; Thu, 02 Feb 2023 17:06:47 +0200 Date: Thu, 2 Feb 2023 17:06:47 +0200 From: Andy Shevchenko To: Levente =?iso-8859-1?B?Uul26XN6?= Cc: Martyn Welch , Linus Walleij , Bartosz Golaszewski , Haibo Chen , Puyou Lu , Justin Chen , Andrey Gusakov , Nate Drude , linux-gpio@vger.kernel.org, Peter Robinson Subject: Re: [RFC PATCH 3/3] gpio: pca953x: Redesign register address calculation Message-ID: References: <5a4ce37a-2d5b-d179-dd1b-04fdd038c63f@eilabs.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <5a4ce37a-2d5b-d179-dd1b-04fdd038c63f@eilabs.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org On Mon, Jan 30, 2023 at 09:59:55PM +0100, Levente Révész wrote: > The driver supports 8 chip types, 6 of which have extended registers > with various functions, e.g. pull-up and pull-down bias for the gpio > lines or interrupt masking. To allow supporting these functions, the > driver has to be able to calculate the addresses of these registers. > > Replace the address calculation scheme with new reg_addr() and check_reg() > functions, one for each register layout. The new functions can work with > all of the extended registers. The functions have been tested with the > register layout of each compatible chip. ... > +/* > + * Register types: > + * - Single register: 1 byte for each GPIO port. > + * - Double register: 2 bytes for each GPIO port. > + * - One-byte register: Only a single byte. We use term "bank". > + */ ... > + * Returns -1 if reg_addr is invalid. Use proper error code. ... > + * Convert register address to register enum value. > + * Returns -1 if reg_addr is invalid. Ditto. -- With Best Regards, Andy Shevchenko