Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2760077imu; Sun, 27 Jan 2019 12:25:55 -0800 (PST) X-Google-Smtp-Source: ALg8bN4ExVWIu3T08KaXtFp+k9x71nhvQwHVSrn0a8ooSzaYVShEjIVNZ2uQTXIC9kbYtez2AB2V X-Received: by 2002:a17:902:9692:: with SMTP id n18mr19548061plp.333.1548620755857; Sun, 27 Jan 2019 12:25:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548620755; cv=none; d=google.com; s=arc-20160816; b=IGzEbiTJsMB/uxjYSUpiTgKN81j/SeUIx17RVpSKauvgBbCIIGInwUa8sFVx1dI5WR xsA4bzmC8J34pf6EOrvuLj9J4RBzKf6amKMBOLF/Ed4wU05tz/bf2D0NJMMtkwEZLmnO EUfgobAICj2Qg6hTbuwFS7kr003SbQb6nECnUtQpaO+HAa+a5suavK4+CVL/gRU8DZYB 06xunTIENIxRtghDOmiKJ0YUOz64UKyuaSm1aPO3xlI3pkLVLu6JYCkHA2HmQqcpo4SU A8i77g529ra+A7vaCABHmC0Ikfwo3gbShWJhDiDYG9370HHP8x8MAD9D1/sW/ylTu7fy O1sw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=Rin6Z5rxUwQbLP18lUcO/4uxvilt/ro0Og27uir8dDo=; b=YoJHevWm8GVYH+Eo80TIZQLaMOz/EnyjXzG4p+SDLEd7zw6c3GomqRIHS4NV8SdhDk v9Fu0MkaNUhA5We7r/7Vby846PG+BEWbX2OpXBUgH6apAOXw5JO23czA8Afp5Miyr6Tz yn9ZCzTwYoACGqBXPKPLKqPSavXd4oHWSe1syBG5u1IEJpogALyrhr96ytKDCSuaPot1 tytG83/PcZdVm/djLXejCNDesjNAWCdsm5jVB7ufYTiczxL4aKkDr5ILDDR7AYOSJfdG vbslkpMfKSyLG8ta7FaCnsPTbkdkdEELSG5skSDsMis+MTSYjs48iWWhCHiCm/XiYk1q mLCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=nEwWnVVF; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t5si190585pgc.369.2019.01.27.12.25.40; Sun, 27 Jan 2019 12:25:55 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=nEwWnVVF; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727064AbfA0UWq (ORCPT + 99 others); Sun, 27 Jan 2019 15:22:46 -0500 Received: from mail-pl1-f193.google.com ([209.85.214.193]:37326 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726566AbfA0UWq (ORCPT ); Sun, 27 Jan 2019 15:22:46 -0500 Received: by mail-pl1-f193.google.com with SMTP id b5so6801001plr.4; Sun, 27 Jan 2019 12:22:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Rin6Z5rxUwQbLP18lUcO/4uxvilt/ro0Og27uir8dDo=; b=nEwWnVVFWs1LIz/UZtT219J3FW60hpIKB1EZyqX/k1RCpztyUG/rjm1SdM7qtresdC FzjBRgAVbE5t0d7uRdGNXGBblznRBxEqH/8zywCl8RAfbL4g9bS0zYtLq4DtAwhyf8Oj tHkfonfwizjwwpH/ZjCv3tQiCn8aAqtaIOqoP1t4zWvLjWws/rNFIAoXR2Kgm+dpCiX+ fAlPEWoO0opVkduNMF7efKyymPxDoj9qrVnIDe8qUX/f9ACLZnLV0CZTLB6qUZBbcIic C7U1oljrXjJQl+rl8HRLYFRrx0TzBE7WdT29Qow2ExYUEI/vEZptQgmfskZlbNfIhtS9 Wpwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Rin6Z5rxUwQbLP18lUcO/4uxvilt/ro0Og27uir8dDo=; b=bdk+Ef+Sp0SHAsWHm3UpeGHz+1qK9O6XCNa5HL5h1V3GCuS/kMBc7NDAq4R54bQYLc crCFiGt5ZN28CMs6Yy7C1YoG8otayIiX8WhkQejCHR8yYrJMUMvd4klABlElzgIO3I6s CRmm6UYMjDTIDxlOyZlHOoPyWJtQ9HH/aWznbE1oT30IvTBXObDCIk5kyNYe/Ck3zc0O icacxT6GFlTAq5aD60ziHo7bUlH69+VLNVScIROmonqopEt7twLd2ITLn114RUBYjEXk nmHM2qxTZTcZMxPNcOOqYESzWPvon3zGd9pGMubIXBFjyCKXLT4wCltRoaeshsoLbbKJ GtJA== X-Gm-Message-State: AJcUukfeC3k5xmozF1SjMYYgKwoB/ql9lOI+o+mtm1ev65V6sbOJJdi7 DmTfzOJNNcIBQBK0q7+ZpqAExxq6/tHXy5bq6QU= X-Received: by 2002:a17:902:112c:: with SMTP id d41mr18546638pla.144.1548620565797; Sun, 27 Jan 2019 12:22:45 -0800 (PST) MIME-Version: 1.0 References: <680df320c7263bdd35f87794ae12fb9a9ef3b71c.1548610407.git.2pi@mok.nu> In-Reply-To: <680df320c7263bdd35f87794ae12fb9a9ef3b71c.1548610407.git.2pi@mok.nu> From: Andy Shevchenko Date: Sun, 27 Jan 2019 22:22:34 +0200 Message-ID: Subject: Re: [PATCH v2 2/3] platform/x86: wmi: add WMI support to MODULE_DEVICE_TABLE() To: Mattias Jacobsson <2pi@mok.nu> Cc: Masahiro Yamada , michal.lkml@markovi.net, Darren Hart , Andy Shevchenko , =?UTF-8?Q?Pali_Roh=C3=A1r?= , Platform Driver , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 ? > + warn("Could not generate all MODULE_ALIAS's in '%s'\n", > + filename); > + return 0; > + } > + return 1; > +} -- With Best Regards, Andy Shevchenko