Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3507443imu; Mon, 28 Jan 2019 06:09:57 -0800 (PST) X-Google-Smtp-Source: ALg8bN4aXjdpahnP0S3K/STUlTQZ7+fiKhfRnwieC00VGPWo9Izn4cWqx11rpnnK4V8cdHhsaMLE X-Received: by 2002:a62:61c3:: with SMTP id v186mr22247526pfb.55.1548684597211; Mon, 28 Jan 2019 06:09:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548684597; cv=none; d=google.com; s=arc-20160816; b=I12Y6X87jKFNgUvaVEwoxsUH465sUnhckzBFqVAJZnm4eDxr/7O+cRC7SPr0vt7vjt XoWsekThMlr4iHDm+i7KEO8DmAcnyVdUlufpIyeF/3t5++yyTNzppGj3qteLpQ/oxb8F EmWK3m3VDccq1CIarl/K9OAnowDCt3BQ38t83b6kgnkR6TGqnKYM/SPpwQQkOYfpkaW2 IWOXraZXC95wpTq0Mrxi9+qSqRBzS3hZ3Et9K4DRFQrbySonT6cfewDqLr06kfZqD7EM wI06b/Wtp4xedXpJ3YPU+zk7kFTRSGtj2FH9kpTbNngVrM/gCKRFPTIae73bVHU6+L1O cL9Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=31wn6j6UBdZaSTs6Df8NNT0GITbprEjdoqmucVMYwbo=; b=1C7mUPT6PXXx7DBGjKNmJZkF9k2p+EAH34Fb9mLmQoJ3fwG/PgsrYdChDjfZtjwBZF kuZUYs38A7mKPTGRK/yS19bPQm4C2afopa22FjoELFi1M+mI55Ud9bXUU3I2zJ2zk24z uhc+u22yQXJjN95y0c+dhusg/a9/4UxQJ/dLbMob2G7v8SWfJrv2aw7/kO8N86qX9/0G reXS6pVSktDRPq4jukysDOopXlSCHDem08DjA/yrHcKLR1u+H9NSjXT75V/01A7oRTUQ PATzBfbeGSFf3DuGDGSJMvfqkvvcN3wTCtjDd+1rDjALM4QaXWL8zaeEDWgJCSwcZ2uF KJJQ== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mok.nu Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b60si32889887plc.95.2019.01.28.06.09.40; Mon, 28 Jan 2019 06:09:57 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mok.nu Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726766AbfA1OJ1 (ORCPT + 99 others); Mon, 28 Jan 2019 09:09:27 -0500 Received: from route-level1.fsdata.se ([89.221.252.216]:51266 "EHLO route-level1.fsdata.se" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726647AbfA1OJ1 (ORCPT ); Mon, 28 Jan 2019 09:09:27 -0500 Received: from DAG01.HMC.local (192.168.46.11) by EDGE01LEVEL1.hmc.local (192.168.46.33) with Microsoft SMTP Server (TLS) id 15.0.847.32; Mon, 28 Jan 2019 15:09:18 +0100 Received: from localhost (94.234.46.36) by DAG01.HMC.local (192.168.46.11) with Microsoft SMTP Server (TLS) id 15.0.1263.5; Mon, 28 Jan 2019 15:09:16 +0100 Date: Mon, 28 Jan 2019 15:09:11 +0100 From: Mattias Jacobsson <2pi@mok.nu> To: Andy Shevchenko CC: Masahiro Yamada , , Darren Hart , "Andy Shevchenko" , Pali =?utf-8?B?Um9ow6Fy?= , Platform Driver , Linux Kernel Mailing List , <2pi@mok.nu> Subject: Re: [PATCH v2 2/3] platform/x86: wmi: add WMI support to MODULE_DEVICE_TABLE() Message-ID: <20190128140911.xsltdctpk3bya7ya@mok.nu> References: <680df320c7263bdd35f87794ae12fb9a9ef3b71c.1548610407.git.2pi@mok.nu> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: X-Originating-IP: [94.234.46.36] X-ClientProxiedBy: PROXY04.HMC.local (192.168.46.54) To DAG01.HMC.local (192.168.46.11) Received-SPF: Neutral (EDGE01LEVEL1.hmc.local: 192.168.46.11 is neither permitted nor denied by domain of 2pi@mok.nu) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On 2019-01-27, Andy Shevchenko wrote: > On Sun, Jan 27, 2019 at 9:04 PM Mattias Jacobsson <2pi@mok.nu> wrote: > > > > The kernel provides the macro MODULE_DEVICE_TABLE() where driver authors > > can specify their device type and their array of device_ids and thereby > > trigger the generation of the appropriate MODULE_ALIAS() output. This is > > opposed to having to specify one MODULE_ALIAS() for each device. The WMI > > device type is currently not supported. > > > > While using MODULE_DEVICE_TABLE() does increase the complexity as well > > as spreading out the implementation across the kernel, it does come with > > some benefits too; > > * It makes different drivers look more similar; if you can specify the > > array of device_ids any device type specific input to MODULE_ALIAS() > > will automatically be generated for you. > > * It helps each driver avoid keeping multiple versions of the same > > information in sync. That is, both the array of device_ids and the > > potential multitude of MODULE_ALIAS()'s. > > > > Add WMI support to MODULE_DEVICE_TABLE() by adding info about struct > > wmi_device_id in devicetable-offsets.c and add a WMI entry point in > > file2alias.c. > > > > The type argument for MODULE_DEVICE_TABLE(type, name) is wmi. > > > +/* Looks like: wmi:guid */ > > +static int do_wmi_entry(const char *filename, void *symval, char *alias) > > +{ > > + DEF_FIELD_ADDR(symval, wmi_device_id, guid_string); > > + if (strlen(*guid_string) != WMI_GUID_STRING_LEN) { > > + warn("Invalid WMI device id 'wmi:%s' in '%s'\n", > > + *guid_string, filename); > > + return 0; > > + } > > > + if (snprintf(alias, 500, WMI_MODULE_PREFIX "%s", *guid_string) < 0) { > > What the point to use snprintf here with arbitrary buffer size if we > exactly know 2 facts: > 1. UUID string is 36 characters > 2. buffer is long enough > > ? As long as no one changes the code, not much. > > > + warn("Could not generate all MODULE_ALIAS's in '%s'\n", > > + filename); > > + return 0; > > + } > > + return 1; > > +} > > -- > With Best Regards, > Andy Shevchenko Thanks, Mattias