From patchwork Thu Apr 12 01:02:42 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Turquette X-Patchwork-Id: 7746 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 360FD23E29 for ; Thu, 12 Apr 2012 01:07:45 +0000 (UTC) Received: from mail-iy0-f180.google.com (mail-iy0-f180.google.com [209.85.210.180]) by fiordland.canonical.com (Postfix) with ESMTP id F021DA18142 for ; Thu, 12 Apr 2012 01:07:44 +0000 (UTC) Received: by mail-iy0-f180.google.com with SMTP id e36so2812570iag.11 for ; Wed, 11 Apr 2012 18:07:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:from:to:cc :subject:date:message-id:x-mailer:in-reply-to:references :mime-version:content-type:x-gm-message-state; bh=JYZ5q9OKR0RiKaEE9/amR7toDZcZvsLQiz+MMj3eP/w=; b=N3y3ghnsPDGqrkqWobJVjVGtGtGlrlAcJ2vj62edzmqKDz1BpdpvqkaVC5eiWSOhh+ dCLmQfnkiOZjIi1NCEOdtl/mePcv+W9kw1BXaUAh4w7yKJ9qGMiI6AJ7LlMKJhsK07N0 P0Z2eJjbgw3sfwquy73CM/VuZAsl3BJnuKZCn+mqk7KXsWEf7r1/zF33kkdP2m2QSrft fGYAACgVCFyTyDGQZWBQHymVBEScFeAZ+8jIf4ZPXz+OfP4pa6i/miZLQoFjXlqttKjn nlrcrb1vIQ+K+JS6p6U8DaqCxj9dpHrzw/+xyOFueHHFSZddTx9y+DII2pcSWWeClJsA s6JA== Received: by 10.50.153.162 with SMTP id vh2mr1997966igb.38.1334192864742; Wed, 11 Apr 2012 18:07:44 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.231.164.217 with SMTP id f25csp161845iby; Wed, 11 Apr 2012 18:07:43 -0700 (PDT) Received: by 10.60.21.103 with SMTP id u7mr709070oee.11.1334192862753; Wed, 11 Apr 2012 18:07:42 -0700 (PDT) Received: from arroyo.ext.ti.com (arroyo.ext.ti.com. [192.94.94.40]) by mx.google.com with ESMTPS id ip10si1764055obb.147.2012.04.11.18.07.40 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 11 Apr 2012 18:07:42 -0700 (PDT) Received-SPF: neutral (google.com: 192.94.94.40 is neither permitted nor denied by best guess record for domain of mturquette@linaro.org) client-ip=192.94.94.40; Authentication-Results: mx.google.com; spf=neutral (google.com: 192.94.94.40 is neither permitted nor denied by best guess record for domain of mturquette@linaro.org) smtp.mail=mturquette@linaro.org Received: from dlelxv30.itg.ti.com ([172.17.2.17]) by arroyo.ext.ti.com (8.13.7/8.13.7) with ESMTP id q3C17ZHU018255; Wed, 11 Apr 2012 20:07:35 -0500 Received: from DLEE74.ent.ti.com (dlee74.ent.ti.com [157.170.170.8]) by dlelxv30.itg.ti.com (8.13.8/8.13.8) with ESMTP id q3C17Z16002627; Wed, 11 Apr 2012 20:07:35 -0500 Received: from dlelxv22.itg.ti.com (172.17.1.197) by DLEE74.ent.ti.com (157.170.170.8) with Microsoft SMTP Server id 14.1.323.3; Wed, 11 Apr 2012 20:07:35 -0500 Received: from nucleus.nsc.com (nucleus.nsc.com [10.188.36.112]) by dlelxv22.itg.ti.com (8.13.8/8.13.8) with ESMTP id q3C17Pn5005839; Wed, 11 Apr 2012 20:07:34 -0500 From: Mike Turquette To: CC: , , , , Mike Turquette , Olof Johansson , Russell King , Sascha Hauer , Shawn Guo , Richard Zhao , Saravana Kannan , Mark Brown , Andrew Lunn , Rajendra Nayak , Viresh Kumar Subject: [PATCH 04/13] clk: core: enforce clk_ops consistency Date: Wed, 11 Apr 2012 18:02:42 -0700 Message-ID: <1334192572-12499-5-git-send-email-mturquette@linaro.org> X-Mailer: git-send-email 1.7.5.4 In-Reply-To: <1334192572-12499-1-git-send-email-mturquette@linaro.org> References: <1334192572-12499-1-git-send-email-mturquette@linaro.org> MIME-Version: 1.0 X-Gm-Message-State: ALoCoQn08poKZvO7EstQvrInNqRoISvjyS7u3rq1YaRpnaXzAfp0dEZoJaFd4PcVV+iJxN23h8dt Documentation/clk.txt has some handsome ASCII art outlining which clk_ops are mandatory for a given clock, given the capability of the hardware. Enforce those mandates with sanity checks in __clk_init. Signed-off-by: Mike Turquette Cc: Arnd Bergman Cc: Olof Johansson Cc: Russell King Cc: Sascha Hauer Cc: Shawn Guo Cc: Richard Zhao Cc: Saravana Kannan Cc: Mark Brown Cc: Andrew Lunn Cc: Rajendra Nayak Cc: Viresh Kumar Reviewed-by: Viresh Kumar --- drivers/clk/clk.c | 14 ++++++++++++++ 1 files changed, 14 insertions(+), 0 deletions(-) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index d83a9e0..9924aec 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -1202,6 +1202,20 @@ void __clk_init(struct device *dev, struct clk *clk) if (__clk_lookup(clk->name)) goto out; + /* check that clk_ops are sane. See Documentation/clk.txt */ + if (clk->ops->set_rate && + !(clk->ops->round_rate && clk->ops->recalc_rate)) { + pr_warning("%s: %s must implement .round_rate & .recalc_rate\n", + __func__, clk->name); + goto out; + } + + if (clk->ops->set_parent && !clk->ops->get_parent) { + pr_warning("%s: %s must implement .get_parent & .set_parent\n", + __func__, clk->name); + goto out; + } + /* throw a WARN if any entries in parent_names are NULL */ for (i = 0; i < clk->num_parents; i++) WARN(!clk->parent_names[i],