From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.3 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4C77CC4727D for ; Fri, 25 Sep 2020 14:42:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 00D4621D42 for ; Fri, 25 Sep 2020 14:42:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1601044929; bh=8YEFRZVqYJPJ/15FHVj7Qk+pbASJGnkree6Lt7U2QWQ=; h=References:In-Reply-To:From:Date:Subject:To:Cc:List-ID:From; b=j6gprDk7nehjys+5nBqVLFuyoJAY0bKhA5Iqd/FpwnnhMC9qS3aHQiaE1AmhqRjkq umKqR9/rVSEyjgZ6VF73jLjsExlunpd84v2kQOjoz4z9gKiti3cfSG+585MDOzH/Qd hUUJt6tTRiA4/AFth7TR2yxXV7Oo5yCghMDcyJEo= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729075AbgIYOmI (ORCPT ); Fri, 25 Sep 2020 10:42:08 -0400 Received: from mail-oi1-f195.google.com ([209.85.167.195]:40084 "EHLO mail-oi1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728148AbgIYOmH (ORCPT ); Fri, 25 Sep 2020 10:42:07 -0400 Received: by mail-oi1-f195.google.com with SMTP id t76so3002924oif.7; Fri, 25 Sep 2020 07:42:07 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=YG0gNwPh92HOAhHCe1SetMmUyiG3vhJKCYpc+sgtuns=; b=AaCMKmypEAR0oxhZ87tbPAdEbGxbds21QwSmF9S9d/2nuDLX/xh+eKdUFiypbEZ2Y6 Fq1wfpXeL3aPOx75BOg5aOK5Wrb0J5xQabnB7AJD8CXxeMj7SKnPA5wCkgyaeuHi011Q Ii6VQ6BOj4U5HCYhKzTas0h9JZYaoVw1dkbG0P8UzHbLy1uvKoIR4/2KElZAYHpLiUS2 9s/txLVz43H6722a3FctMuPslPmeD5pJFegi+QEjLFSHG/13CHXoBOEeeRAR3MNjTJKH CQ0ZZYhfjSNn9Ruc/t8ca3JlgBzwtphZdROBO/KAUvdBaCJ5GKn/1slQ4xxETA9P5dUZ srhQ== X-Gm-Message-State: AOAM532olw1F1GPCWyif6EwclGPDfXrZ1bchT4F16BL/kjp+FEbWjUNK EG9ECsKdezmgX5+56IDIo8IY9NFovUIF3uHTSvQ= X-Google-Smtp-Source: ABdhPJxU3jxuaLiKzG8zDH/2eFePJxoIPj8oFAp0fMhiapBAoCnj7xHlIj1YPh+i5qJ+MBniXk6wyRx8+xYVyP9+4pI= X-Received: by 2002:a05:6808:491:: with SMTP id z17mr463820oid.110.1601044926846; Fri, 25 Sep 2020 07:42:06 -0700 (PDT) MIME-Version: 1.0 References: <20200924080041.2740-1-zhuguangqing83@gmail.com> In-Reply-To: <20200924080041.2740-1-zhuguangqing83@gmail.com> From: "Rafael J. Wysocki" Date: Fri, 25 Sep 2020 16:41:56 +0200 Message-ID: Subject: Re: [PATCH] cpuidle: change #ifdef for the declaration of cpuidle_enter_s2idle() To: zhuguangqing83@gmail.com Cc: "Rafael J. Wysocki" , Daniel Lezcano , Linux PM , Linux Kernel Mailing List , zhuguangqing Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Sep 24, 2020 at 10:01 AM wrote: > > From: zhuguangqing > > Currently, if CONFIG_SUSPEND=n and CONFIG_CPU_IDLE=y, the function > cpuidle_enter_s2idle() is declared but not defined, it may cause error > when cpuidle_enter_s2idle() is called. > > If CONFIG_SUSPEND=y and CONFIG_CPU_IDLE=n, the function > cpuidle_enter_s2idle() is defined as "return -ENODEV;" which is not > supposed to be. > > Change #ifdef CONFIG_CPU_IDLE to #ifdef CONFIG_SUSPEND for > cpuidle_enter_s2idle() in cpuidle.h, which is consistent with its > defination in cpuidle.c. Well, what about the case when CONFIG_SUSPEND is set, but CONFIG_CPU_IDLE isn't? > > Signed-off-by: zhuguangqing > --- > include/linux/cpuidle.h | 14 +++++++++----- > 1 file changed, 9 insertions(+), 5 deletions(-) > > diff --git a/include/linux/cpuidle.h b/include/linux/cpuidle.h > index 6175c77bf25e..2aa8cead1727 100644 > --- a/include/linux/cpuidle.h > +++ b/include/linux/cpuidle.h > @@ -216,22 +216,26 @@ static inline struct cpuidle_device *cpuidle_get_device(void) {return NULL; } > extern int cpuidle_find_deepest_state(struct cpuidle_driver *drv, > struct cpuidle_device *dev, > u64 latency_limit_ns); > -extern int cpuidle_enter_s2idle(struct cpuidle_driver *drv, > - struct cpuidle_device *dev); > extern void cpuidle_use_deepest_state(u64 latency_limit_ns); > #else > static inline int cpuidle_find_deepest_state(struct cpuidle_driver *drv, > struct cpuidle_device *dev, > u64 latency_limit_ns) > {return -ENODEV; } > -static inline int cpuidle_enter_s2idle(struct cpuidle_driver *drv, > - struct cpuidle_device *dev) > -{return -ENODEV; } > static inline void cpuidle_use_deepest_state(u64 latency_limit_ns) > { > } > #endif > > +#ifdef CONFIG_SUSPEND > +extern int cpuidle_enter_s2idle(struct cpuidle_driver *drv, > + struct cpuidle_device *dev); > +#else > +static inline int cpuidle_enter_s2idle(struct cpuidle_driver *drv, > + struct cpuidle_device *dev) > +{return -ENODEV; } > +#endif > + > /* kernel/sched/idle.c */ > extern void sched_idle_set_state(struct cpuidle_state *idle_state); > extern void default_idle_call(void); > -- > 2.17.1 >