From mboxrd@z Thu Jan 1 00:00:00 1970 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 C1CA0EB64D7 for ; Thu, 29 Jun 2023 01:27:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229469AbjF2B1U (ORCPT ); Wed, 28 Jun 2023 21:27:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41306 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229994AbjF2B1R (ORCPT ); Wed, 28 Jun 2023 21:27:17 -0400 Received: from mg.richtek.com (mg.richtek.com [220.130.44.152]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 1ED721FE7; Wed, 28 Jun 2023 18:27:14 -0700 (PDT) X-MailGates: (flag:4,DYNAMIC,BADHELO,RELAY,NOHOST:PASS)(compute_score:DE LIVER,40,3) Received: from 192.168.10.47 by mg.richtek.com with MailGates ESMTP Server V5.0(12339:0:AUTH_RELAY) (envelope-from ); Thu, 29 Jun 2023 09:27:04 +0800 (CST) Received: from ex3.rt.l (192.168.10.46) by ex4.rt.l (192.168.10.47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.25; Thu, 29 Jun 2023 09:27:03 +0800 Received: from linuxcarl2.richtek.com (192.168.10.154) by ex3.rt.l (192.168.10.45) with Microsoft SMTP Server id 15.2.1118.25 via Frontend Transport; Thu, 29 Jun 2023 09:27:03 +0800 Date: Thu, 29 Jun 2023 09:27:03 +0800 From: ChiYuan Huang To: Mark Brown CC: , , , , , Subject: Re: [PATCH 2/2] regulator: rt5739: Add DID check and compatible for rt5733 Message-ID: <20230629012703.GA10948@linuxcarl2.richtek.com> References: <1687942037-14652-1-git-send-email-cy_huang@richtek.com> <1687942037-14652-3-git-send-email-cy_huang@richtek.com> <2a8732f4-13fe-476d-9ae7-b970bd82c218@sirena.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <2a8732f4-13fe-476d-9ae7-b970bd82c218@sirena.org.uk> User-Agent: Mutt/1.5.21 (2010-09-15) Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org On Wed, Jun 28, 2023 at 12:47:50PM +0100, Mark Brown wrote: > On Wed, Jun 28, 2023 at 04:47:17PM +0800, cy_huang@richtek.com wrote: > > > + if (did == RT5733_CHIPDIE_ID) { > > + min_uV = RT5733_VOLT_MINUV; > > + max_uV = RT5733_VOLT_MAXUV; > > + step_uV = RT5733_VOLT_STPUV; > > + } else { > > + min_uV = RT5739_VOLT_MINUV; > > + max_uV = RT5739_VOLT_MAXUV; > > + step_uV = RT5739_VOLT_STPUV; > > + } > > It would be better to write these as switch statements so if any more > variants turn up they can be added more easily. Since the IC difference is only voltage range and step, They can be retrieved from the regulator description. To check DID here may not a good coding. I may rewrite it as below max_uV = desc->min_uV + desc->uV_step * (desc->n_voltages - 1); And put a switch case for DID check in 'init_regulator_desc'. Is it better?