Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp2596893ybc; Mon, 18 Nov 2019 01:28:24 -0800 (PST) X-Google-Smtp-Source: APXvYqzVCX+EfzkH3qbXP1MBEnqxqi29TIOZIxbPBN+6fPm15xq+apmmjmBbQv52YW/g1yfmx8tc X-Received: by 2002:a17:906:2505:: with SMTP id i5mr4600540ejb.18.1574069304677; Mon, 18 Nov 2019 01:28:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574069304; cv=none; d=google.com; s=arc-20160816; b=iCKXDNJR3aAM7p0Wi603Crzu9IdB3rGN1rQeRCZefpPBVPK77f0/BWD2P/Q938PQRM DZuBYEHBtoYrsP6sxR2aZ/ZT7iPi/GA0+H9j0BNVlu3eGZB/CueGHG1gV3qByjf2pDWx ir+H2C+Y2TZKBgcbAhk0abuixGJ+7CaXcOYd9/2okiElciSvkVFuiZb7mPEjUXLBs/kH i2SyBOV4g/zrZrgatfZDbfZaiT102zAIosBTCXXAULQSXq1DVneApU7ZU3GHfwI0gUlt DGzv/kchh7KAHRe7TGZBnE+OfMfS3fCtQSNyHYsW9HVMyj8qrUdIfuM9jAi7uxumfk0g j+3A== 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=B3pNvCIngnKK433Ea1IV1b/NuDnGj2Ezzamhwbw320E=; b=nm/ZC0PQRiKe1yNR9ohlFdbn7XisXcI/6eMeeQjJIG3B2QVkrob7z/eimESxqdf88/ MEPGciL5XzwkDD1BKXwyGwcOx1SfRiWFPY11MAXzCAE6E87nq6FZTjX1fzHDXN1Ltz87 6BEUSpnUMyznzKFG9fa9gco2SzaZPFLY+jNajGDm08tKf4JW0QarpUItnq8uKFu2can8 SpS02CvO4Mc1Z0PsRrFgjapV5HPpNA0ft+X+FpMAnqnV+9yYhPC21PSZiUnQflChNTMY Lx15ze0b3bCtLu9TJL+No8MIZRoRsADd1TgGjEWJAXvWsR9cSujHZgAKDo5r+HOw1k0R BtfQ== 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 u15si10921603ejb.120.2019.11.18.01.28.01; Mon, 18 Nov 2019 01:28:24 -0800 (PST) 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 S1726760AbfKRJ0J (ORCPT + 99 others); Mon, 18 Nov 2019 04:26:09 -0500 Received: from mx2.suse.de ([195.135.220.15]:56452 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726460AbfKRJ0J (ORCPT ); Mon, 18 Nov 2019 04:26:09 -0500 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 DCDD6AC4D; Mon, 18 Nov 2019 09:26:07 +0000 (UTC) Date: Mon, 18 Nov 2019 10:26:06 +0100 From: Jean Delvare To: Linux I2C , LKML Cc: Wolfram Sang Subject: [PATCH 2/4] firmware: dmi: Add dmi_memdev_handle Message-ID: <20191118102606.6dbccfdf@endymion> In-Reply-To: <20191118102410.78cd8e6e@endymion> References: <20191118102410.78cd8e6e@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