From patchwork Fri Oct 23 11:54:57 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 55482 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f197.google.com (mail-wi0-f197.google.com [209.85.212.197]) by patches.linaro.org (Postfix) with ESMTPS id D53C620581 for ; Fri, 23 Oct 2015 11:55:12 +0000 (UTC) Received: by wikv3 with SMTP id v3sf10104972wik.1 for ; Fri, 23 Oct 2015 04:55:12 -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=AMnsxEuif7BK0uwLZDhwVlh7mIILglChll35LbiFnVM=; b=MOGsJtjOPBw39l3sz7CdkJCopcZE5zRlc9uL3NSJ756apFgUlWF1a7Y/8LGuiS5Wn1 aGLg7kV6GaJ5/jqlNQqGpNwBnAsB5/F8wfkyPohbIMcBj68jO+Ql9QVngYi8Z4pwA0hk +XzPb2mAIImo7tkBS2HBqrHHZQF1J7zVWO7RCOwEJfLHL+MOsqThhVW0iBPv/WeDIFz6 okD/1s1P9R7dep7o0fv8VjLBGzaYZ64hmgRZNPw2pxQnVRjZIOBnvQJmIGzKpW7tTo4C oG2pfGBGrt1zxCpIuZ9NZMoGsQ4KUaht0Vai+rWCHbRH+ykaKMxHzz0QGViSS2qFEgsB lqaQ== X-Gm-Message-State: ALoCoQkmNWpB9tdAyXJ/7udkwTx+L1s/ck4k24EuinptxJvjdnBLXjZKPCLVjxqCFz4sstLFayjO X-Received: by 10.180.149.135 with SMTP id ua7mr753952wib.7.1445601312198; Fri, 23 Oct 2015 04:55:12 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.25.142.16 with SMTP id q16ls391515lfd.64.gmail; Fri, 23 Oct 2015 04:55:12 -0700 (PDT) X-Received: by 10.112.188.168 with SMTP id gb8mr10942717lbc.6.1445601312049; Fri, 23 Oct 2015 04:55:12 -0700 (PDT) Received: from mail-lf0-f44.google.com (mail-lf0-f44.google.com. [209.85.215.44]) by mx.google.com with ESMTPS id rq10si12428643lbb.158.2015.10.23.04.55.12 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 23 Oct 2015 04:55:12 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.44 as permitted sender) client-ip=209.85.215.44; Received: by lfbn126 with SMTP id n126so46183115lfb.2 for ; Fri, 23 Oct 2015 04:55:11 -0700 (PDT) X-Received: by 10.25.82.76 with SMTP id g73mr7498269lfb.56.1445601311915; Fri, 23 Oct 2015 04:55:11 -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.112.59.35 with SMTP id w3csp1178308lbq; Fri, 23 Oct 2015 04:55:10 -0700 (PDT) X-Received: by 10.107.33.2 with SMTP id h2mr20509289ioh.30.1445601310693; Fri, 23 Oct 2015 04:55:10 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n68si15338697ioe.51.2015.10.23.04.55.09; Fri, 23 Oct 2015 04:55:10 -0700 (PDT) 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; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752209AbbJWLzI (ORCPT + 11 others); Fri, 23 Oct 2015 07:55:08 -0400 Received: from mail-wi0-f173.google.com ([209.85.212.173]:37789 "EHLO mail-wi0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751768AbbJWLzH (ORCPT ); Fri, 23 Oct 2015 07:55:07 -0400 Received: by wicfv8 with SMTP id fv8so28482749wic.0 for ; Fri, 23 Oct 2015 04:55:06 -0700 (PDT) X-Received: by 10.28.138.148 with SMTP id m142mr426246wmd.2.1445601305927; Fri, 23 Oct 2015 04:55:05 -0700 (PDT) Received: from mai.telefonica.net (185.Red-213-96-199.staticIP.rima-tde.net. [213.96.199.185]) by smtp.gmail.com with ESMTPSA id w9sm816222wjf.20.2015.10.23.04.55.04 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 23 Oct 2015 04:55:05 -0700 (PDT) From: Daniel Lezcano To: rjw@rjwysocki.net Cc: Russell King , linux-pm@vger.kernel.org (open list:CPUIDLE DRIVERS), linux-kernel@vger.kernel.org (open list) Subject: [PATCH 1/2] cpuidle: mvebu: clean up multiple platform drivers Date: Fri, 23 Oct 2015 13:54:57 +0200 Message-Id: <1445601298-31138-1-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <562A1FE0.1060302@linaro.org> References: <562A1FE0.1060302@linaro.org> Sender: linux-pm-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: daniel.lezcano@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.215.44 as permitted sender) smtp.mailfrom=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: , From: Russell King There's no need to use multiple platform drivers, especially when we want to do something different in the probe, but we still use a common probe function. We can use the platform ID system to only register one platform driver, but have it match several devices, and give us the CPU idle driver via the ID's driver_data. Signed-off-by: Russell King Signed-off-by: Daniel Lezcano --- drivers/cpuidle/cpuidle-mvebu-v7.c | 45 +++++++++++++++++--------------------- 1 file changed, 20 insertions(+), 25 deletions(-) diff --git a/drivers/cpuidle/cpuidle-mvebu-v7.c b/drivers/cpuidle/cpuidle-mvebu-v7.c index 980151f..facd7d3 100644 --- a/drivers/cpuidle/cpuidle-mvebu-v7.c +++ b/drivers/cpuidle/cpuidle-mvebu-v7.c @@ -99,44 +99,39 @@ static struct cpuidle_driver armada38x_idle_driver = { static int mvebu_v7_cpuidle_probe(struct platform_device *pdev) { - mvebu_v7_cpu_suspend = pdev->dev.platform_data; + const struct platform_device_id *id = pdev->id_entry; - if (!strcmp(pdev->dev.driver->name, "cpuidle-armada-xp")) - return cpuidle_register(&armadaxp_idle_driver, NULL); - else if (!strcmp(pdev->dev.driver->name, "cpuidle-armada-370")) - return cpuidle_register(&armada370_idle_driver, NULL); - else if (!strcmp(pdev->dev.driver->name, "cpuidle-armada-38x")) - return cpuidle_register(&armada38x_idle_driver, NULL); - else + if (!id) return -EINVAL; -} -static struct platform_driver armadaxp_cpuidle_plat_driver = { - .driver = { - .name = "cpuidle-armada-xp", - }, - .probe = mvebu_v7_cpuidle_probe, -}; + mvebu_v7_cpu_suspend = pdev->dev.platform_data; -module_platform_driver(armadaxp_cpuidle_plat_driver); + return cpuidle_register((struct cpuidle_driver *)id->driver_data, NULL); +} -static struct platform_driver armada370_cpuidle_plat_driver = { - .driver = { +static const struct platform_device_id mvebu_cpuidle_ids[] = { + { + .name = "cpuidle-armada-xp", + .driver_data = (unsigned long)&armadaxp_idle_driver, + }, { .name = "cpuidle-armada-370", + .driver_data = (unsigned long)&armada370_idle_driver, + }, { + .name = "cpuidle-armada-38x", + .driver_data = (unsigned long)&armada38x_idle_driver, }, - .probe = mvebu_v7_cpuidle_probe, + {} }; -module_platform_driver(armada370_cpuidle_plat_driver); - -static struct platform_driver armada38x_cpuidle_plat_driver = { +static struct platform_driver mvebu_cpuidle_driver = { + .probe = mvebu_v7_cpuidle_probe, .driver = { - .name = "cpuidle-armada-38x", + .name = "cpuidle-mbevu", }, - .probe = mvebu_v7_cpuidle_probe, + .id_table = mvebu_cpuidle_ids, }; -module_platform_driver(armada38x_cpuidle_plat_driver); +module_platform_driver(mvebu_cpuidle_driver); MODULE_AUTHOR("Gregory CLEMENT "); MODULE_DESCRIPTION("Marvell EBU v7 cpuidle driver");