Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp4071083yba; Sun, 19 May 2019 10:02:19 -0700 (PDT) X-Google-Smtp-Source: APXvYqwHXBf+wDwQBdLVvCgnxdXPXqc6KrMc7I63vnIiB/tAI4Yv9Cnd7PpCSz3bhTUiZwvUG7/m X-Received: by 2002:a17:902:683:: with SMTP id 3mr27941941plh.209.1558285339541; Sun, 19 May 2019 10:02:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558285339; cv=none; d=google.com; s=arc-20160816; b=oENZCVkGxBhD6DWD1Jx8E0WOxKXhBYQsRKcgX1k9JBUvurIpUzEXo1N0xJRnuCSjXn U95giItZKu8vuZiKVJW1DtI4weKCVtTZF32ClsYNW4IFZ/8FJ0cc0R54Lns9RwoiM8bX 26Az57hHGxVi5/sNLFsjQID/CjfUIu4DTBpUsS3kxeo8pWPC78MWhKLS+4GGPLqMQQis MXKvF/qR632VkcxT5VBadxz5DtB6ZP7wkglPnGPIYQ2H1/BVxUI3nHWus6+LpfFrZT3Z tn+hp8Ssraer6ZlzNIIo9cM8tDuxCzUGdrpMAKET2mQV5YGoNCQG0xi4GTy8frC3UIcC E/UQ== 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 :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=A1n1CjcQuzFovnLXkGWwcRiXTwu+AIfhlD3hc8BsEJY=; b=m8IifE/ONXDd7RUdIotandKNhHQgB33nHc9kcVpFtsSvvIYW7M3x5u0Rj6c3R34qxF LvQEXNogq5d3jt1647SNQ2H7YtXKPDdKYI/OEFKw5JBVU2zjQEZy4unF+HhWz/gYEeO5 hKzJczbwNixNgFzSmuWuRGLiYmgL6jWq7ZWYc9Rwv1bT6SJLLdAx4K61fyI6ly86p5qT CwQcUnLLCjF6hmPEY44/0WcU2+00zbAN8d5hL2RjVoNJuAgeopokhMaVeBQZL89TmNKA FUEypWpX71TnEvnAjbz83D2M991330MFbbaNs2AYE7QISkaCHuzYyFxxnxYFGugCxfQd 4wEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=SfbqQ7UR; 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=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b17si4659000pls.52.2019.05.19.10.01.26; Sun, 19 May 2019 10:02:19 -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=pass header.i=@kernel.org header.s=default header.b=SfbqQ7UR; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726066AbfESQ5W (ORCPT + 99 others); Sun, 19 May 2019 12:57:22 -0400 Received: from mail.kernel.org ([198.145.29.99]:55164 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725993AbfESQ5W (ORCPT ); Sun, 19 May 2019 12:57:22 -0400 Received: from archlinux (cpc91196-cmbg18-2-0-cust659.5-4.cable.virginm.net [81.96.234.148]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C32E521743; Sun, 19 May 2019 11:00:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1558263634; bh=N2AfJUm5S/n9kNq0ukcJ2NfhgtOc6Fh2mApK13sY1b0=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=SfbqQ7URvAiUBaaGq9YorAgNZZLsiTxuY5c9iLHuYslS1D7htpDvUt3W57XB0XUoH 0zjJ5/Zn7wODiPbFk+6Y6AZPCjsSKyhLMq0tDxtQQqeAEL7ooS1e4Q1o+OeXJ63eH3 dODoRh9i8LZw9gAe42T6vDok5ihEq3zYXmkwhELo= Date: Sun, 19 May 2019 12:00:29 +0100 From: Jonathan Cameron To: Lucas Oshiro Cc: Lars-Peter Clausen , Michael Hennerich , Stefan Popa , Hartmut Knaack , Peter Meerwald-Stadler , Greg Kroah-Hartman , linux-iio@vger.kernel.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, kernel-usp@googlegroups.com, Rodrigo Ribeiro Subject: Re: [PATCH v2] staging: iio: adis16240: add device to module device table Message-ID: <20190519120029.1da8f41c@archlinux> In-Reply-To: <20190518214434.23660-1-lucasseikioshiro@gmail.com> References: <20190518214434.23660-1-lucasseikioshiro@gmail.com> X-Mailer: Claws Mail 3.17.3 (GTK+ 2.24.32; x86_64-pc-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 On Sat, 18 May 2019 18:44:34 -0300 Lucas Oshiro wrote: > Add a of_device_id struct and MODULE_DEVICE_TABLE call, in order to add > device-tree support for this driver. > > Signed-off-by: Lucas Oshiro > Signed-off-by: Rodrigo Ribeiro > Co-developed-by: Rodrigo Ribeiro Hi Lucas, Rodrigo, The description isn't 100% accurate but it's close enough. Ever since devicetree was introduced, there has been a fallback mode for i2c and spi devices in which, in the absence of either a devicetree match table or an ACPI one, an attempt is made to match against the older i2c_device_id table entries. So it'll 'work' for devicetree bindings without this patch, but by a less controlled route and one that doesn't allow for the possibility of multiple manufacturers using the same part number. Hence these are good changes to make. Simplifying the description to enabling devicetree probing is fine though. Under drivers/spi.c, devices probed via a device tree binding use: of_register_spi_device (applied to all children of an spi bus, so the slave devices). This calls of_modalias_node which performs a copy of the compatible without the manufacturer ID into the modalias field. Later, spi_match_device is called, which first attempts of_driver_match_device which I think does the precise match. If that fails, it tries ACPI, and failing that it falls back to matching the modalias against the id_table entries. Thus it can still work without these entries but they do make it simpler and more consistent. Applied to the togreg branch of iio.git and pushed out as testing for the autobuilders to play with it. Thanks, Jonathan > --- > drivers/staging/iio/accel/adis16240.c | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/drivers/staging/iio/accel/adis16240.c b/drivers/staging/iio/accel/adis16240.c > index b80e0d248b0f..8c6d23604eca 100644 > --- a/drivers/staging/iio/accel/adis16240.c > +++ b/drivers/staging/iio/accel/adis16240.c > @@ -435,6 +435,12 @@ static int adis16240_remove(struct spi_device *spi) > return 0; > } > > +static const struct of_device_id adis16240_of_match[] = { > + { .compatible = "adi,adis16240" }, > + { }, > +}; > +MODULE_DEVICE_TABLE(of, adis16240_of_match); > + > static struct spi_driver adis16240_driver = { > .driver = { > .name = "adis16240",