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 5ACF8C05027 for ; Tue, 14 Mar 2023 16:50:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230515AbjCNQul (ORCPT ); Tue, 14 Mar 2023 12:50:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33068 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230475AbjCNQuh (ORCPT ); Tue, 14 Mar 2023 12:50:37 -0400 Received: from mail-qk1-x733.google.com (mail-qk1-x733.google.com [IPv6:2607:f8b0:4864:20::733]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 84091A90A8; Tue, 14 Mar 2023 09:50:35 -0700 (PDT) Received: by mail-qk1-x733.google.com with SMTP id bm1so928510qkb.13; Tue, 14 Mar 2023 09:50:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678812634; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=qeeMTBeHxd/XKAWq9zMSxWQt+iGsLohYMBPFE0cHKVw=; b=TEzl5OOjEfi4ZoGOkYN8gZFJ9gtcaQIqJwed9zRK/We5JdhhaPjWnKyIoazv/xeGma jB/RIr1qGrOugUO+eFk1R5B+fT5Zw4TRiYkLR6VgwPWh6pK7kMDSaYY4th2TsTWhl0vR mQa/iCgSU/2gX6ZcJ4l3UL8vJqPoK7I8vFJehWeb2gjdcy+1l1LJjEI95rh2AuSVGUwW Oqnh82Q0MF621wl4L0Gn5IArlQX7YU7LIYIGG29D+lRj09YL8dDwaZaaodx6urCZZqZr B8+oQBBPAPFJu53GBTK5I+7YJjWA0SIs1sNZaA6qkdfXmc3eapYpWYbi88C+IMGVD92v bQmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678812634; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=qeeMTBeHxd/XKAWq9zMSxWQt+iGsLohYMBPFE0cHKVw=; b=ThBM7SLvRRFXZFMCvzZ2sXoR8+kouJEoEaDQzqUAH8odh/MoJ8RKtKzJlnax9xCx5t feDWMqx5IrRiLG9Tt5w006Ae7rarUVmdvW7Dv8qQ7AZdP/3JS7P+OuF35MjzPQsKzbOW pi0NfPaRv1XZKQKZGtDBH1wUiXTWfD+jy865sbeQnWwZdXLp0LLXDvgUdo4kIIuJRilL /ZP72CrrXJ8h3sWHiJ2TqcaUEkZHO0IhjkNKXyJAZCP7n0UK74D7Na1kVJWA3g70XjBn ZcPvuJTg7NU/e4dYjvLuipPHYNTva6Vy6M3OLe9ikZLkEUxr081ohAILrIf+fT4tUpPf tF5A== X-Gm-Message-State: AO0yUKXBDsg0OqCLIPZG66idNtqApPY+OA/M2jOfsvvpQ1mbKqbf6CDr 20kG5o6bGpxCh3bXvodFLeA4s3DgRLDsRGNmDeGcGNjkvQx1WA== X-Google-Smtp-Source: AK7set/RFZPS8a3N7ASDY49n0VTB0jswh+PB2qIEhyPfsAQHwJveha5H2uRDx8YRx1h+MqhkRHtiFgb2H3Vv5b1128Q= X-Received: by 2002:a05:620a:1389:b0:743:9b78:d97e with SMTP id k9-20020a05620a138900b007439b78d97emr3365593qki.14.1678812634602; Tue, 14 Mar 2023 09:50:34 -0700 (PDT) MIME-Version: 1.0 References: <20230314120252.48263-1-mmkurbanov@sberdevices.ru> <20230314120252.48263-3-mmkurbanov@sberdevices.ru> <3b920b9e-07dc-7bda-4fe1-d15d07e708cc@sberdevices.ru> In-Reply-To: From: Andy Shevchenko Date: Tue, 14 Mar 2023 18:49:58 +0200 Message-ID: Subject: Re: [PATCH v3 2/2] leds: add aw20xx driver To: Martin Kurbanov Cc: Pavel Machek , Lee Jones , Rob Herring , Krzysztof Kozlowski , linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org, kernel@sberdevices.ru, devicetree@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Mar 14, 2023 at 6:22=E2=80=AFPM Andy Shevchenko wrote: > On Tue, Mar 14, 2023 at 2:12=E2=80=AFPM Martin Kurbanov > wrote: > > On 2023-03-01 00:51, Andy Shevchenko wrote: ... > > >> +static int aw200xx_set_imax(const struct aw200xx *const chip, > > >> + u32 led_imax_microamp) > > >> +{ > > >> + struct imax_global { > > >> + u32 regval; > > >> + u32 microamp; > > >> + } imaxs[] =3D { > > >> + { 8, 3300 }, > > >> + { 9, 6700 }, > > >> + { 0, 10000 }, > > >> + { 11, 13300 }, > > >> + { 1, 20000 }, > > >> + { 13, 26700 }, > > >> + { 2, 30000 }, > > >> + { 3, 40000 }, > > >> + { 15, 53300 }, > > >> + { 4, 60000 }, > > >> + { 5, 80000 }, > > >> + { 6, 120000 }, > > >> + { 7, 160000 }, > > > > > > This looks a bit random. Is there any pattern on how value is > > > connected to the register value? > > > > There is no ability to create any pattern here, because this table data > > doesn=E2=80=99t have any regularity. > > There is a clear pattern. > > You have two tables, i.e. with multiplier 10000 and second one with > multiplier 3333 (table in the datasheet seems bad from a math > perspective). And it's even shown correctly in the datasheet. > > With this mix you missed 10. > > The coefficient table is 1,2,3,4,6,8,12,16 for both tables. > > Hence you need one table and two multipliers. > > Please, rewrite accordingly. JFYI: You may see how I killed a table in one driver due to missing understanding that there is a pattern. 9df461eca18f ("spi: pxa2xx: replace ugly table by approximation") --=20 With Best Regards, Andy Shevchenko