Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp4314457ybp; Mon, 14 Oct 2019 02:40:02 -0700 (PDT) X-Google-Smtp-Source: APXvYqyCWurYQfmSlGm5aoq1vw5RPCdOOO7EfbdbaCq3D39XUldTebPZqUw9TLW5DD2pBpvE0KTo X-Received: by 2002:a17:906:fca8:: with SMTP id qw8mr28324442ejb.188.1571046002796; Mon, 14 Oct 2019 02:40:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571046002; cv=none; d=google.com; s=arc-20160816; b=FVP3mWTVyggN9QG/Fv8Ms5i5+LhBPR/8wgI9y1YYJ8vBaZe0d5mkgYLBcAYBP/W/ev /0S0p2mO67wlE1iuQWAZiaAzGrVtD7f2CqgH+L5SUA6E9dP66cNi3hpmlU3eTeToJr5k 41aHfx73sZ9RnCYaoswUlHax5KC8aq9PWj743pcU9owUpsWWubsbDRf1+7Srgdt+xtLW jtv1KQc4wxfa3ITmdlP/+mmb6+Mt/oP0236w1l/ESdQqtjomd5U9lD7Lb/jyV6YJIP35 9W5FtoxWm6UU4saK4DZRDPyAFOaKp3HAFKIvMMUM5qICaB319YrFi8OuKQ/+ki4iEEyj Ycdw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date; bh=OIpbXox6wT/VBHKiyVk2277H0ZChSVDMN4PirjWqklw=; b=DtnYsB5IuF4Ch5L2k/OeG4+6Dr+YOP1FQK4oT81hYMYKMnzm0v7zflSHqjsB1K5boN E91i0boWZ/Hdy4WP24kJCp40c5DLqcwiGTJN3s4XIjgZSvO805ingMqmguVUk67qq9Ug CdJjym30h72fO1CO+6mKrlvnAPrYcAjZgUO+4Cqe2/Bo/8C3qhJVebtVOvOb6MtU/WpP Ezz0V0ng80IqCXrHSsbcK0oZnYSNFQp+E1Ms1B4p55YPW4SanLNiV3/FFK5PmKfmuz2W I3MzjNlwrngTVVhpVss1DluFzwoKWbhF0zGtgxvS+e5ia7G8vMhiQv2stbAfUFkcV/8F XYPw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b12si12629449edk.16.2019.10.14.02.39.39; Mon, 14 Oct 2019 02:40:02 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731035AbfJNJin (ORCPT + 99 others); Mon, 14 Oct 2019 05:38:43 -0400 Received: from mx2.suse.de ([195.135.220.15]:55162 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1730872AbfJNJin (ORCPT ); Mon, 14 Oct 2019 05:38:43 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 7AB86BD30; Mon, 14 Oct 2019 09:38:41 +0000 (UTC) Date: Mon, 14 Oct 2019 11:38:57 +0200 From: Jean Delvare To: Linux I2C , LKML Cc: Wolfram Sang Subject: [PATCH 2/4] firmware: dmi: Add dmi_memdev_handle Message-ID: <20191014113857.1166bef6@endymion> In-Reply-To: <20191014113636.57b5ce89@endymion> References: <20191014113636.57b5ce89@endymion> Organization: SUSE Linux X-Mailer: Claws Mail 3.17.3 (GTK+ 2.24.32; x86_64-suse-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add a utility function dmi_memdev_handle() which returns the DMI handle associated with a given memory slot. This will allow kernel drivers to iterate over the memory slots. Signed-off-by: Jean Delvare --- drivers/firmware/dmi_scan.c | 16 ++++++++++++++++ include/linux/dmi.h | 2 ++ 2 files changed, 18 insertions(+) --- linux-5.3.orig/drivers/firmware/dmi_scan.c 2019-10-10 11:33:02.871034637 +0200 +++ linux-5.3/drivers/firmware/dmi_scan.c 2019-10-10 11:45:37.275549638 +0200 @@ -1151,3 +1151,19 @@ u8 dmi_memdev_type(u16 handle) return 0x0; /* Not a valid value */ } EXPORT_SYMBOL_GPL(dmi_memdev_type); + +/** + * dmi_memdev_handle - get the DMI handle of a memory slot + * @slot: slot number + * + * Return the DMI handle associated with a given memory slot, or %0xFFFF + * if there is no such slot. + */ +u16 dmi_memdev_handle(int slot) +{ + if (dmi_memdev && slot >= 0 && slot < dmi_memdev_nr) + return dmi_memdev[slot].handle; + + return 0xffff; /* Not a valid value */ +} +EXPORT_SYMBOL_GPL(dmi_memdev_handle); --- linux-5.3.orig/include/linux/dmi.h 2019-10-10 11:33:02.871034637 +0200 +++ linux-5.3/include/linux/dmi.h 2019-10-10 11:34:46.146337207 +0200 @@ -114,6 +114,7 @@ extern bool dmi_match(enum dmi_field f, extern void dmi_memdev_name(u16 handle, const char **bank, const char **device); extern u64 dmi_memdev_size(u16 handle); extern u8 dmi_memdev_type(u16 handle); +extern u16 dmi_memdev_handle(int slot); #else @@ -144,6 +145,7 @@ static inline void dmi_memdev_name(u16 h const char **device) { } static inline u64 dmi_memdev_size(u16 handle) { return ~0ul; } static inline u8 dmi_memdev_type(u16 handle) { return 0x0; } +static inline u16 dmi_memdev_handle(int slot) { return 0xffff; } static inline const struct dmi_system_id * dmi_first_match(const struct dmi_system_id *list) { return NULL; } -- Jean Delvare SUSE L3 Support