From patchwork Thu Jul 5 13:23:26 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 1160691 Return-Path: X-Original-To: patchwork-linux-acpi@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 0A96440ABE for ; Thu, 5 Jul 2012 13:23:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932721Ab2GENXc (ORCPT ); Thu, 5 Jul 2012 09:23:32 -0400 Received: from mail-wg0-f44.google.com ([74.125.82.44]:46875 "EHLO mail-wg0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756328Ab2GENXb (ORCPT ); Thu, 5 Jul 2012 09:23:31 -0400 Received: by wgbdr13 with SMTP id dr13so8306649wgb.1 for ; Thu, 05 Jul 2012 06:23:30 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=Iqkl21fKzSOnCDnXXGS6thvCIcrIX0j9MrDIQcQwYzw=; b=hXzTRIVWZsC6biW/0kUYyZ4APZV2RSilsyCd3cyHShLwUkWNqnGQS84ilvOhY5OKUi qdvkGu+kRX4lpOiMoN0pFl1rc0RstUn4ywrYZOp1wjhL+ZsHguqO8mu1RdhA1GAlJvSR vghUzHb1qhHPkhMF+slckvQ2GstpkKiBdA8wGFCZSi6PUOETNmr2O9J15hjcIQSE5LdJ Ns5yxAm1x9v93Z3jh/dw11u2KOKSAfe3Nn7gmznYYcGdpFLDrty1W0hR4bJGQAxYshSM Pmop33UpQc6sUcTW8hRP6jocH9glpkf3IZ9uEdCXMTwBqJYw7ZuP4ZI1ueV88UQUv/wT S35w== Received: by 10.180.105.130 with SMTP id gm2mr42033086wib.6.1341494610697; Thu, 05 Jul 2012 06:23:30 -0700 (PDT) Received: from localhost.localdomain (AToulouse-159-1-71-53.w92-134.abo.wanadoo.fr. [92.134.94.53]) by mx.google.com with ESMTPS id q6sm312524wiy.0.2012.07.05.06.23.29 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 05 Jul 2012 06:23:30 -0700 (PDT) From: Daniel Lezcano To: rjw@sisk.pl, lenb@kernel.org Cc: linux-acpi@vger.kernel.org, linux-pm@lists.linux-foundation.org, linaro-dev@lists.linaro.org Subject: [PATCH 2/4] cpuidle: define the enter function in the driver structure Date: Thu, 5 Jul 2012 15:23:26 +0200 Message-Id: <1341494608-16591-2-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 1.7.5.4 In-Reply-To: <1341494608-16591-1-git-send-email-daniel.lezcano@linaro.org> References: <1341494608-16591-1-git-send-email-daniel.lezcano@linaro.org> X-Gm-Message-State: ALoCoQnL/pCZuRPq+4L8ChYx7A5rp8RXQzQen6zGAjkPqwR096DkMub0kkGvTWelG8RhFQJKDtxW Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org We have the state index passed as parameter to the 'enter' function. Most of the drivers assign their 'enter' functions several times in the cpuidle_state structure, as we have the index, we can delegate to the driver to handle their own callback array. That will have the benefit of removing multiple lines of code in the different drivers. In order to smoothly modify the driver, the 'enter' function are in the driver structure and in the cpuidle state structure. That will let the time to modify the different drivers one by one. So the 'cpuidle_enter' function checks if the 'enter' callback is assigned in the driver structure and use it, otherwise it invokes the 'enter' assigned to the cpuidle_state. Signed-off-by: Daniel Lezcano --- drivers/cpuidle/cpuidle.c | 4 +++- include/linux/cpuidle.h | 1 + 2 files changed, 4 insertions(+), 1 deletions(-) diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c index 0132706..c064144 100644 --- a/drivers/cpuidle/cpuidle.c +++ b/drivers/cpuidle/cpuidle.c @@ -46,7 +46,9 @@ static inline int cpuidle_enter(struct cpuidle_device *dev, struct cpuidle_driver *drv, int index) { struct cpuidle_state *target_state = &drv->states[index]; - return target_state->enter(dev, drv, index); + + return drv->enter ? drv->enter(dev, drv, index) : + target_state->enter(dev, drv, index); } static inline int cpuidle_enter_tk(struct cpuidle_device *dev, diff --git a/include/linux/cpuidle.h b/include/linux/cpuidle.h index a6b3f2e..4d816c7 100644 --- a/include/linux/cpuidle.h +++ b/include/linux/cpuidle.h @@ -131,6 +131,7 @@ struct cpuidle_driver { struct cpuidle_state states[CPUIDLE_STATE_MAX]; int state_count; int safe_state_index; + int (*enter)(struct cpuidle_device *, struct cpuidle_driver *, int); }; #ifdef CONFIG_CPU_IDLE