Received: by 2002:ac0:a679:0:0:0:0:0 with SMTP id p54csp149233imp; Wed, 20 Feb 2019 16:23:45 -0800 (PST) X-Google-Smtp-Source: AHgI3IYb+v/dMADHn1Z00fOalARSdqh7kzWAQVjVxaK1Jt5yEOL0ktQ8NhZShWkkmw4Ti0STbABk X-Received: by 2002:aa7:8c97:: with SMTP id p23mr38292296pfd.229.1550708625628; Wed, 20 Feb 2019 16:23:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550708625; cv=none; d=google.com; s=arc-20160816; b=tssdMy8I3ocbxb3Bulkdfm8QjfcOcL3WBADBXV8cqfW8suVWBWkMuNi/kXfKad5ZIW GedCc8oJD42Ae+8ihdC/1Lpr+O9eFWgOVQHl5wwjQTona9txfV3/svMSK7ct3JNZD+C2 XXaPyYWOqkTAE3b+34rNVopZSIAYlI00qhzNEdAOevQD/81IeXEjDC5063dJQuw72D3j /fhAFw7EbmJlzq2MFegY76vgQBrrdSpb0DU35k6jWKLDv5ma2QXHns5cViIKvd5LH8rh O2xb7vEFy60EWCZrhUjPpq9KPDQa+1yEZH09cb4fFJppMvLpsoYxe9nDb2pZT5mXe1gl DGvA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=jjWqUbBDvK3nC729N/p7FCit75OVtoymj2KU/ULiaRI=; b=Zgxb7kkwr7qwb+1e9Hc01lKtvUfW/qDy7oCYUYs9F/aUZel3IVfiaS5w5uM21B6pNj Ug91QFck/C/dIFZNMgrvhp7UkP0ufjmnXT6JlRLLTscugvdTbEju6jh6yYBmdtedo54d 8TpvKjbadRXAokUJ/BhABDnsTOYL9YCAbw7y4ehcU3vWqxFZcB9LcnYIyy9sh3J5VWJu NPIYzN5Nhv+Pth2YsPpAknoqe4Zbz8nVg2Nw9O38+UN01MzxDrTtWNmHRH6yiLf/tv+8 CnQLVLz/HXFUmC56AbcwVrbNgygNpTfpgDTXBIIVyV3oHBLyLGCHvItPqYClbWlrG0Bz uVbw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ingics-com.20150623.gappssmtp.com header.s=20150623 header.b=CrE8ljU9; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ay6si185143plb.293.2019.02.20.16.23.30; Wed, 20 Feb 2019 16:23:45 -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=@ingics-com.20150623.gappssmtp.com header.s=20150623 header.b=CrE8ljU9; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726998AbfBUAXI (ORCPT + 99 others); Wed, 20 Feb 2019 19:23:08 -0500 Received: from mail-wr1-f67.google.com ([209.85.221.67]:34388 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726121AbfBUAXH (ORCPT ); Wed, 20 Feb 2019 19:23:07 -0500 Received: by mail-wr1-f67.google.com with SMTP id f14so28132613wrg.1 for ; Wed, 20 Feb 2019 16:23:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ingics-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=jjWqUbBDvK3nC729N/p7FCit75OVtoymj2KU/ULiaRI=; b=CrE8ljU9PZbxOcslc9gmjImDEsWL7V6eptvX8xLRCjA+UxrrJeOgg6Me+gg9Cy6pYb iBmzTiFqMybTy6Z5GQQ6cHhStM5kBt1vtVQ3QD6w9Mn/Vnlz5ANa6oHyaO8i0dmQEnm+ qxk/MoHFKPwcx1AXZbG2d07LdDQBscqQjWEeh2E/YGGYu3Qv1N0/KwsC5mHJSIQ4hINc mIYx9qGqu5TfC+rJXCEW2sGsojrO5cpmlmyO/PdSLTBQHuJjlpOa1kFvWt39/sBQGf+y CLkty0EX6lQpOMcVshcE00w4ijRECShBaT8UKSThI2bDWYDaIkUc2jt+nrCxxettiLi/ DqxQ== 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:content-transfer-encoding; bh=jjWqUbBDvK3nC729N/p7FCit75OVtoymj2KU/ULiaRI=; b=UeshkTgBbC1qwg2n5juz/IvwYKd1LOMnqojmTX+9KSbP5Wq+kvztOwIeyrJxuWOX+0 ETH8tUEcuhrss/RAO5xNk+vvwEn9uHrgcoaSuk3fIIpHD/WH1VtlbVbOVWtuLW6ptFeg rtVP9zoLX4xZD+tHW4w7dvQY+5jD2Z4PKzKYLtWAWebjfWJv9X/cg13gnFmxzrmN2zz3 IOAgXL3QBwILbta2qUhXm1faEFqSd4bO+FGgdWEKMyTGFvqkRaI1AmPOSqxqabY9j6Gx 23BK2QtDN1GaDJrgFibPBPhsyXqR9qALSghKMLJ3/KTpHaSlcUJkmXFrsXk3FwMr4zn8 343A== X-Gm-Message-State: AHQUAuZfNzjd9UhvhHdPSIH4RcZVtqooK4PhXxTQHlbL0nUiyYsnDKlj GMs0jLtFjZMb/5bo37wbVA7HSamfoxQLUDyCo38yGg== X-Received: by 2002:adf:e48a:: with SMTP id i10mr27779817wrm.257.1550708585334; Wed, 20 Feb 2019 16:23:05 -0800 (PST) MIME-Version: 1.0 References: <20190220165013.12774-1-axel.lin@ingics.com> <24E35288-677D-4223-B94A-52A4F37792A8@schinagl.nl> In-Reply-To: <24E35288-677D-4223-B94A-52A4F37792A8@schinagl.nl> From: Axel Lin Date: Thu, 21 Feb 2019 08:22:53 +0800 Message-ID: Subject: Re: [PATCH] regulator: axp20x: Get rid of AXP20X_xxx_START/END/STEPS defines To: Olliver Schinagl Cc: Mark Brown , Chen-Yu Tsai , Priit Laes , Liam Girdwood , LKML Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Olliver Schinagl =E6=96=BC 2019=E5=B9=B42=E6=9C=8821= =E6=97=A5 =E9=80=B1=E5=9B=9B =E4=B8=8A=E5=8D=886:57=E5=AF=AB=E9=81=93=EF=BC= =9A > > Hey Axel, > > On February 20, 2019 5:50:13 PM GMT+01:00, Axel Lin = wrote: > >The AXP20X_xxx_START/END/STEPS defines make the code hard to read and > >very hard to check the linear range settings because it needs to check > >the defines one-by-one. > >The original code without the defines is very good in readability > >as the meaning of each field of REGULATOR_LINEAR_RANGE is clear. > >So I suggest to get rid of AXP20X_xxx_START/END/STEPS defines. > Are you suggesting that magic values and hex numbers are more readable? For example: static const struct regulator_linear_range axp803_dcdc234_ranges[] =3D { REGULATOR_LINEAR_RANGE(500000, 0x0, 0x46, 10000), REGULATOR_LINEAR_RANGE(1220000, 0x47, 0x4b, 20000), }; Above looks very clear to me as it describes the linear ranges: 1st linear range: min_uV is 500000, from selector 0 ~ 0x46, the uV_step is = 10000 2nd linear range: min_uV is 1220000, from selector 0x47 ~ 0x4b, the uV_step is 20000 And it's easy to check the min_sel and max_sel in each linear range. Now, take a look at below code: static const struct regulator_linear_range axp803_dcdc234_ranges[] =3D { REGULATOR_LINEAR_RANGE(500000, AXP803_DCDC234_500mV_START, AXP803_DCDC234_500mV_END, 10000), REGULATOR_LINEAR_RANGE(1220000, AXP803_DCDC234_1220mV_START, AXP803_DCDC234_1220mV_END, 20000), }; 1st linear range: I have to check what is AXP803_DCDC234_500mV_START for min_sel, then check what is AXP803_DCDC234_500mV_END for max_sel, and AXP803_DCDC234_500mV_END is AXP803_DCDC234_500mV_START + AXP803_DCDC234_500mV_STEPS so I have to check if AXP803_DCDC234_500mV_STEPS is correct or not. The same for 2nd linear range. It's unnecessary complexity. And it's just for 2 linear ranges, for axp20x_ldo4_ranges with 5 linear ran= ge, it's really hard to check the settings. IMHO, In such case, the defines does not help. It's a rare case that I suggest to remove the defines. > > Maybe you can explain what your problem is, as it appears you are trying = to debug something? well, I just read the code. I just found it's very hard to read the linear range setting for this drive= r. Regards, Axel