Received: by 2002:a25:86ce:0:0:0:0:0 with SMTP id y14csp1994889ybm; Thu, 23 May 2019 09:41:17 -0700 (PDT) X-Google-Smtp-Source: APXvYqzEpT81ZIwKR1af3Qgzi14lA+9O7X6QLIWxtizXCsqry5liJPIa4LHxxaDdUy556/qlVlZl X-Received: by 2002:a65:454c:: with SMTP id x12mr12549455pgr.354.1558629677334; Thu, 23 May 2019 09:41:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558629677; cv=none; d=google.com; s=arc-20160816; b=T3TNu2XHynNWYrOfaoz5tOTVZ5et9nOsrgzXkcptHLdUDrs2uRlSTv+pAvZnhKaimp DVKUSaCyMgAXQaKlIqXXUqyE7vOf+vKZLB35ybuYpA3K808EiV2WPUC5uVZCqs29zyTK 1u4vOQmZOMimpGZJPn9zOuFA9Uj7s8Ucml18nPd9wJUNLsObBDgIigDcO2jkuFuB25vf lKuEWR04A8jSWbIONi6oBFITjd14ys4ZwaCulVvmAnzc3cBc/RKLAC8zq/W9ZLzcmiPy aS1ypi4bW0F3rTZkPwx02NELLsrXMTkQw+1zqgm9dIppdkY1tqOskH0pL0+zNrH/TqaP kaDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=r0rDpYcpEU2DlpfJPWclkw5oXzfo0RvY7oAeAA+3T90=; b=dYsGSWZ+NRQMJtqyhyy4qsaRl6SMvf+Iw6nQ4pdHAGvgAKH74SXP8Bvud+RX94ac4b dGQWl+FhSeCpwkfkjg09nzT5tkbvzoIcjnlK949M3MawWE8UD4eYEwoHpQDLS0WhLbZW aQ3X77S0LfAj2ruLZH+QmsmBc/34jgC7MZ3xysK4QiXM4BFnOsXerupCMBGyQnLmsBfm kdOR/L003q4IOj8L/t+B59VvuMA9AFE1C0UiNWwEnntKfLVYTG+/hGuQCFynLNi45hh3 68Vw9YARhf2l8CMYfK43W8zpSzRlUQsbxB2um1wQ4sRgMIuyF/GHNcVNFhVPsMYzSPu0 gu7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=f7DFyXKT; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q40si1320151pjb.17.2019.05.23.09.41.01; Thu, 23 May 2019 09:41:17 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=f7DFyXKT; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731398AbfEWQic (ORCPT + 99 others); Thu, 23 May 2019 12:38:32 -0400 Received: from mail-ua1-f66.google.com ([209.85.222.66]:46313 "EHLO mail-ua1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731281AbfEWQib (ORCPT ); Thu, 23 May 2019 12:38:31 -0400 Received: by mail-ua1-f66.google.com with SMTP id a95so2398220uaa.13 for ; Thu, 23 May 2019 09:38:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=r0rDpYcpEU2DlpfJPWclkw5oXzfo0RvY7oAeAA+3T90=; b=f7DFyXKTBWt5U7XgFYEc6tpBvygZbJf11fOqOQXgOXkwOVzXyJkqrEFj1jL04GFqyF KaPeTgWPv1xcwPktqe+PKBE5ipEuuUyahM+6zRAjX7mwCrDn8SQiMqpgRr8v4QSo8uBt mai/Br9ocyY4z1h4P4lZ9JoH9BK9pnb/uS9X8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=r0rDpYcpEU2DlpfJPWclkw5oXzfo0RvY7oAeAA+3T90=; b=DW/iAnxn8I8kPt2KCBOZMwuLO5O3p8Kdw9wpYUdKLmk6O9bErhTIjz2Grq+MGEvP4u MlngadFaMv2nGQ6wAJ6HzyGXenU34ycxAhsyuaShvGHBoLuo2bu3MdCnk7mt/S2Bn7Ck I6dmV9xYRgGVw6d9kYlJQh40Da9S3R8eYxOLQD/3bZGBJhUG2UZjQj00q1NvXiSD6BVi dPDyOmEUpjPByo4Yxqg92gSEsdcdijq1SrBGXwck3kml/83SLU5XSGCeG26xL6vdX8fw 6bHkMl2+/qhghUucdEtdwrFx115REkh4BuBRoq1m7p2HUHSqpijx5Er7Ru3IjCbb+kdJ shkg== X-Gm-Message-State: APjAAAVzqHboTTCwpWirh5qty3/si/LSIIE6nVJk1Kvzoy4jDKciFqXG m0weoOK27JOJieV/PSZ+cR/3N3Yw5Yg= X-Received: by 2002:a9f:22e8:: with SMTP id 95mr41344595uan.6.1558629509570; Thu, 23 May 2019 09:38:29 -0700 (PDT) Received: from mail-vs1-f43.google.com (mail-vs1-f43.google.com. [209.85.217.43]) by smtp.gmail.com with ESMTPSA id w9sm6046890vkh.53.2019.05.23.09.38.25 for (version=TLS1_3 cipher=AEAD-AES128-GCM-SHA256 bits=128/128); Thu, 23 May 2019 09:38:28 -0700 (PDT) Received: by mail-vs1-f43.google.com with SMTP id l20so3990844vsp.3 for ; Thu, 23 May 2019 09:38:25 -0700 (PDT) X-Received: by 2002:a67:1cc2:: with SMTP id c185mr23275103vsc.20.1558629505309; Thu, 23 May 2019 09:38:25 -0700 (PDT) MIME-Version: 1.0 References: <20190501043734.26706-1-bjorn.andersson@linaro.org> <20190501043734.26706-3-bjorn.andersson@linaro.org> In-Reply-To: <20190501043734.26706-3-bjorn.andersson@linaro.org> From: Doug Anderson Date: Thu, 23 May 2019 09:38:13 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v7 2/4] soc: qcom: Add AOSS QMP driver To: Bjorn Andersson Cc: Andy Gross , David Brown , Stephen Boyd , Rob Herring , Mark Rutland , linux-arm-msm , devicetree@vger.kernel.org, LKML Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On Tue, Apr 30, 2019 at 9:38 PM Bjorn Andersson wrote: > > +static int qmp_qdss_clk_prepare(struct clk_hw *hw) > +{ > + struct qmp *qmp = container_of(hw, struct qmp, qdss_clk); > + char buf[QMP_MSG_LEN] = "{class: clock, res: qdss, val: 1}"; nit: "static const" the buf? No need to copy it to the stack each time. In qmp_qdss_clk_unprepare() too. ...your string is also now fixed at 34 bytes big (including the '\0'). Do we still need to send exactly 96 bytes, or can we dumb this down to 36? We'll get a compile error if we overflow, right? If this truly needs to be exactly 96 bytes maybe qmp_send()'s error checks should check for things being exactly 96 bytes instead of checking for > and % 4. > +static int qmp_qdss_clk_add(struct qmp *qmp) > +{ > + struct clk_init_data qdss_init = { > + .ops = &qmp_qdss_clk_ops, > + .name = "qdss", > + }; Can't qdss_init be "static const"? That had the advantage of not needing to construct it on the stack and also of it having a longer lifetime. It looks like clk_register() stores the "hw" pointer in its structure and the "hw" structure will have a pointer here. While I can believe that it never looks at it again, it's nice if that pointer doesn't point somewhere on an old stack. I suppose we could go the other way and try to mark more stuff in this module as __init and __initdata, but even then at least the pointer won't be onto a stack. ;-) > + int ret; > + > + qmp->qdss_clk.init = &qdss_init; > + ret = clk_hw_register(qmp->dev, &qmp->qdss_clk); > + if (ret < 0) { > + dev_err(qmp->dev, "failed to register qdss clock\n"); > + return ret; > + } > + > + return of_clk_add_hw_provider(qmp->dev->of_node, of_clk_hw_simple_get, > + &qmp->qdss_clk); devm_clk_hw_register() and devm_of_clk_add_hw_provider()? If you're worried about ordering you could always throw in devm_add_action_or_reset() to handle the qmp_pd_remove(), qmp_close() and mbox_free_channel(). ...with that you could fully get rid of qmp_remove() and also your setting of drvdata. > +static void qmp_pd_remove(struct qmp *qmp) > +{ > + struct genpd_onecell_data *data = &qmp->pd_data; > + struct device *dev = qmp->dev; > + int i; > + > + of_genpd_del_provider(dev->of_node); > + > + for (i = 0; i < data->num_domains; i++) > + pm_genpd_remove(data->domains[i]); Still feels like the above loop would be better as: for (i = data->num_domains - 1; i >= 0; i--) (BTW: any way you could add me to the CC list for future patches so I notice them earlier?) -Doug