From patchwork Wed Aug 13 11:33:38 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guodong Xu X-Patchwork-Id: 35344 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ig0-f198.google.com (mail-ig0-f198.google.com [209.85.213.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 67C3E203C5 for ; Wed, 13 Aug 2014 11:35:11 +0000 (UTC) Received: by mail-ig0-f198.google.com with SMTP id h18sf3128218igc.5 for ; Wed, 13 Aug 2014 04:35:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=vbGIhPIhPRuapsIgt2NRZ/ilkZj4MeNjM98X1jFceDw=; b=O5QWTKYkNzNj4vpfYK4VyQuKbE/tB+y60O13+oAGqv3ILvtgmpzpqOcdgUnN6GmKSB sGmiviBcdPbt0nchifVWAFNANZN99bsXBuCNBye/gFpkknpg7E69bhP3+0u0m8D6a6BD McyrLQL4k/1lumwlmHKMHYmXiM6de9d8emGoCN47pWQYC0wnEWzBSGbF7vnR1+j3M6DB iT1gEF7OuwINhOVXAJlPTWat6nRS5++gWZPslbQAd9iClA24SZjazoowVM40u1qJ1BHD ThXJIFIHx/VxD9aui3bVJKb+sUskO9yCwZDA6PxGR05+tMKY3YbQd4nFgsF0cslsZ5g+ 8iUg== X-Gm-Message-State: ALoCoQl3z+QVH8o/xHtrgUZDz0lXpcQPpVSKP6+7QYDSaICgRh4Sy8kQ1PbhJsd/BXwPCwhgFXUR X-Received: by 10.182.81.161 with SMTP id b1mr1973149oby.1.1407929710979; Wed, 13 Aug 2014 04:35:10 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.87.9 with SMTP id q9ls544225qgd.5.gmail; Wed, 13 Aug 2014 04:35:10 -0700 (PDT) X-Received: by 10.221.24.135 with SMTP id re7mr94612vcb.53.1407929710886; Wed, 13 Aug 2014 04:35:10 -0700 (PDT) Received: from mail-vc0-f178.google.com (mail-vc0-f178.google.com [209.85.220.178]) by mx.google.com with ESMTPS id ym7si897150vdb.76.2014.08.13.04.35.10 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 13 Aug 2014 04:35:10 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.178 as permitted sender) client-ip=209.85.220.178; Received: by mail-vc0-f178.google.com with SMTP id la4so14983437vcb.9 for ; Wed, 13 Aug 2014 04:35:10 -0700 (PDT) X-Received: by 10.221.56.5 with SMTP id wa5mr2946227vcb.25.1407929710781; Wed, 13 Aug 2014 04:35:10 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.221.37.5 with SMTP id tc5csp323174vcb; Wed, 13 Aug 2014 04:35:10 -0700 (PDT) X-Received: by 10.66.220.230 with SMTP id pz6mr736557pac.145.1407929709733; Wed, 13 Aug 2014 04:35:09 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e6si1321707pdl.47.2014.08.13.04.35.08 for ; Wed, 13 Aug 2014 04:35:09 -0700 (PDT) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752354AbaHMLfF (ORCPT + 23 others); Wed, 13 Aug 2014 07:35:05 -0400 Received: from mail-pd0-f174.google.com ([209.85.192.174]:53375 "EHLO mail-pd0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751404AbaHMLfA (ORCPT ); Wed, 13 Aug 2014 07:35:00 -0400 Received: by mail-pd0-f174.google.com with SMTP id fp1so14393021pdb.33 for ; Wed, 13 Aug 2014 04:35:00 -0700 (PDT) X-Received: by 10.66.146.35 with SMTP id sz3mr705508pab.148.1407929700226; Wed, 13 Aug 2014 04:35:00 -0700 (PDT) Received: from localhost.localdomain ([120.136.45.59]) by mx.google.com with ESMTPSA id ya1sm1832872pbb.91.2014.08.13.04.34.52 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 13 Aug 2014 04:34:58 -0700 (PDT) From: Guodong Xu To: robh+dt@kernel.org, pawel.moll@arm.com, mark.rutland@arm.com, ijc+devicetree@hellion.org.uk, galak@codeaurora.org, linux@arm.linux.org.uk, sameo@linux.intel.com, lee.jones@linaro.org, lgirdwood@gmail.com, broonie@kernel.org, grant.likely@linaro.org, khilman@linaro.org, haojian.zhuang@linaro.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: Guodong Xu Subject: [PATCH v5 1/7] regulator: core: add const qualifier to ops in struct regulator_desc Date: Wed, 13 Aug 2014 19:33:38 +0800 Message-Id: <1407929624-8737-2-git-send-email-guodong.xu@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1407929624-8737-1-git-send-email-guodong.xu@linaro.org> References: <1407929624-8737-1-git-send-email-guodong.xu@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: guodong.xu@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.178 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , struct regulator_ops *ops is a member in struct regulator_desc, which gets its value from individual regulator driver upon regulator_register() and is used by regulator core APIs. It's not allowed for regulator core to modify any of these callbacks in *ops. Add 'const' qualifier to enforce that. Signed-off-by: Guodong Xu --- drivers/regulator/core.c | 24 ++++++++++++------------ include/linux/regulator/driver.h | 2 +- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index 4c1f999..eb6f172 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -838,7 +838,7 @@ static void print_constraints(struct regulator_dev *rdev) static int machine_constraints_voltage(struct regulator_dev *rdev, struct regulation_constraints *constraints) { - struct regulator_ops *ops = rdev->desc->ops; + const struct regulator_ops *ops = rdev->desc->ops; int ret; /* do we need to apply the constraint voltage */ @@ -935,7 +935,7 @@ static int machine_constraints_voltage(struct regulator_dev *rdev, static int machine_constraints_current(struct regulator_dev *rdev, struct regulation_constraints *constraints) { - struct regulator_ops *ops = rdev->desc->ops; + const struct regulator_ops *ops = rdev->desc->ops; int ret; if (!constraints->min_uA && !constraints->max_uA) @@ -979,7 +979,7 @@ static int set_machine_constraints(struct regulator_dev *rdev, const struct regulation_constraints *constraints) { int ret = 0; - struct regulator_ops *ops = rdev->desc->ops; + const struct regulator_ops *ops = rdev->desc->ops; if (constraints) rdev->constraints = kmemdup(constraints, sizeof(*constraints), @@ -2196,9 +2196,9 @@ EXPORT_SYMBOL_GPL(regulator_count_voltages); */ int regulator_list_voltage(struct regulator *regulator, unsigned selector) { - struct regulator_dev *rdev = regulator->rdev; - struct regulator_ops *ops = rdev->desc->ops; - int ret; + struct regulator_dev *rdev = regulator->rdev; + const struct regulator_ops *ops = rdev->desc->ops; + int ret; if (rdev->desc->fixed_uV && rdev->desc->n_voltages == 1 && !selector) return rdev->desc->fixed_uV; @@ -2484,8 +2484,8 @@ EXPORT_SYMBOL_GPL(regulator_set_voltage); int regulator_set_voltage_time(struct regulator *regulator, int old_uV, int new_uV) { - struct regulator_dev *rdev = regulator->rdev; - struct regulator_ops *ops = rdev->desc->ops; + struct regulator_dev *rdev = regulator->rdev; + const struct regulator_ops *ops = rdev->desc->ops; int old_sel = -1; int new_sel = -1; int voltage; @@ -3246,9 +3246,9 @@ EXPORT_SYMBOL_GPL(regulator_mode_to_status); */ static int add_regulator_attributes(struct regulator_dev *rdev) { - struct device *dev = &rdev->dev; - struct regulator_ops *ops = rdev->desc->ops; - int status = 0; + struct device *dev = &rdev->dev; + const struct regulator_ops *ops = rdev->desc->ops; + int status = 0; /* some attributes need specific methods to be displayed */ if ((ops->get_voltage && ops->get_voltage(rdev) >= 0) || @@ -3815,7 +3815,7 @@ core_initcall(regulator_init); static int __init regulator_init_complete(void) { struct regulator_dev *rdev; - struct regulator_ops *ops; + const struct regulator_ops *ops; struct regulation_constraints *c; int enabled, ret; diff --git a/include/linux/regulator/driver.h b/include/linux/regulator/driver.h index bbe03a1..4b62813 100644 --- a/include/linux/regulator/driver.h +++ b/include/linux/regulator/driver.h @@ -245,7 +245,7 @@ struct regulator_desc { int id; bool continuous_voltage_range; unsigned n_voltages; - struct regulator_ops *ops; + const struct regulator_ops *ops; int irq; enum regulator_type type; struct module *owner;