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=-6.9 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,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 507BBC43333 for ; Thu, 19 Mar 2020 13:12:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 232F8215A4 for ; Thu, 19 Mar 2020 13:12:51 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="h6lTLxGm" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729012AbgCSNMu (ORCPT ); Thu, 19 Mar 2020 09:12:50 -0400 Received: from us-smtp-delivery-74.mimecast.com ([216.205.24.74]:48385 "EHLO us-smtp-delivery-74.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728991AbgCSNMq (ORCPT ); Thu, 19 Mar 2020 09:12:46 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1584623566; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=BiF9UVVWwWC4pkbDjzQdjsflyybUcPqM93A1c/UpIdM=; b=h6lTLxGmffmVHkb8+tVVdLJeEs3zPNKFf3zT2QQEzIuXPbVQAipfebLsP/uBNpOCH/GMcj g0v05Y0lO3UbI8XnS+8SxN+4qDw3ta2I4F4zTFZnyqR9hed1dk+CdOhzyObYIAZyDP+l2J rEu6aFXJsDyKJc+etkFSiAt9ha4iMag= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-425-eqd4g3m3NW--1uSumeTZug-1; Thu, 19 Mar 2020 09:12:42 -0400 X-MC-Unique: eqd4g3m3NW--1uSumeTZug-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 523C0801A08; Thu, 19 Mar 2020 13:12:40 +0000 (UTC) Received: from t480s.redhat.com (ovpn-114-197.ams2.redhat.com [10.36.114.197]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8687360BF7; Thu, 19 Mar 2020 13:12:33 +0000 (UTC) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, linuxppc-dev@lists.ozlabs.org, linux-hyperv@vger.kernel.org, David Hildenbrand , Wei Yang , Michal Hocko , Greg Kroah-Hartman , Andrew Morton , Michal Hocko , Oscar Salvador , "Rafael J. Wysocki" , Baoquan He Subject: [PATCH v3 2/8] drivers/base/memory: map MMOP_OFFLINE to 0 Date: Thu, 19 Mar 2020 14:12:15 +0100 Message-Id: <20200319131221.14044-3-david@redhat.com> In-Reply-To: <20200319131221.14044-1-david@redhat.com> References: <20200319131221.14044-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Historically, we used the value -1. Just treat 0 as the special case now. Clarify a comment (which was wrong, when we come via device_online() the first time, the online_type would have been 0 / MEM_ONLINE). The default is now always MMOP_OFFLINE. This removes the last user of the manual "-1", which didn't use the enum value. This is a preparation to use the online_type as an array index. Reviewed-by: Wei Yang Acked-by: Michal Hocko Cc: Greg Kroah-Hartman Cc: Andrew Morton Cc: Michal Hocko Cc: Oscar Salvador Cc: "Rafael J. Wysocki" Cc: Baoquan He Cc: Wei Yang Signed-off-by: David Hildenbrand --- drivers/base/memory.c | 11 ++++------- include/linux/memory_hotplug.h | 2 +- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/drivers/base/memory.c b/drivers/base/memory.c index 8c5ce42c0fc3..e7e77cafef80 100644 --- a/drivers/base/memory.c +++ b/drivers/base/memory.c @@ -211,17 +211,14 @@ static int memory_subsys_online(struct device *dev) return 0; =20 /* - * If we are called from state_store(), online_type will be - * set >=3D 0 Otherwise we were called from the device online - * attribute and need to set the online_type. + * When called via device_online() without configuring the online_type, + * we want to default to MMOP_ONLINE. */ - if (mem->online_type < 0) + if (mem->online_type =3D=3D MMOP_OFFLINE) mem->online_type =3D MMOP_ONLINE; =20 ret =3D memory_block_change_state(mem, MEM_ONLINE, MEM_OFFLINE); - - /* clear online_type */ - mem->online_type =3D -1; + mem->online_type =3D MMOP_OFFLINE; =20 return ret; } diff --git a/include/linux/memory_hotplug.h b/include/linux/memory_hotplu= g.h index 3aaf00db224c..76f3c617a8ab 100644 --- a/include/linux/memory_hotplug.h +++ b/include/linux/memory_hotplug.h @@ -48,7 +48,7 @@ enum { /* Types for control the zone type of onlined and offlined memory */ enum { /* Offline the memory. */ - MMOP_OFFLINE =3D -1, + MMOP_OFFLINE =3D 0, /* Online the memory. Zone depends, see default_zone_for_pfn(). */ MMOP_ONLINE, /* Online the memory to ZONE_NORMAL. */ --=20 2.24.1