From patchwork Mon Feb 22 08:48:20 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 62478 Delivered-To: patch@linaro.org Received: by 10.112.43.199 with SMTP id y7csp1101322lbl; Mon, 22 Feb 2016 00:48:51 -0800 (PST) X-Received: by 10.98.0.84 with SMTP id 81mr36666608pfa.67.1456130931332; Mon, 22 Feb 2016 00:48:51 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v88si38379740pfi.243.2016.02.22.00.48.50; Mon, 22 Feb 2016 00:48:51 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dkim=neutral (body hash did not verify) header.i=@linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753683AbcBVIst (ORCPT + 11 others); Mon, 22 Feb 2016 03:48:49 -0500 Received: from mail-pf0-f173.google.com ([209.85.192.173]:36164 "EHLO mail-pf0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753544AbcBVIss (ORCPT ); Mon, 22 Feb 2016 03:48:48 -0500 Received: by mail-pf0-f173.google.com with SMTP id e127so89491913pfe.3 for ; Mon, 22 Feb 2016 00:48:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=qwnloj58dLCMk2HK556Nd2/EYPLJPiYbshb0HnWxiMg=; b=dSpFVSDoat3VDf9oEk6hO/GYWPxmjmpinpFln2/SzNFqsp2F26QnlQ/2aeYJm6Mh0F 8N1CeqcPSvmnfCf2bU6WueNrIQo9BphWgiMZzrN+T0j5+nsMp96JPJxuAbygkCsfMFDj zbNdo6M60gZwUsromdKtIQb8cIyE8ffn8nWoA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=qwnloj58dLCMk2HK556Nd2/EYPLJPiYbshb0HnWxiMg=; b=CZ31Rg/zBgeOse2AoDILUXWPyN9QYNeeWcHleAtxaPV9EKSs81d2a724y5hO4ycF7b vqr9FXqNdzelR7Y346APknrdIagsYPmiDJcRfucMsnmRec4MGwZjnQdP1ScWx9V6fmo1 cTpwN6EqWmxRc29CwAxHvCPYViorBKI0UsXCf2Fku/Iz5PBuJkRBpje1Efp4fipiq0z6 zLBCQUNAlrDWw9UjWPqod9aMg1bPc6/uD2VMP0EQQvsGD2hUR+IbwkodBIGZiOVwu9QX 0uDFmhv1ITN6zPSQDADJrTMFFlqNDt0r1geXIbQ6ZbR/DG0qZiverT2MHl2Ke29hudUB wfTA== X-Gm-Message-State: AG10YOTndEsy7VeV+MVukOATIyqib37VSEi4VTkqSlozvLI7SBsN00eGCqwZ79FzqHZmHc70 X-Received: by 10.98.67.153 with SMTP id l25mr36605360pfi.111.1456130928401; Mon, 22 Feb 2016 00:48:48 -0800 (PST) Received: from localhost ([122.172.89.184]) by smtp.gmail.com with ESMTPSA id f12sm34895588pfd.87.2016.02.22.00.48.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 22 Feb 2016 00:48:47 -0800 (PST) From: Viresh Kumar To: Rafael Wysocki , Viresh Kumar Cc: linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] cpufreq: governors: Drop unnecessary checks from show() and store() Date: Mon, 22 Feb 2016 14:18:20 +0530 Message-Id: <306e197065818fbd8d696fbe2071ccb39682a775.1456130856.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.7.1.410.g6faf27b Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org The show() and store() routines in the cpufreq-governor core don't need to check if the struct governor_attr they want to use really provides the callbacks they need as expected (if that's not the case, it means a bug in the code anyway), so change them to avoid doing that. Also change the error value to -EBUSY, if the governor is getting removed and we aren't allowed to store any more changes. Signed-off-by: Viresh Kumar --- drivers/cpufreq/cpufreq_governor.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) -- 2.7.1.410.g6faf27b -- To unsubscribe from this list: send the line "unsubscribe linux-pm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/cpufreq/cpufreq_governor.c b/drivers/cpufreq/cpufreq_governor.c index aeb5ad81d869..528cd7a49398 100644 --- a/drivers/cpufreq/cpufreq_governor.c +++ b/drivers/cpufreq/cpufreq_governor.c @@ -125,12 +125,8 @@ static ssize_t governor_show(struct kobject *kobj, struct attribute *attr, { struct dbs_data *dbs_data = to_dbs_data(kobj); struct governor_attr *gattr = to_gov_attr(attr); - int ret = -EIO; - if (gattr->show) - ret = gattr->show(dbs_data, buf); - - return ret; + return gattr->show(dbs_data, buf); } static ssize_t governor_store(struct kobject *kobj, struct attribute *attr, @@ -138,11 +134,11 @@ static ssize_t governor_store(struct kobject *kobj, struct attribute *attr, { struct dbs_data *dbs_data = to_dbs_data(kobj); struct governor_attr *gattr = to_gov_attr(attr); - int ret = -EIO; + int ret = -EBUSY; mutex_lock(&dbs_data->mutex); - if (dbs_data->usage_count && gattr->store) + if (dbs_data->usage_count) ret = gattr->store(dbs_data, buf, count); mutex_unlock(&dbs_data->mutex);