From patchwork Sun Nov 6 15:46:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 2462 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 154B13F331 for ; Sun, 6 Nov 2022 16:46:18 +0100 (CET) Received: by mail-ej1-f72.google.com with SMTP id dn14-20020a17090794ce00b007ae5d040ca8sf384790ejc.17 for ; Sun, 06 Nov 2022 07:46:18 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1667749577; cv=pass; d=google.com; s=arc-20160816; b=zTJZZ6grb9AnrhnZCOD0QbRCtfHS0PpO7eLWE1+HrdjHHcxH1uHn8mitAnH7p2il3c B/ua10IcJ3q5Mhdl6n06gdUWBDr4vcN8ajuPg/C+iaIpEvonzihtcUdAVI0lNGm7Nl3K v/qKGXKnKarBBI6VtyHXfBRjenhZEvjGIYI9ccF3Zg8OoMODoxJdGl8S4ThDMY5rfk3E 3gC9pPtfMJwS4W/pzTM4q63qipPxRhcwyt5M2HMMiBzelKCYK5+G05386ZSC4Qbd5ezw NmLVNYH/3U40UiOV1A7gGqILGCylY4db37iw78vhBprPdmVsCZy51fN920eDBKZZ3J+m 6KlA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:mime-version:message-id:date:subject:cc:to :from:dkim-signature; bh=QGGGwfvz6exizhplVUZhhq0D7ekVQeYIKTs2YOhTqfY=; b=bA+ANJDXkE0qwtEHNJS1utZ+Rc0JDLQ0mVLeWcRX3PW10AtxtsR0eG/kUAJw+T8lno GIiE5YOrgM1MX+UjloluF0WveKIQ8ncFuGXBc+x1+wKApsHQ3EC9dxOt94gOm/8X6jkb K5Xl9bdwhT4KaQsqm1JkwU7jEGQEObnZ1DTUzSU+WVpNY5TNq2mGhC5EPwAEy/2Q5RLU gvdsPX01Cm0asnScKSbh1f9UHdtybf2iHwURU4x7Fn6CbBF6ijKLYa6OHI2vlDU+njKy 0OcgglhKFnamLWFuuLJv9SiE/1eAync+iD1wrV0a+u1OVoRqKnMIr9wIkDqYfbERKuBD Pg5g== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=F2cbbEOv; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:x-original-authentication-results :x-original-sender:mime-version:message-id:date:subject:cc:to:from :from:to:cc:subject:date:message-id:reply-to; bh=QGGGwfvz6exizhplVUZhhq0D7ekVQeYIKTs2YOhTqfY=; b=ODMejkR7JGcn1MIlIWY6G5gJ2YqVmpI3rKTwW12m7eZc8mpgQBivVFGN+SoD40PLMv 0C7BxzWs2AAWdjEbbfT4JGGNJ4bzyzibK7fQYE9Sp47N0uwLFo0CWSjf7abw5p6v1wLv Kt9MJ4MUMgy/VjNv1MCFVLP74/eTVpX4QCbOo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=list-unsubscribe:list-archive:list-help:list-post :x-spam-checked-in-group:list-id:mailing-list:precedence :x-original-authentication-results:x-original-sender:mime-version :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=QGGGwfvz6exizhplVUZhhq0D7ekVQeYIKTs2YOhTqfY=; b=0wQUEWYRe1ms9aBqOVu93TEEGAYftvE1b50MQlUfssizjO+J1iKDuSApy3tm6yp0z7 ilVQCdUguXC+EE4TXor9gPAywTAlQgyamXCAB+I32eEwNUxzWvobHQbTlXQaHOfYl2w8 QYrzEQDjxqsmTTYZ3dly6LpGoU4cMeoNqUuh1wFMsm8k9M7o7GvtpiOW7iYmmm+Le/tl GX3mU5uqGQMvmiCJSUffaFAgmq/gS5RR+crXluLUCZbEgiPYxmwnMPhAyfGh6G8kTbkj IEWTNTVySWNM274I1moqsuwTEPPuHWKFQnE9u/3PGbbyBNtsQPjrHct19bt4hqPrjMxz UccA== X-Gm-Message-State: ACrzQf3ocfFFHujOqFZQR1IbeqvYNj/LqAKkj+JJwywqex+q1EjnmWFq Bkpg2ludyIfc7cMbdmnKM39guBeC X-Google-Smtp-Source: AMsMyM4ThJnN2gOTfO//oNA5ZkB9JA5h80C4eYIEXIQbUOYWu/LcXU1+agrCc3papWVf61W3sbIDWg== X-Received: by 2002:a17:907:a05c:b0:7ad:f563:815d with SMTP id gz28-20020a170907a05c00b007adf563815dmr26148981ejc.371.1667749577669; Sun, 06 Nov 2022 07:46:17 -0800 (PST) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a05:6402:524c:b0:43d:b3c4:cd21 with SMTP id t12-20020a056402524c00b0043db3c4cd21ls3489040edd.2.-pod-prod-gmail; Sun, 06 Nov 2022 07:46:16 -0800 (PST) X-Received: by 2002:a05:6402:3718:b0:453:a46c:386c with SMTP id ek24-20020a056402371800b00453a46c386cmr46004233edb.97.1667749576458; Sun, 06 Nov 2022 07:46:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667749576; cv=none; d=google.com; s=arc-20160816; b=r6eB86V/MQNQWf0DA16kUer4XJYhQAJwEOJ+JvVM3NbTnSW5FzWckhoS/xbUayGkey TsoU6f9GZD6/25y2iffEBUrsezkfPHh3I+EXoO9fOvjyLxOzQwxk0cOm3JDTasFhklMR FDMvAtfOFqRjYN7GdI2U1aBdiBr9oIJ5dh4fq2Ll5sHiLsVouztf+OTRMXkvEMVdJyDY vPb+ASODo6pKjQqU5gdizpp7YO0lbFtvqP/o2gmOatlbpLpLZiLr/dEeEKzJdFavKZ0o E8STfE+ZTU1+o05Yky6L48NFUYTrY35xNS2vrYWJG7wEQp2HZMG5smGWXp4CPX+yrTrU jmBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:dkim-signature; bh=IESrdIGOIZAm+SZQoTxRhJ5XsZQ5NE5GBRmcNiJagyU=; b=SUSdI6xaX8I1UadSjFOtby4jjX9dNUhDkDkEFLQQU4Ocjr6kLNWqhhGB8R/BYJqlZ4 vFEYFhLOD0CC4rxb0uGaW38W4DirlkCA2PxhitChDNJqmVYg8pNRSfVBM6jZxYAEJPPc fFjs3dW+Gc9BZ+OZYsOyd4dDJtk3xtjMBVMAw8CBq+sfHqWL82RPfQdbrg4wh8skc6wB mwcdDhE/JHajYe8wdIzs88UeO9ccW31vJSHunFWPP3RK1DZAyHfVbl1bXnBT/VXUaRe/ /WpVPKiCk6LK8dj75pVQKk00MPUDwVPfPvjOR4praq9N+jo3W5bkv3sTLvF0ToCOi1vd ICWQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=F2cbbEOv; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id d23-20020a170906c21700b0078aa3871be1sor1347052ejz.126.2022.11.06.07.46.16 for (Google Transport Security); Sun, 06 Nov 2022 07:46:16 -0800 (PST) Received-SPF: pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; X-Received: by 2002:a17:906:99c1:b0:6fe:b01d:134 with SMTP id s1-20020a17090699c100b006feb01d0134mr8027170ejn.598.1667749576127; Sun, 06 Nov 2022 07:46:16 -0800 (PST) Received: from dario-ThinkPad-T14s-Gen-2i.homenet.telecomitalia.it (host-95-232-76-31.retail.telecomitalia.it. [95.232.76.31]) by smtp.gmail.com with ESMTPSA id kz20-20020a17090777d400b00772061034dbsm2204139ejc.182.2022.11.06.07.46.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 06 Nov 2022 07:46:15 -0800 (PST) From: Dario Binacchi To: linux-kernel@vger.kernel.org Cc: michael@amarulasolutions.com, Amarula patchwork , Dario Binacchi , Allison Randal , Greg Kroah-Hartman , Liang He , Michael Turquette , Stephen Boyd , Tero Kristo , Thomas Gleixner , Tony Lindgren , linux-clk@vger.kernel.org, linux-omap@vger.kernel.org Subject: [PATCH v3 1/2] clk: ti: add of_ti_clk_register() helper Date: Sun, 6 Nov 2022 16:46:11 +0100 Message-Id: <20221106154612.3474940-1-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.32.0 MIME-Version: 1.0 X-Original-Sender: dario.binacchi@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=F2cbbEOv; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Content-Type: text/plain; charset="UTF-8" Precedence: list Mailing-list: list linux-amarula@amarulasolutions.com; contact linux-amarula+owners@amarulasolutions.com List-ID: X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com X-Google-Group-Id: 476853432473 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , The ti_clk_register() function is always called with the parameter of type struct device set to NULL, since the functions from which it is called always have a parameter of type struct device_node. Adding this helper will allow you to register a TI clock to the common clock framework by taking advantage of the facilities provided by the struct device_node type. Signed-off-by: Dario Binacchi --- (no changes since v1) drivers/clk/ti/clk.c | 30 ++++++++++++++++++++++++++++++ drivers/clk/ti/clock.h | 2 ++ 2 files changed, 32 insertions(+) diff --git a/drivers/clk/ti/clk.c b/drivers/clk/ti/clk.c index 1dc2f15fb75b..e29b5c7c0dc8 100644 --- a/drivers/clk/ti/clk.c +++ b/drivers/clk/ti/clk.c @@ -560,6 +560,36 @@ int ti_clk_add_alias(struct device *dev, struct clk *clk, const char *con) return 0; } +/** + * of_ti_clk_register - register a TI clock to the common clock framework + * @node: device node for the clock + * @hw: hardware clock handle + * @con: connection ID for this clock + * + * Registers a TI clock to the common clock framework, and adds a clock + * alias for it. Returns a handle to the registered clock if successful, + * ERR_PTR value in failure. + */ +struct clk *of_ti_clk_register(struct device_node *node, struct clk_hw *hw, + const char *con) +{ + struct clk *clk; + int ret; + + ret = of_clk_hw_register(node, hw); + if (ret) + return ERR_PTR(ret); + + clk = hw->clk; + ret = ti_clk_add_alias(NULL, clk, con); + if (ret) { + clk_unregister(clk); + return ERR_PTR(ret); + } + + return clk; +} + /** * ti_clk_register - register a TI clock to the common clock framework * @dev: device for this clock diff --git a/drivers/clk/ti/clock.h b/drivers/clk/ti/clock.h index 37ab53339a9b..a75fcf775de0 100644 --- a/drivers/clk/ti/clock.h +++ b/drivers/clk/ti/clock.h @@ -199,6 +199,8 @@ extern const struct omap_clkctrl_data dm816_clkctrl_data[]; typedef void (*ti_of_clk_init_cb_t)(void *, struct device_node *); +struct clk *of_ti_clk_register(struct device_node *node, struct clk_hw *hw, + const char *con); struct clk *ti_clk_register(struct device *dev, struct clk_hw *hw, const char *con); struct clk *ti_clk_register_omap_hw(struct device *dev, struct clk_hw *hw, From patchwork Sun Nov 6 15:46:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 2463 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 324913F9F8 for ; Sun, 6 Nov 2022 16:46:19 +0100 (CET) Received: by mail-ed1-f69.google.com with SMTP id e15-20020a056402190f00b00461b0576620sf6629496edz.2 for ; Sun, 06 Nov 2022 07:46:19 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1667749579; cv=pass; d=google.com; s=arc-20160816; b=sGPrzl7TdI8ghBfq7RFAmM3UGm4J1S313k+MKIF02FtehoJ5pr604+YLJW6sy/VTpl USvnOq3oPoknZfUshd01pNtqk7OEZPjl6vdGzbSh4wIwyWYr6/qY6bZw8WkSEt5rmr3U KXCP4o5E5Gtn7l26STpp35e5ACMTs+i5nF/M9fLT6iCKbyWkLxg6oNJvVToigO2+4LzI XEISDZWXdOUh2sCCSzD9A4MperjdZMuklxCK6nghEtM4EjMfKGSfRlsjJhxm0XxgMHUL 521sfaE2DllPVUuNimIZUGaL+leG5tod106w1iyaL2hh3X/fx9CEi4TPfmdPvVL4P9NB 8pxA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=E3ZCo+8yqZXjqXX8/Kqlnuzjx+LtA2vw0BMoV1WcXi0=; b=Uw6nsnyinImcoATSMfP5UWiHp0d2PFEzsjskmjuWq6bKLwoHwMjU4gnd9nLd1S68ch nWttWO8ztFv7WNH7x8Fld+pt3FzWRaZaqKp9MLtxOJXUuqBERxUtL/pTx7dGm4xgkJbH S195Ce5mTw1sH5VYi0Np2djK8cmkDg9Qf7SmA/sAonHOChCCWcTfBARvAOMqLAoP9uHp TER49m72VIA9ZltHrzZxfLMtIOT3GJzLHGJoTDV5XW/iS2532UyEw656tRF1Iz4GRuos EvYQoIqXRX2/94oTm2DFYQEux418l9KtVaP+7s5gOKR6UhG/x4+B1MbkBPW1MRU1nVBX xldg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=ho8Jqqap; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:x-original-authentication-results :x-original-sender:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=E3ZCo+8yqZXjqXX8/Kqlnuzjx+LtA2vw0BMoV1WcXi0=; b=d77xRyu5QmQWAwWgl53afuYErCnG4SBFeQ8hqWuMSNRJ+Dji8ssUh/PT5ai4KbCOfT IqU9P5961flc755VbOCt6oJyHqWAqauTlxbl2GXM0p0rMNpOgqzOEbnljfNSRGFQHE9C Cq895hKf6GY8m6iohfMuej9tPLI7XNrt99Jb4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=list-unsubscribe:list-archive:list-help:list-post :x-spam-checked-in-group:list-id:mailing-list:precedence :x-original-authentication-results:x-original-sender:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=E3ZCo+8yqZXjqXX8/Kqlnuzjx+LtA2vw0BMoV1WcXi0=; b=xVzmwd4gYCvtR3FeD3fN3EZmxvkjmh5yLcEbNmSzAvY5IzQxPM0d+465hWgZWhkMu2 8RSXM7TXMg62G5m6t9cAcE/TlocgZnOmvbJK4C+MDbami/lZSJmhq6XB4/HfS/XoIIWT jp2PCleLdSzxn4680wdcK0W3uM38Jou46fT5MqyxamnbQhHHYoNm31QHF4g6ACoxIn94 IYljnflSNvlD4aOHP6RbuPzXgRHHw4kPz42xuB9FwnRFK3CYtlKygdE1iuG4Zdz/eW7G 0nU4xIaccmFawzeAaPROTq3Ugs3N0JvKRLaN99VQssOEyYxpImiRwGzZofZu+TKhDSVX lCsg== X-Gm-Message-State: ACrzQf2znGKX0mUuDmTDQN1we5Pucg/MsHr6hP3JmYM+InkCT7FoywNQ HXRhN9gCowkYcm0/gc7OxsOCn1o5 X-Google-Smtp-Source: AMsMyM7fObcKfylVAyURD8V584Z0tuJB7ob9tZztcJNwZwXWB4Gswpa2CfHlm8SwxUc5Hj3JuxeTpQ== X-Received: by 2002:a17:907:aa1:b0:7ad:cd92:a48f with SMTP id bz1-20020a1709070aa100b007adcd92a48fmr36204240ejc.369.1667749578779; Sun, 06 Nov 2022 07:46:18 -0800 (PST) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a17:906:1856:b0:797:e443:f845 with SMTP id w22-20020a170906185600b00797e443f845ls5447082eje.5.-pod-prod-gmail; Sun, 06 Nov 2022 07:46:17 -0800 (PST) X-Received: by 2002:a17:907:10db:b0:7ae:566e:3a1f with SMTP id rv27-20020a17090710db00b007ae566e3a1fmr5730612ejb.751.1667749577610; Sun, 06 Nov 2022 07:46:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667749577; cv=none; d=google.com; s=arc-20160816; b=dlNgsw8XurQ+TF3HQcXNyWtGXnY5DN04YE236zAEx7zG0q3KA2YFoHCR1StCy/STlW fAZ3Uj3ZAy2HOuLdp4pBTX5ZqVuhSWJMcr8f92yF3bSb4AJHSWsDM+77DhookJ2bCtsO as2ijF1z+iKpyLInM6KFRBHoRBiYa4BMTrM0/NiC1KAncKFrKgkDQJT7/TQYBuAreQIh xMy4IY05+iDf0qAdSSVKp0c+db5ZzqM4SRoklKMtirqkcfo+BykzIGd5ZLRDnynjrbEw 5vD72IYOJxLGgNz4GzoWeV4iDbhdQeAkf8tKZE0hBIvpMDqLTHqFK//gHtAQlItZ0EyV I/vw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=Ke2ic1RycAYFmZzx9qb25pQPIAwiVR4I1nr3ghBSQyY=; b=YIAFvdRaJkzM2QL5K8uiypg2dkRP1dKi6c3xPbzc4goct/9J77gUeHM0931HNYACFn BWew+V+e/6dAR63QY4E4ftX8j2NZT7bLEyNxKwa2tAjhPeOeiuDSFJCQNdybjCTr3oAi 5w9+PkPsq5rp7s2wjL1SHlraX9jCMyBWjL+WxXTXNuBQbX+vSvq43tGW+Y6TeCCWtQfh rnyHsvZpSjVheIu5rw55obromjUwyRcdlDxKCj5YS67wqnIZiHsWRjPk+uHWpGr1+xYz 3YhnUNtNYcV/U7b0bsis70mv0Oew37XAx2kh0S43qZDpnd5YdVW1182d5xkc8aYMCUVo wNKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=ho8Jqqap; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id s20-20020a50ab14000000b00461f5cdb5acsor1726265edc.53.2022.11.06.07.46.17 for (Google Transport Security); Sun, 06 Nov 2022 07:46:17 -0800 (PST) Received-SPF: pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; X-Received: by 2002:a05:6402:1382:b0:464:1e50:1a41 with SMTP id b2-20020a056402138200b004641e501a41mr20978094edv.245.1667749577399; Sun, 06 Nov 2022 07:46:17 -0800 (PST) Received: from dario-ThinkPad-T14s-Gen-2i.homenet.telecomitalia.it (host-95-232-76-31.retail.telecomitalia.it. [95.232.76.31]) by smtp.gmail.com with ESMTPSA id kz20-20020a17090777d400b00772061034dbsm2204139ejc.182.2022.11.06.07.46.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 06 Nov 2022 07:46:17 -0800 (PST) From: Dario Binacchi To: linux-kernel@vger.kernel.org Cc: michael@amarulasolutions.com, Amarula patchwork , Dario Binacchi , kernel test robot , Allison Randal , Greg Kroah-Hartman , Miaoqian Lin , Michael Turquette , Stephen Boyd , Tero Kristo , Thomas Gleixner , Tony Lindgren , linux-clk@vger.kernel.org, linux-omap@vger.kernel.org Subject: [PATCH v3 2/2] clk: ti: dra7-atl: don't allocate `parent_names' variable Date: Sun, 6 Nov 2022 16:46:12 +0100 Message-Id: <20221106154612.3474940-2-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20221106154612.3474940-1-dario.binacchi@amarulasolutions.com> References: <20221106154612.3474940-1-dario.binacchi@amarulasolutions.com> MIME-Version: 1.0 X-Original-Sender: dario.binacchi@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=ho8Jqqap; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Content-Type: text/plain; charset="UTF-8" Precedence: list Mailing-list: list linux-amarula@amarulasolutions.com; contact linux-amarula+owners@amarulasolutions.com List-ID: X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com X-Google-Group-Id: 476853432473 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , The `parent_names' variable was freed also in case of kzalloc() error. Instead of modifying the code to perform a proper memory release, I decided to fix the bug by not allocating memory. Since only one parent name is referenced, it is not necessary to allocate this variable at runtime and therefore you can avoid calling the kzalloc() function. This simplifies the code (even calls to kfree can be removed) and improves the performance of the routine. Signed-off-by: Dario Binacchi Reported-by: kernel test robot --- Changes in v3: - Add the "clk: ti: add of_ti_clk_register() helper" patch to the series. - Use a variable of type struct clk_parent_data to furthermore simplify the code. - Update the commit message. Changes in v2: - Fix compiling error - Add kernel test robot's Reported-by tag. drivers/clk/ti/clk-dra7-atl.c | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/drivers/clk/ti/clk-dra7-atl.c b/drivers/clk/ti/clk-dra7-atl.c index ff4d6a951681..373561626ec4 100644 --- a/drivers/clk/ti/clk-dra7-atl.c +++ b/drivers/clk/ti/clk-dra7-atl.c @@ -163,8 +163,8 @@ static const struct clk_ops atl_clk_ops = { static void __init of_dra7_atl_clock_setup(struct device_node *node) { struct dra7_atl_desc *clk_hw = NULL; + struct clk_parent_data pdata = { .index = 0 }; struct clk_init_data init = { NULL }; - const char **parent_names = NULL; const char *name; struct clk *clk; @@ -188,24 +188,15 @@ static void __init of_dra7_atl_clock_setup(struct device_node *node) goto cleanup; } - parent_names = kzalloc(sizeof(char *), GFP_KERNEL); - - if (!parent_names) - goto cleanup; - - parent_names[0] = of_clk_get_parent_name(node, 0); - - init.parent_names = parent_names; - - clk = ti_clk_register(NULL, &clk_hw->hw, name); + init.parent_data = &pdata; + clk = of_ti_clk_register(node, &clk_hw->hw, name); if (!IS_ERR(clk)) { of_clk_add_provider(node, of_clk_src_simple_get, clk); - kfree(parent_names); return; } + cleanup: - kfree(parent_names); kfree(clk_hw); } CLK_OF_DECLARE(dra7_atl_clock, "ti,dra7-atl-clock", of_dra7_atl_clock_setup);