From patchwork Thu Nov 1 10:15:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 149946 Delivered-To: patches@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp600065ljp; Thu, 1 Nov 2018 03:16:12 -0700 (PDT) X-Received: by 2002:a2e:9d86:: with SMTP id c6-v6mr4386935ljj.146.1541067372103; Thu, 01 Nov 2018 03:16:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1541067372; cv=none; d=google.com; s=arc-20160816; b=Z9LAF7qho3OA6+aKbM8IrNqB3jgHYhxjikqIEefJeNHaiEcsISTIO6tC/H7uy6zhXQ m+/8YaC1taKMNPDt91DZbWL3eutqB9zsTezkn85TVR3VVVhPOyPjDT3BlkALu01Bpjfb xImsdN2bP/Y6tgXa722O0+6LFDUrFURzq9r6pMURXVlxwKMyBWaLwNCEpYYJDjVgHn6f aff6mtk01IrGHPxcld61/J8AJschTI/yntwFdoN4q0HbVpp/qQXd1F4NuYXnq7prKAAm 1WOmWeH84fJppmdyB7pQEVnRbnKzm4Uqz0hC4PaP6aKnF31PZFtn9pnd63HTOTI15En8 M81w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:cc:to:from:dkim-signature; bh=yYSTozc/AyueJ39Ry2KZnVCxEzhuLsH7UrmGbAaS8pM=; b=Nk23xvnMH8lxnYrFJ245n3GdoSe+Us8v0U4TjE07NH6ZCv9N9vWwL13Enx/M3zLWAP S/VMe9690kNXOCABQXPT6WYZkKI9GjfH8WMS8iFQ6LyELUJEZ2f2yYSjFdUWROawzJPF ZPFhd4jP131uG4qvclRt4NnoRlbpgcKQtDYPPLXJ3wBB2+bJlgO4/2ncEuSlbDvpnEPH q/h25Q6wtCNPJkQDycgVPiB4odoJ7N4YvnmRAdAkkxNw3GETbxMfIWO0TLS4lSkcDKFJ CL/uD6fSr3WrkmAvn+hktMwVKzgm4nTfbLkEGzpPuG67yflDO32MduNg6lWteDMqYW5v J+jQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LKp902Lf; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id z26sor3629715lfe.67.2018.11.01.03.16.12 for (Google Transport Security); Thu, 01 Nov 2018 03:16:12 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LKp902Lf; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=yYSTozc/AyueJ39Ry2KZnVCxEzhuLsH7UrmGbAaS8pM=; b=LKp902Lfha43yr+uheKrWZMeZyQjjtZ2S+HjFxZvo/vvUN+q8BFBdiyvHiqw1ZXSnw 64cX2PPbEvNRjJx1j8BvOgj1pBtEiHk/BC3cPCvkEOVZev68IsrEZ6IIflVDiG7XlaA7 i5N61fmyjoVpPyK9x33+UvJ5sbjsgswIyM5XI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=yYSTozc/AyueJ39Ry2KZnVCxEzhuLsH7UrmGbAaS8pM=; b=eQoq4u9XkHJ7FsKqWyCSIoA7znxDnRnTHiow9ZtswuzHnyVl7euuAeibUrls5UmRLo AfmL2NJZk+RKBnaAPUpCJv1WdztspQuPyC/BmJmO2lF+4Hu53iVsbqOO9GbKwoiEdvc6 uTsPEw9wNArv6YrMR83tydqhZpr1tihhJze2Cr7U4PNSaNGSlYeknnd2hn+nQfGQyqGK z+LqAmbH6WmRvqoT/0jIPGwkkIfFPqknHqKLTp1ZQbP1DMM4BQWe0bfIDOE6A1qVV/sb rs37CBqesXqE2XO5/pdteOPMJIlgq17+JZLeUASQs2vkSbSwIpYe4Yw6QNTOxTvgkcDw FqqQ== X-Gm-Message-State: AGRZ1gIfBtztwRDk/oBpQVr3qqAJ1aBPOrvIejTxs5TLvRx0j+LcBGlf 90iFDZHssw0ThRFTO17uo4iion43 X-Google-Smtp-Source: AJdET5cO0MFHx8m8B36AKwWaHuMsSFzEAZKJInLE+YcIxHEeAVttpQjb0ZHXa5ix0H9qmN0DGHFPBg== X-Received: by 2002:a19:d58e:: with SMTP id m136mr4346357lfg.70.1541067371730; Thu, 01 Nov 2018 03:16:11 -0700 (PDT) Return-Path: Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id m63-v6sm3066075lje.81.2018.11.01.03.16.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 01 Nov 2018 03:16:10 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Daniel Lezcano , linux-pm@vger.kernel.org Cc: Sudeep Holla , Lorenzo Pieralisi , Lina Iyer , Ulf Hansson , Vincent Guittot , linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org Subject: [PATCH v2 2/2] ARM: cpuidle: Convert to use cpuidle_register|unregister() Date: Thu, 1 Nov 2018 11:15:58 +0100 Message-Id: <20181101101558.3035-1-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 The only reason that remains, to why the ARM cpuidle driver calls cpuidle_register_driver(), is to avoid printing an error message in case another driver already have been registered for the CPU. This seems a bit silly, but more importantly, if that is a common scenario, perhaps we should change cpuidle_register() accordingly instead. In either case, let's consolidate the code, by converting to use cpuidle_register|unregister(), which also avoids the unnecessary allocation of the struct cpuidle_device. Signed-off-by: Ulf Hansson Reviewed-by: Lorenzo Pieralisi --- Changes in v2: - Fixup spelling in changelog. - Added Lorenzo's reviewed-by tag. --- drivers/cpuidle/cpuidle-arm.c | 30 +++--------------------------- 1 file changed, 3 insertions(+), 27 deletions(-) -- 2.17.1 diff --git a/drivers/cpuidle/cpuidle-arm.c b/drivers/cpuidle/cpuidle-arm.c index df564d783216..3a407a3ef22b 100644 --- a/drivers/cpuidle/cpuidle-arm.c +++ b/drivers/cpuidle/cpuidle-arm.c @@ -82,7 +82,6 @@ static int __init arm_idle_init_cpu(int cpu) { int ret; struct cpuidle_driver *drv; - struct cpuidle_device *dev; drv = kmemdup(&arm_idle_driver, sizeof(*drv), GFP_KERNEL); if (!drv) @@ -119,33 +118,12 @@ static int __init arm_idle_init_cpu(int cpu) goto out_kfree_drv; } - ret = cpuidle_register_driver(drv); - if (ret) { - if (ret != -EBUSY) - pr_err("Failed to register cpuidle driver\n"); + ret = cpuidle_register(drv, NULL); + if (ret) goto out_kfree_drv; - } - - dev = kzalloc(sizeof(*dev), GFP_KERNEL); - if (!dev) { - ret = -ENOMEM; - goto out_unregister_drv; - } - dev->cpu = cpu; - - ret = cpuidle_register_device(dev); - if (ret) { - pr_err("Failed to register cpuidle device for CPU %d\n", - cpu); - goto out_kfree_dev; - } return 0; -out_kfree_dev: - kfree(dev); -out_unregister_drv: - cpuidle_unregister_driver(drv); out_kfree_drv: kfree(drv); return ret; @@ -176,9 +154,7 @@ static int __init arm_idle_init(void) while (--cpu >= 0) { dev = per_cpu(cpuidle_devices, cpu); drv = cpuidle_get_cpu_driver(dev); - cpuidle_unregister_device(dev); - cpuidle_unregister_driver(drv); - kfree(dev); + cpuidle_unregister(drv); kfree(drv); }