From patchwork Fri Jan 23 20:21:47 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Khoronzhuk X-Patchwork-Id: 43696 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f199.google.com (mail-lb0-f199.google.com [209.85.217.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id D4F04218DB for ; Fri, 23 Jan 2015 20:22:44 +0000 (UTC) Received: by mail-lb0-f199.google.com with SMTP id f15sf5363926lbj.2 for ; Fri, 23 Jan 2015 12:22:43 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=V7I9fgAKHKSKnUhQ2VzfFs3L7myOWyYERmycaU1VRY0=; b=crjjzWAezLlDrtpcLZKH3vULZ+i7mHTGtFspRB8Y3LY4Q/hd5PJTY09S8bmG74BRha TJ62dl3y/VCpIztQxrYHmuYnEiDCr6iyDfiEhMqRRrsP+u/La7Gdy6uFSN2Zd3dsVggB +q2AaHJYPGpe50jhlTvAx9LkeMTZlz9zDOBu/isDI+Kh+VyMyruZJESEXBM3PG3d1aKz 9SqssMJho3xjrHDOiERGGgBfAcCG0hv4AfYK6KCK/JTS0GI1xZmjOVtwPHSYwk7QUNpO jKakxtQH4GxCi5gArAWQhhY58YzSOjr4We9f5VDon0U7eygVurpMk2pGl8QaUCatTanx 2m4w== X-Gm-Message-State: ALoCoQkEpoo72thHqCQvTjlu/89T7EjIYbKIZjB04DwhdC20INOUWq9pU0dTV6MOw6BrQE8L+Bix X-Received: by 10.112.84.226 with SMTP id c2mr1235939lbz.5.1422044563876; Fri, 23 Jan 2015 12:22:43 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.220.164 with SMTP id px4ls311641lac.34.gmail; Fri, 23 Jan 2015 12:22:43 -0800 (PST) X-Received: by 10.112.47.135 with SMTP id d7mr9312530lbn.54.1422044563701; Fri, 23 Jan 2015 12:22:43 -0800 (PST) Received: from mail-lb0-f169.google.com (mail-lb0-f169.google.com. [209.85.217.169]) by mx.google.com with ESMTPS id o5si2254202lae.100.2015.01.23.12.22.43 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 23 Jan 2015 12:22:43 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.169 as permitted sender) client-ip=209.85.217.169; Received: by mail-lb0-f169.google.com with SMTP id f15so8976809lbj.0 for ; Fri, 23 Jan 2015 12:22:43 -0800 (PST) X-Received: by 10.112.44.230 with SMTP id h6mr9241777lbm.98.1422044563566; Fri, 23 Jan 2015 12:22:43 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.35.133 with SMTP id h5csp15609lbj; Fri, 23 Jan 2015 12:22:42 -0800 (PST) X-Received: by 10.66.90.130 with SMTP id bw2mr14259269pab.56.1422044561747; Fri, 23 Jan 2015 12:22:41 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id zn6si3153491pac.126.2015.01.23.12.22.39; Fri, 23 Jan 2015 12:22:41 -0800 (PST) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756620AbbAWUWf (ORCPT + 28 others); Fri, 23 Jan 2015 15:22:35 -0500 Received: from mail-wi0-f179.google.com ([209.85.212.179]:56127 "EHLO mail-wi0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755672AbbAWUWK (ORCPT ); Fri, 23 Jan 2015 15:22:10 -0500 Received: by mail-wi0-f179.google.com with SMTP id l15so5292604wiw.0 for ; Fri, 23 Jan 2015 12:22:09 -0800 (PST) X-Received: by 10.180.39.35 with SMTP id m3mr1542128wik.3.1422044529427; Fri, 23 Jan 2015 12:22:09 -0800 (PST) Received: from khorivan.itg.ti.com (101-172-94-178.pool.ukrtel.net. [178.94.172.101]) by mx.google.com with ESMTPSA id dp8sm3151873wib.20.2015.01.23.12.22.07 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 23 Jan 2015 12:22:08 -0800 (PST) From: Ivan Khoronzhuk To: linux-kernel@vger.kernel.org, ard.biesheuvel@linaro.org Cc: dmidecode-devel@nongnu.org, grant.likely@linaro.org, leif.lindholm@linaro.org, matt.fleming@intel.com, Ivan Khoronzhuk Subject: [PATCH 2/2] firmware: dmi-sysfs: add SMBIOS entry point area attribute Date: Fri, 23 Jan 2015 22:21:47 +0200 Message-Id: <1422044507-22982-3-git-send-email-ivan.khoronzhuk@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1422044507-22982-1-git-send-email-ivan.khoronzhuk@linaro.org> References: <1422044507-22982-1-git-send-email-ivan.khoronzhuk@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: ivan.khoronzhuk@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.169 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , There are situations when code needs to access SMBIOS entry table area, but cannot use /dev/mem for this. As the table format is consistent only for a version, and can be changed, use binary attribute to give access to raw SMBIOS entry table area. Signed-off-by: Ivan Khoronzhuk --- drivers/firmware/dmi-sysfs.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/drivers/firmware/dmi-sysfs.c b/drivers/firmware/dmi-sysfs.c index e0f1cb3..b5c0558 100644 --- a/drivers/firmware/dmi-sysfs.c +++ b/drivers/firmware/dmi-sysfs.c @@ -46,6 +46,8 @@ struct dmi_sysfs_entry { static LIST_HEAD(entry_list); static DEFINE_SPINLOCK(entry_list_lock); +static unsigned char smbios_raw_header[32]; + /* dmi_sysfs_attribute - Top level attribute. used by all entries. */ struct dmi_sysfs_attribute { struct attribute attr; @@ -646,9 +648,37 @@ static void cleanup_entry_list(void) } } +static ssize_t smbios_entry_area_raw_read(struct file *filp, + struct kobject *kobj, + struct bin_attribute *bin_attr, + char *buf, loff_t pos, size_t count) +{ + ssize_t size; + + size = bin_attr->size; + + if (size > pos) + size -= pos; + else + return 0; + + if (count < size) + size = count; + + memcpy(buf, &smbios_raw_header[pos], size); + + return size; +} + +static struct bin_attribute smbios_entry_area_raw_attr = { + .read = smbios_entry_area_raw_read, + .attr = {.name = "smbios_raw_header", .mode = 0400}, +}; + static int __init dmi_sysfs_init(void) { int error = -ENOMEM; + int size; int val; /* Set up our directory */ @@ -669,6 +699,18 @@ static int __init dmi_sysfs_init(void) goto err; } + size = dmi_get_smbios_entry_area(smbios_raw_header); + if (size == -ENODATA) { + pr_debug("dmi-sysfs: SMBIOS raw data is not available.\n"); + error = size; + goto err; + } + + /* Create the raw binary file to access the entry area */ + smbios_entry_area_raw_attr.size = size; + if (sysfs_create_bin_file(dmi_kobj, &smbios_entry_area_raw_attr)) + goto err; + pr_debug("dmi-sysfs: loaded.\n"); return 0;