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 phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BD96AC433EF for ; Wed, 29 Dec 2021 22:01:21 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 60F9D81EB2; Wed, 29 Dec 2021 23:01:19 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="Z0G4dTzR"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id EC32782F73; Wed, 29 Dec 2021 23:01:16 +0100 (CET) Received: from mail-ed1-x52e.google.com (mail-ed1-x52e.google.com [IPv6:2a00:1450:4864:20::52e]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 39482811D2 for ; Wed, 29 Dec 2021 23:01:14 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=alpernebiyasak@gmail.com Received: by mail-ed1-x52e.google.com with SMTP id j21so90884409edt.9 for ; Wed, 29 Dec 2021 14:01:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:date:mime-version:user-agent:subject:content-language:to :cc:references:from:in-reply-to:content-transfer-encoding; bh=tg3Z5+So8IJ5+u4Sy0h9AGFEF5o1Bzbyo5jFM03f2j0=; b=Z0G4dTzRFqGTbgLIom7pkc71/mcCwfNPGCv+XX8socE+Aor3JuQUyBLVK6ZTv2MSPp 1hS6yazAAHvSKt059jLKZXPgo+hIW75fijovwWgcs9+5cZXrzDWUIXQqxnEubp/9ku0e vrn28RK7hYfm9H902VHrz0egYfP/m8+3/R/smDg8JpaIZanxxGKnCFm87dP5qTQKwZmE QEY3aPxozHavsb2RgEfqMSH4XKISu85CcOCQud0bzm4AehEMBRkouJ7gEk8sGfLGmOzU 0QzQzzuVBa+pkD/VQbk/KsyYuSgIU1w1+a9B7a4EZrVc/Ty9uxEpStgcLgyh+1UZBDIz L6iQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=tg3Z5+So8IJ5+u4Sy0h9AGFEF5o1Bzbyo5jFM03f2j0=; b=AM7Q/JqJ/sAjqifG57/687Bumtc0qYtEyn+62m5AM8XpAZIO2nKiP1dyNlQIrbusfu XOltcQ3LAvtFO24JIy7nCw4VAinyLOQC3MKQICXlLW0xqL7Tc4wmJZnmiyhTGXCYr7sm CZtutA+wOIAblSnljcMYWjGTIWGh/Bj+vQ/FtTtrbxBc/GXS7ktE9RKNZSQaE+3oWghj cEtAae12DNgszH+qCHBCRJC+k4TX2wCPkU0//fVkl+xAkgCm7uJtY9g4n4hhSIhjjw69 JD3aiKsmmEE8YrOJ7zhN31rbEiKsRlNJ4IMzqV1LD6eckg5hu/LY0urs7zz1RQ+79oHa iAeA== X-Gm-Message-State: AOAM531tfbgLhWBt1W/gklJFfZ3gE4fRmdrX9I5pmjxXaNV4Q4OeCG1B AWXW/gjBAvuz8mkgaqe2UkY= X-Google-Smtp-Source: ABdhPJzZwmnR9N0hlISoiv6rlgzHcq/htzXzeDeK2sew35SNU7hWstKA/l/HvX4tntNWRAEqwlwa9A== X-Received: by 2002:aa7:d411:: with SMTP id z17mr27138129edq.214.1640815273376; Wed, 29 Dec 2021 14:01:13 -0800 (PST) Received: from [192.168.0.74] ([178.233.26.119]) by smtp.gmail.com with ESMTPSA id t20sm8815990edv.81.2021.12.29.14.01.10 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 29 Dec 2021 14:01:12 -0800 (PST) Message-ID: <257f6869-9df0-b962-d71d-9b3ff3f26717@gmail.com> Date: Thu, 30 Dec 2021 01:01:06 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux aarch64; rv:91.0) Gecko/20100101 Thunderbird/91.4.1 Subject: Re: [PATCH v2] phy: Track power-on and init counts in uclass Content-Language: en-US To: Simon Glass Cc: U-Boot Mailing List , Tom Rini , Neil Armstrong , Frank Wang , Grant Likely , Patrick Delaunay , Icenowy Zheng , Jagan Teki , Andre Przywara , Grant Likely , Peter Robinson , Joe Hershberger References: <20211224130549.20276-1-alpernebiyasak@gmail.com> From: Alper Nebi Yasak In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.38 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean On 28/12/2021 11:34, Simon Glass wrote: > Should add comments for the struct I can do that and send as a v3. > Also I wonder if a simple fixed-length array might be possible instead > of the linked list? I think it's possible, my first prototype was something like: #define MAX_PHYS 16 struct phy_uc_priv { int power_on_count[MAX_PHYS]; int init_count[MAX_PHYS]; }; uc_priv = dev_get_uclass_priv(phy->dev); uc_priv->power_on_count[phy->id]; uc_priv->init_count[phy->id]; UCLASS_DRIVER(phy) = { ... .per_device_auto = sizeof(struct phy_uc_priv), } But I rewrote as a linked list because I couldn't decide on a reasonable value for that MAX_PHYS. Best guess I have is from drivers/phy/cadence/phy-cadence-sierra.c which defines SIERRA_MAX_LANES as 16. As array-of-structs, I guess things would be roughly: #define MAX_PHYS 16 struct phy_counts { int power_on_count; int init_count; }; counts = dev_get_uclass_priv(phy->dev)[phy->id]; counts->power_on_count; counts->init_count; UCLASS_DRIVER(phy) = { ... .per_device_auto = sizeof(struct phy_counts[MAX_PHYS]), } Should I change to that?