From patchwork Wed May 17 19:56:23 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corey Minyard X-Patchwork-Id: 100008 Delivered-To: patch@linaro.org Received: by 10.140.96.100 with SMTP id j91csp392131qge; Wed, 17 May 2017 12:56:59 -0700 (PDT) X-Received: by 10.99.109.9 with SMTP id i9mr523417pgc.56.1495051019747; Wed, 17 May 2017 12:56:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1495051019; cv=none; d=google.com; s=arc-20160816; b=0ip9v5+SWzoJNK63iakJ3nUN1eaFlacsbObdrP9btJMTwK/jaRW4oMeWBQiPxC2VGl 4UIVgix4zUU3zzFGa2dVuJHbvip/c1Mrau2sfYmGUE4BiwFviaNJNW5l3m4mdPjLaqTx 4UzpMGXtvwOye3oJgjGtOM5fuDgVHkYLECtkbCR0isndk6e3dBfW71F4NY9ef6eocima /07JYF5r1ESM7zAbfD+yWz5fGFTyb3Ri72WkUdePxwQY5lRwoLiPYCcGYIx0e6PhRZSr Kk8uDwmXT+C05rya2/mhkiB3jHMaTcbmxXZCQuVRZtDKjJYGFndwh4cyQ+p6H3HxlFOU MhZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=Us5Mui4B3DBZqB/EBuV1NrwqzYeKniGPrWDeK4I37Bk=; b=OPsc1wqOkS+qzyDWjgh/ec1X4Cf1+zUyoThEqCKkZQXuTprRfYLA8y6O7BO0a0YTOA wnMFTnpEh7jJgB53afFezXq0G1G8DBDL9OQjwfqXC66UoJ85CHqgplo2hlrGtc9f20CP +sJmhYFDQ6Xp4bLT1oJmDop5Dafq/xGRJQ2rr+P/Cwaetb+r9KDPP1Z1ni6Fz6MRRatY F0RbVg6rTXl7S3he1B2lH1cYGL+jyIZSDnNP09TcRDYODcCSl6jrkpZYUx+VWvODliPb 5F7QLIX0K4GRkcPM8ZbpgZmSCZHEdT42dxQ62qBQgiHokwEU+4r5idupLa0xa0nCJGte WNtA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.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 l10si2972162pln.71.2017.05.17.12.56.59; Wed, 17 May 2017 12:56:59 -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; dkim=fail header.i=@gmail.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 S1753763AbdEQT4k (ORCPT + 25 others); Wed, 17 May 2017 15:56:40 -0400 Received: from mail-oi0-f65.google.com ([209.85.218.65]:35393 "EHLO mail-oi0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753140AbdEQT4f (ORCPT ); Wed, 17 May 2017 15:56:35 -0400 Received: by mail-oi0-f65.google.com with SMTP id m17so3899974oik.2 for ; Wed, 17 May 2017 12:56:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=Us5Mui4B3DBZqB/EBuV1NrwqzYeKniGPrWDeK4I37Bk=; b=Uatu+R5vTmEpz7b/qWB9/hdpKJybD0qmOKpCkKUAag5wiR6qlInwI6PmwEltqEnydk vDdQvaJV3cqvq0jZ4YzGlLzgOHaK13CGW7Sp1XwOyRdZSF8LVFGdHo7DH8ng9C/YTrJG rvFmGIKkm3rDdkeHdZJSopT6NUEY2Dl+JQOzIjyaJ0JhVPVjDwfDqipPPJ1nt4N+a1mZ QLqG6gWvZTgE8U1y1SPFnjd97pkS2nASSed+aoLjAWdcv7biSt9or1yV0ruBR3+kubDN ymJztRnNeZVK25zBs/HXM38bJTQadKGkmc+AwKC+PZE5rnN+RiWxRkjAhUbvONU9FRla HH4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=Us5Mui4B3DBZqB/EBuV1NrwqzYeKniGPrWDeK4I37Bk=; b=T3UONZ5YLJn6BHrJt3OdnT82/8h08BuM6rGXIko5Dkv6aJEEZbQzJ3laaZu2TlaBQw YoBKhRjEDRX6xutZToYpFHqUXbovKuxjYB0T87ZG5xEKBJPA5G1+mXYC5UDvJFbzAOj/ +JSCdvMsAwiJP8Vxn2uD7GDr+3bt3DiBS8wrFMkOLh+tS39z7b1CCBxHF4OmR12oq0ZY XSclcFfxBjM4sYfO0T/3ndbxaZdtsuuj/bhpdj4TrJZF6kWzGdMsC0kwLTExbOz7Gbyg U7jIifo7m0/R1f8qWte71L1su3bgpWn4bHxdLLAqD+yRQB04GSIRoo3YttYmaUup35TY LMYw== X-Gm-Message-State: AODbwcC80BzC5vxMTkp1G44YsBbMIDOBh6akkWrCoNUdgHujV8MR3b5A L+GEi+ESQtI7hg== X-Received: by 10.157.11.34 with SMTP id a31mr355673ota.114.1495050994403; Wed, 17 May 2017 12:56:34 -0700 (PDT) Received: from serve.minyard.net ([47.184.154.34]) by smtp.gmail.com with ESMTPSA id p27sm1533935otp.57.2017.05.17.12.56.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 May 2017 12:56:33 -0700 (PDT) Received: from t430.minyard.net (t430m.minyard.net [192.168.27.3]) by serve.minyard.net (Postfix) with ESMTPA id 8AADC130E; Wed, 17 May 2017 14:56:30 -0500 (CDT) Received: by t430.minyard.net (Postfix, from userid 1000) id DF48B300037; Wed, 17 May 2017 14:56:28 -0500 (CDT) From: minyard@acm.org To: Jean Delvare Cc: openipmi-developer@lists.sourceforge.net, linux-kernel@vger.kernel.org, Andy Lutomirski , Corey Minyard Subject: [PATCH v5 4/5] dmi: Add IPMI DMI devices as platform devices Date: Wed, 17 May 2017 14:56:23 -0500 Message-Id: <1495050984-5602-5-git-send-email-minyard@acm.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1495050984-5602-1-git-send-email-minyard@acm.org> References: <1495050984-5602-1-git-send-email-minyard@acm.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Corey Minyard Have DMI create a platform device for every IPMI device it finds. Signed-off-by: Corey Minyard Cc: Jean Delvare Cc: Andy Lutomirski Tested-by: Andy Lutomirski --- drivers/firmware/dmi_scan.c | 55 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 53 insertions(+), 2 deletions(-) -- 2.7.4 diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c index 96c0743..211e111 100644 --- a/drivers/firmware/dmi_scan.c +++ b/drivers/firmware/dmi_scan.c @@ -7,6 +7,7 @@ #include #include #include +#include #include #include @@ -783,6 +784,52 @@ static ssize_t raw_table_read(struct file *file, struct kobject *kobj, return count; } +static void __init dmi_add_platform_ipmi(struct dmi_device *dev, int *nr) +{ + struct platform_device *pdev; + struct dmi_dev_ipmi *ipmi_dev = to_dmi_dev_ipmi(dev); + int rv; + + if (!ipmi_dev->good_data) { + pr_err("dmi: Invalid IPMI data, not creating platform device"); + return; + } + + if (ipmi_dev->type == IPMI_DMI_TYPE_SSIF) + pdev = platform_device_alloc("dmi-ipmi-ssif", *nr); + else + pdev = platform_device_alloc("dmi-ipmi-si", *nr); + if (!pdev) { + pr_err("dmi: Error allocation IPMI platform device"); + return; + } + if (ipmi_dev->type == IPMI_DMI_TYPE_SSIF) + pdev->driver_override = "ipmi_ssif"; + else + pdev->driver_override = "ipmi_si"; + + pdev->dev.fwnode = &dev->fwnode; + rv = platform_device_add(pdev); + if (rv) { + dev_err(&pdev->dev, "dmi: Unable to add device: %d\n", rv); + platform_device_del(pdev); + return; + } + + (*nr)++; +} + +static void __init dmi_add_platform_devices(void) +{ + struct dmi_device *dev; + int nr_ipmi = 0; + + list_for_each_entry(dev, &dmi_devices, list) { + if (dev->type == DMI_DEV_TYPE_IPMI) + dmi_add_platform_ipmi(dev, &nr_ipmi); + } +} + static BIN_ATTR(smbios_entry_point, S_IRUSR, raw_table_read, NULL, 0); static BIN_ATTR(DMI, S_IRUSR, raw_table_read, NULL, 0); @@ -823,9 +870,13 @@ static int __init dmi_init(void) bin_attr_DMI.size = dmi_len; bin_attr_DMI.private = dmi_table; ret = sysfs_create_bin_file(tables_kobj, &bin_attr_DMI); - if (!ret) - return 0; + if (ret) + goto out_remove_bin_file; + + dmi_add_platform_devices(); + return 0; + out_remove_bin_file: sysfs_remove_bin_file(tables_kobj, &bin_attr_smbios_entry_point); err_unmap: