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 8B282C433F5 for ; Mon, 20 Dec 2021 15:57:27 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 44C2E8303F; Mon, 20 Dec 2021 16:57:24 +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="PlmzDfwi"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id D36AA83104; Mon, 20 Dec 2021 16:57:22 +0100 (CET) Received: from mail-ed1-x532.google.com (mail-ed1-x532.google.com [IPv6:2a00:1450:4864:20::532]) (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 D944582A68 for ; Mon, 20 Dec 2021 16:57: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=alpernebiyasak@gmail.com Received: by mail-ed1-x532.google.com with SMTP id w16so11766615edc.11 for ; Mon, 20 Dec 2021 07:57:19 -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=LHIkCJ85o7isNSPFUeBJP8/nACRNQz4BrKbd9o182Rs=; b=PlmzDfwi76Xkl6k3E3z1kkl0DhzFeAZGXWN9cjaLiBuP+VIVLlWBubO6jaodnxoUsl JK5/Z+PHhZtXMMgeI6jsPxKCI7ICsakm7aE1PTlPsmeRjtFD0oWWynhORExK1uFnAtH0 pprGLYS9nZROwO51mF8fXWSbn5NTRKguWIrrAUnDg36FweyrqSHnzb8k5fow1g1qIabV HO2MGUj5PHkWhn7vx60gA3yxHJ61xQR3nQWi/r3DJ67JhkP70zK/X9Adaonvahv2HBOb +KUUMjomUKrVhOwfABtSvw8ibQugSiEqa5PZWD90kfb/4lMJnKo+pebReBAezn/xLaQL QMzQ== 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=LHIkCJ85o7isNSPFUeBJP8/nACRNQz4BrKbd9o182Rs=; b=K+F7LU0ZUZQABcBBT3rAE8+x4Zxo5Ng9QAKd5WPlzEk3vml6MArzo11wrlcb8j/XFL 7MRYiSLEHy78kaEiWtQKZGKS8cccz+3v81Pv/OBeirpsFX2Nl8f9mY7i8g3kQelFfF1H mPXd4g2p7MvSdzsKimJpmbB54ERcHwBP8Smn9qUQsYYEJQFV6rpcSkOwjsXUZ0nzDeo/ OVzimwJzupxMa5G3WOamLaN1PoKcUfOsACxJv39U/ofenrcPnBZw/Nf6zjeBWVvA8+DF tXGBZNRDYGt3JJW+lIAAdB+BKljahzSbSPjgK4LJRMsQ1mePf8irtRiuiv7oDc5OV6t/ wPLA== X-Gm-Message-State: AOAM530QxbnL9fvbwN6fvOnSdgsiHkLsfQNsTJrZnZ0y0doKT+gbB+9w HuV2cQLCJlzraV8CGYRXP+4= X-Google-Smtp-Source: ABdhPJxkyYL0zqIDNtu7nPX5xEFO4rXblmaJN0v4dioaPMwLIXVm/4PDpaC8nMKTrmg0q+SaD6uQwQ== X-Received: by 2002:a50:d61a:: with SMTP id x26mr7721659edi.24.1640015839484; Mon, 20 Dec 2021 07:57:19 -0800 (PST) Received: from [192.168.0.74] ([178.233.26.119]) by smtp.gmail.com with ESMTPSA id f8sm1020386edd.73.2021.12.20.07.57.04 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 20 Dec 2021 07:57:19 -0800 (PST) Message-ID: <8bbb5a07-48e7-b783-d623-7d483995a234@gmail.com> Date: Mon, 20 Dec 2021 18:56:50 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux aarch64; rv:91.0) Gecko/20100101 Thunderbird/91.4.0 Subject: Re: [PATCH] phy: Track power-on and init counts in uclass Content-Language: en-US To: Simon Glass Cc: u-boot@lists.denx.de, Joe Hershberger , Jagan Teki , Tom Rini , Andre Przywara , Patrick Delaunay , Grant Likely , Grant Likely , Icenowy Zheng , Peter Robinson , Frank Wang , Neil Armstrong References: <20211210200124.19226-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 15/12/2021 06:26, Simon Glass wrote: > On Sat, 11 Dec 2021 at 02:02, Alper Nebi Yasak wrote: >> diff --git a/drivers/phy/phy-uclass.c b/drivers/phy/phy-uclass.c >> index 59683a080cd7..48b4b24db674 100644 >> --- a/drivers/phy/phy-uclass.c >> +++ b/drivers/phy/phy-uclass.c >> @@ -11,12 +11,65 @@ >> #include >> #include >> #include >> +#include >> + >> +struct phy_id_priv { >> + unsigned long id; >> + int power_on_count; >> + int init_count; >> + struct list_head list; >> +}; >> >> static inline struct phy_ops *phy_dev_ops(struct udevice *dev) >> { >> return (struct phy_ops *)dev->driver->ops; >> } >> >> +static struct phy_id_priv *phy_get_uclass_priv(struct phy *phy) > > This name is very confusing as it is similar to one used by DM, but > does something different. What I thought is: if we replaced these "struct phy" handles with child udevices, the counts would be their uclass_priv, and this function would be just dev_get_uclass_priv() on those child udevices. (Or maybe it would be parent_priv?). So I tried to pick names similar to those. > Do you think this function should be split into something that adds > the data and something that reads it? I can split and rename things into: - struct phy_counts - phy_alloc_counts(struct phy *phy) - phy_get_counts(struct phy *phy) >> +{ >> + struct list_head *uc_priv; >> + struct phy_id_priv *id_priv; >> + >> + if (!generic_phy_valid(phy)) >> + return NULL; >> + >> + uc_priv = dev_get_uclass_priv(phy->dev); >> + list_for_each_entry(id_priv, uc_priv, list) >> + if (id_priv->id == phy->id) >> + return id_priv; >> + >> + id_priv = kzalloc(sizeof(*id_priv), GFP_KERNEL); >> + if (!id_priv) >> + return NULL; >> + >> + id_priv->id = phy->id; >> + id_priv->power_on_count = 0; >> + id_priv->init_count = 0; >> + list_add(&id_priv->list, uc_priv); >> + >> + return id_priv; >> +}