Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp3975386rdb; Thu, 14 Sep 2023 08:14:11 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEy31L0y79DTBb0FKlzPYWaTED5L58otx1jckNFAJATojmGyZcSt73aY/G4JjaXV0KYY7l5 X-Received: by 2002:a17:902:e552:b0:1b8:2ba0:c9a8 with SMTP id n18-20020a170902e55200b001b82ba0c9a8mr6492337plf.2.1694704450799; Thu, 14 Sep 2023 08:14:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694704450; cv=none; d=google.com; s=arc-20160816; b=JDlIJH0jBTAr765cdM7qcY14EymBPSAKWUAVROeC+aVeOBTug/k3jyUNlqFY1J+ZhF bd1A8gkExBHL4JdPzSAolWQy1PuIsmA8g+ZHaLEpQFaHnoVN8IAKoMwCh67ktK5pN2zb qgMtOkO6vu4L8ns2p3+jLNz2Hk8r44QaIkFl5gLRn8rCftiO53p5uTTCNK6AfJLYoLPi k3Gh6D++QszJaS1Xrz9BVjaOhmiuLvbfSQ32tm68NRJ1AEKvgS7Bz1b2E6sifK95xmf4 mhcg9s8KLbgxsNuf7qNiN+Nspc8XV6UmwI4O5qGNqnOQGMQadinpSamGibnfuGlKImRr 6CCw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version; bh=K6qs+97gtBt4xLj07Pv1kbP7De0U8L4e9JSzQq9tIVA=; fh=rPji0t0oZskInhFMmMZTm7NaIbiwXPc2pGml45/EfuI=; b=jfBa/2Y4dMHKb1qra5UC8Tg9sS9JxYDkrg4zQfbIyC5nS/WBTZPuTrR6wbAKgN/HnX AEW7TermnTsxqWY0ZuClOXjCjSwImRBYwJnDncdAD3fAyKGdLD2Ozc0ve+rIwIIHqqxd IiuzXdiqTfq0COJhYg3OpEPtqVlN5qLzXCa1h6LvcnK+bxbGvUc3peNueoR/C3e+V4LB Hmbg6vtF4vn5aBBf/RQLX/iYZht29xjvawKCs46ci4E88qkNyWCFHY60lB3IzloLR+Tp w7Cj7VzDqY5EQMC0G7Gy9sMGoNJvyYWWP9Zr2KxQPY6TuBWQRgywn041IpBeq1vf/nlz 4t3A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id s8-20020a170902ea0800b001b9d335180dsi2014942plg.618.2023.09.14.08.14.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 08:14:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id AC53280EBCBF; Thu, 14 Sep 2023 05:19:06 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238396AbjINMTH convert rfc822-to-8bit (ORCPT + 99 others); Thu, 14 Sep 2023 08:19:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34786 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234522AbjINMTG (ORCPT ); Thu, 14 Sep 2023 08:19:06 -0400 Received: from mail-yw1-f181.google.com (mail-yw1-f181.google.com [209.85.128.181]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 502EE1FC9; Thu, 14 Sep 2023 05:19:02 -0700 (PDT) Received: by mail-yw1-f181.google.com with SMTP id 00721157ae682-59b4ec8d9c1so10295017b3.0; Thu, 14 Sep 2023 05:19:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694693941; x=1695298741; 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=MY7JVFz1bNlrjVrnjoxD6/0CcvRhM6TdVrF+6BcMksE=; b=q5y1sKPpwLX0KM2RNEmFA4MB8YIF3vDdXnCO5DAmkLVtpNhsZVmiD90bsy19l1GnqN xpNOJn9PoMNi2dfOKrMMhZOw+yIjR5KeYdpvn8VjwabRVE8+FQIGvbgRaOlmlb6iHyRp h4xMp3F/cmphQLK9LT1HuQ1l1YTRS+huAZQYJkGLbW5uKcwEHaYFrYclqPELe7AFFUKG he+1tvylE0uXa8i74Bmq9elCpaSZ6aIojRTtjGuq64dlBkED4Dt3O/KKkOEAamOSNGDO unGZ+IWgovNveXFT1kRf6VC9WG5w5c8BDgl/RmbrIHBNR9uaLdbCoKoOZZOHTUn89SJE G5dg== X-Gm-Message-State: AOJu0YxQP2t5u+4oHSheHOpS9v5WvH38TGoT01QtIpZ1s73EF+qOFL7U KW4bxOF3uB3yHYfWKk88rg1jH7ay+Y+miA== X-Received: by 2002:a81:6c53:0:b0:592:1bab:52bd with SMTP id h80-20020a816c53000000b005921bab52bdmr5423379ywc.39.1694693941331; Thu, 14 Sep 2023 05:19:01 -0700 (PDT) Received: from mail-yb1-f178.google.com (mail-yb1-f178.google.com. [209.85.219.178]) by smtp.gmail.com with ESMTPSA id i130-20020a0ddf88000000b0056d51c39c1fsm291307ywe.23.2023.09.14.05.18.58 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 14 Sep 2023 05:18:59 -0700 (PDT) Received: by mail-yb1-f178.google.com with SMTP id 3f1490d57ef6-d801c83325fso936861276.0; Thu, 14 Sep 2023 05:18:58 -0700 (PDT) X-Received: by 2002:a25:7497:0:b0:d78:3a4e:c19e with SMTP id p145-20020a257497000000b00d783a4ec19emr5260394ybc.24.1694693938512; Thu, 14 Sep 2023 05:18:58 -0700 (PDT) MIME-Version: 1.0 References: <20230912045157.177966-1-claudiu.beznea.uj@bp.renesas.com> <20230912045157.177966-9-claudiu.beznea.uj@bp.renesas.com> <8490f909-c0ad-5a6d-7a97-03c80a8b47ba@omp.ru> In-Reply-To: <8490f909-c0ad-5a6d-7a97-03c80a8b47ba@omp.ru> From: Geert Uytterhoeven Date: Thu, 14 Sep 2023 14:18:44 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 08/37] clk: renesas: rzg2l: trust value returned by hardware To: Sergey Shtylyov Cc: Claudiu , mturquette@baylibre.com, sboyd@kernel.org, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org, ulf.hansson@linaro.org, linus.walleij@linaro.org, gregkh@linuxfoundation.org, jirislaby@kernel.org, magnus.damm@gmail.com, catalin.marinas@arm.com, will@kernel.org, prabhakar.mahadev-lad.rj@bp.renesas.com, biju.das.jz@bp.renesas.com, quic_bjorande@quicinc.com, arnd@arndb.de, konrad.dybcio@linaro.org, neil.armstrong@linaro.org, nfraprado@collabora.com, rafal@milecki.pl, wsa+renesas@sang-engineering.com, linux-renesas-soc@vger.kernel.org, linux-clk@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mmc@vger.kernel.org, linux-gpio@vger.kernel.org, linux-serial@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Claudiu Beznea Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Thu, 14 Sep 2023 05:19:06 -0700 (PDT) On Tue, Sep 12, 2023 at 6:43 PM Sergey Shtylyov wrote: > On 9/12/23 7:51 AM, Claudiu wrote: > > > From: Claudiu Beznea > > > > Initial value of CPG_PL2SDHI_DSEL bits 0..1 or 4..6 is 01b. Hardware user's > > manual (r01uh0914ej0130-rzg2l-rzg2lc.pdf) specifies that setting 0 is > > prohibited. The rzg2l_cpg_sd_clk_mux_get_parent() should just read > > CPG_PL2SDHI_DSEL, trust the value and return the proper clock parent index > > based on the read value. Do this. > > > > Fixes: eaff33646f4cb ("clk: renesas: rzg2l: Add SDHI clk mux support") > > Signed-off-by: Claudiu Beznea > > --- a/drivers/clk/renesas/rzg2l-cpg.c > > +++ b/drivers/clk/renesas/rzg2l-cpg.c > > @@ -239,14 +239,8 @@ static u8 rzg2l_cpg_sd_clk_mux_get_parent(struct clk_hw *hw) > > > > val >>= GET_SHIFT(hwdata->conf); > > val &= GENMASK(GET_WIDTH(hwdata->conf) - 1, 0); > > - if (val) { > > - val--; > > - } else { > > - /* Prohibited clk source, change it to 533 MHz(reset value) */ > > - rzg2l_cpg_sd_clk_mux_set_parent(hw, 0); > > - } > > > > - return val; > > + return val ? --val : val; > > return val ? val - 1 : 0; Definitely, mixing multiple users of the same variable and pre-decrement is ill-defined. Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds