Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp442702imu; Wed, 16 Jan 2019 01:33:20 -0800 (PST) X-Google-Smtp-Source: ALg8bN7ytpM9qALzpZcNZR9dvvxlwKgs/SLHnTJBzae52f2gFlV6VDzigzfiSpOfUjrSSS1mevVW X-Received: by 2002:a63:b94c:: with SMTP id v12mr7900362pgo.221.1547631200025; Wed, 16 Jan 2019 01:33:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547631200; cv=none; d=google.com; s=arc-20160816; b=0lW/P0y00Y3F0QexVeSn8NIsijhJbdGEWmIhHCljn3ctByJ/ciDDGWuHXuJpB+hPOn TMHiGzTKDRtE83Ls75jmNcWWmkAPYvYR+8rRcRw3JgJt+QjhyUy2XbSZYCAQsbcuTQZl 6oBMg3tzs2Ue2/V5YbbcScxGOw99h0ZVEBwfYWtAKWR/8nlsrj3AHKrsVrHlLctVEPxP g12jQD6mFk7vjQ4JO8bFJwmQyO8t1J5kBxTiz+xQuPt1l10LEE0pgE7jHXysfbmQANE0 nfhhXBmv1HZ4b/h74K9dOjuYkHkeeZODe1DcDeIkkLe3fxdo5hCgWflTg57uKFf5m8D4 SKTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=1gNo1y+dIxdHxK499SDgABwOKeUfhKYaZKkqSCe+rf4=; b=O68p4uTEjWcHCj4ghhHqME2t7alLhcRKBXjv2NR+RuVvI82YIXyUc7oKAnULkZdINh z0rnvc8ngTbkIl4DjpZj7J35tND+FO2B7WDybUjsG5bt/4qzlhtOFGVf9p4KB29W2++X eDaGWe/6ANGSyBEHM2AVVrhfKv0ndiRFgLE6iVYS+gfBh3n4Z8qM8aWCza1hPEPN+8Vi vh+MissD5Oyhc+fZv8blo9y/S3R56OTpJCoJ8v/pHlJPd2ZVFXeLDDYkO7cJyN8ZJXip TVPUFwjI21tdil+2Pb0ohWheQ2WByXBJ444Ir4Qej5GzP9cYiHRgvfLcY+3257/X5oOx sYMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=iODOvuAu; 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 k33si5412606pgb.424.2019.01.16.01.32.53; Wed, 16 Jan 2019 01:33:20 -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=iODOvuAu; 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 S2388870AbfAOSl1 (ORCPT + 99 others); Tue, 15 Jan 2019 13:41:27 -0500 Received: from mail-pf1-f196.google.com ([209.85.210.196]:43699 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728911AbfAOSl1 (ORCPT ); Tue, 15 Jan 2019 13:41:27 -0500 Received: by mail-pf1-f196.google.com with SMTP id w73so1707672pfk.10; Tue, 15 Jan 2019 10:41:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=1gNo1y+dIxdHxK499SDgABwOKeUfhKYaZKkqSCe+rf4=; b=iODOvuAu3JkhXkG6MXxTyFvyVHwfFVnHU2l70XnVe7pBdNhWkLeFtQIwqNmPkqSPeX 0q9LtUlF1oUFIB9KykYBP4AycK2D5Q0+O03MkfpJ8+vnWhv9D/bXgJllM9nbh6EhfRzT tAbdnhlkbwfSNDP3Yt9i6OJwdUicuUM6eLoJ/TzU0eLIOtgr3fv5escB8850S1adnFHQ Dxx2hRpNzh7rrW3/y3WTLlxw9PH8TS/lT6dTU+ugdWBAkN+pvt/C4Fc2uoN5MdbsLH58 vSUugz2yuYHyvnfOXIkRxV/RXbj/8taGld/7aUVHFnSFBOC6sjJEEZGbj9vvZY84Gi4K zSyw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=1gNo1y+dIxdHxK499SDgABwOKeUfhKYaZKkqSCe+rf4=; b=Rrhi2KFaHPsMyK2frjMPbytI0QX3phK6AETU2c4yLchmpwJhTcNnbTm0JeAjOe/Vz6 2bm9/XL1Y/guJWuQhDAlYTqWBgUh1PDqvh1o5XfkszupsukfXj6pfGKIlb1OS2+5yGGD pigY0lSlbvaX2gqSgoDC7vcviVlrsLcsfDjfTBr1BwaMF2fWaZAYIoE50IRrk0yTR/Lc XysPAhn6R6fh4ravnK3anZreBz3O6+XBkPTT0IC3ZTlDn+bkER4d8D3bcnKGzEtV0RoO V6vAya154uxhMDLR2BkamdJb1bT5rPzhHtZ9/CVLZGkun9Yl8XPb4/kxR1kteoSOsZKH WP8g== X-Gm-Message-State: AJcUukdoaPPFXTWcDLVfD7Fls8FlLHLC0BLi0HZdFJVVVuPpCmzIRZ1j muTb56CcgrXP1V53TIpyEicC5j5e X-Received: by 2002:a65:4ccb:: with SMTP id n11mr5061245pgt.257.1547577685189; Tue, 15 Jan 2019 10:41:25 -0800 (PST) Received: from himanshu-Vostro-3559 ([103.233.116.134]) by smtp.gmail.com with ESMTPSA id l5sm3909299pgp.82.2019.01.15.10.41.21 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 15 Jan 2019 10:41:24 -0800 (PST) Date: Wed, 16 Jan 2019 00:11:17 +0530 From: Himanshu Jha To: sebastien bourdelin Cc: linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-iio@vger.kernel.org, mark.rutland@arm.com, robh+dt@kernel.org, pmeerw@pmeerw.net, lars@metafoo.de, knaack.h@gmx.de, jic23@kernel.org Subject: Re: [PATCH v2 1/2] iio: chemical: bme680: Add device-tree support Message-ID: <20190115184117.GA10186@himanshu-Vostro-3559> References: <20190111205359.14158-1-sebastien.bourdelin@gmail.com> <20190112094226.GA910@himanshu-Vostro-3559> <2522efda-2762-01a6-7597-38c086779b74@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <2522efda-2762-01a6-7597-38c086779b74@gmail.com> User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Sebastien, On Mon, Jan 14, 2019 at 03:00:41PM -0500, sebastien bourdelin wrote: > Hi, > > On 1/12/19 4:42 AM, Himanshu Jha wrote: > > On Fri, Jan 11, 2019 at 03:53:58PM -0500, Sebastien Bourdelin wrote: > > > This commit allow the driver to work with device-tree. > > > > > > Signed-off-by: Sebastien Bourdelin > > > --- > > I get the following compilation failure: > > > > Below I have `allyesconfig` except 'BME680' configure as [M] > > in case you wish to reproduce. > > > > himanshu@himanshu-Vostro-3559:~/linux-next$ grep -i -w 'CONFIG_BME680\|CONFIG_ACPI\|CONFIG_OF' .config > > CONFIG_ACPI=y > > CONFIG_OF=y > > CONFIG_BME680=m > > himanshu@himanshu-Vostro-3559:~/linux-next$ sudo make drivers/iio/chemical/bme680_spi.o > > make[1]: Nothing to be done for 'all'. > > CALL scripts/checksyscalls.sh > > DESCEND objtool > > CC [M] drivers/iio/chemical/bme680_spi.o > > In file included from ./include/linux/acpi.h:41:0, > > from drivers/iio/chemical/bme680_spi.c:7: > > ./include/linux/module.h:213:1: error: expected ‘,’ or ‘;’ before ‘extern’ > > extern typeof(name) __mod_##type##__##name##_device_table \ > > ^ > > drivers/iio/chemical/bme680_spi.c:119:1: note: in expansion of macro ‘MODULE_DEVICE_TABLE’ > > MODULE_DEVICE_TABLE(of, bme680_of_spi_match); > > ^~~~~~~~~~~~~~~~~~~ > > scripts/Makefile.build:291: recipe for target 'drivers/iio/chemical/bme680_spi.o' failed > > make[1]: *** [drivers/iio/chemical/bme680_spi.o] Error 1 > > Makefile:1741: recipe for target 'drivers/iio/chemical/bme680_spi.o' failed > > make: *** [drivers/iio/chemical/bme680_spi.o] Error 2 > Thanks for the test, this is bad, i will fix that! > > BUT if: > > > > himanshu@himanshu-Vostro-3559:~/linux-next$ make allyesconfig > > scripts/kconfig/conf --allyesconfig Kconfig > > # > > # configuration written to .config > > # > > > > himanshu@himanshu-Vostro-3559:~/linux-next$ sudo make drivers/iio/chemical/bme680_spi.o > > scripts/kconfig/conf --syncconfig Kconfig > > make[1]: Nothing to be done for 'all'. > > HOSTCC scripts/dtc/dtc.o > > HOSTCC scripts/dtc/flattree.o > > HOSTCC scripts/dtc/fstree.o > > HOSTCC scripts/dtc/data.o > > HOSTCC scripts/dtc/livetree.o > > HOSTCC scripts/dtc/treesource.o > > HOSTCC scripts/dtc/srcpos.o > > HOSTCC scripts/dtc/checks.o > > HOSTCC scripts/dtc/util.o > > LEX scripts/dtc/dtc-lexer.lex.c > > YACC scripts/dtc/dtc-parser.tab.h > > HOSTCC scripts/dtc/dtc-lexer.lex.o > > YACC scripts/dtc/dtc-parser.tab.c > > HOSTCC scripts/dtc/dtc-parser.tab.o > > HOSTLD scripts/dtc/dtc > > CC scripts/mod/empty.o > > MKELF scripts/mod/elfconfig.h > > HOSTCC scripts/mod/modpost.o > > CC scripts/mod/devicetable-offsets.s > > HOSTCC scripts/mod/file2alias.o > > HOSTCC scripts/mod/sumversion.o > > HOSTLD scripts/mod/modpost > > CC kernel/bounds.s > > CC arch/x86/kernel/asm-offsets.s > > CALL scripts/checksyscalls.sh > > DESCEND objtool > > CC drivers/iio/chemical/bme680_spi.o > > > > Compiles without any issues. > Hum, weird it compiles actually :s I think this behavior is observed due to: include/linux/module.h +212 #ifdef MODULE /* Creates an alias so file2alias.c can find device table. */ #define MODULE_DEVICE_TABLE(type, name) \ extern typeof(name) __mod_##type##__##name##_device_table \ __attribute__ ((unused, alias(__stringify(name)))) #else /* !MODULE */ #define MODULE_DEVICE_TABLE(type, name) #endif So, when we build the driver as a module[M] then macro expansion takes place giving us the compiler warning. OTOH, if the driver is built as builtin[*] then marco expands to nothing or simply goes away. And `;' completes the struct declaration while silencing the warning. static const struct of_device_id bme680_of_spi_match[] = { { .compatible = "bosch,bme680", }, {}, } MODULE_DEVICE_TABLE(of, bme680_of_spi_match); converts to: static const struct of_device_id bme680_of_spi_match[] = { { .compatible = "bosch,bme680", }, {}, } ; ^^^ Amazing! Correct me if I'm wrong somewhere, took me 2 hours to figure that out :D Also, I some additional interesting observations: When buitin[*] -> no symbol tables in the RO segment of object file himanshu@himanshu-Vostro-3559:~/linux-next$ nm drivers/iio/chemical/bme680_spi.o 0000000000000000 d __addressable_bme680_spi_driver_init130 00000000000001a0 r bme680_acpi_match U bme680_core_probe 0000000000000000 r bme680_of_spi_match 00000000000000a0 d bme680_regmap_bus U bme680_regmap_config 0000000000000000 t bme680_regmap_spi_read 0000000000000010 t bme680_regmap_spi_write 0000000000000000 d bme680_spi_driver 0000000000000000 t bme680_spi_driver_exit 0000000000000000 t bme680_spi_driver_init 00000000000001e0 r bme680_spi_id 0000000000000070 t bme680_spi_probe U _dev_err U __devm_regmap_init U driver_unregister 0000000000000000 d __exitcall_bme680_spi_driver_exit 0000000000000000 t __initcall_bme680_spi_driver_init6 U regmap_read U regmap_update_bits_base U regmap_write U spi_get_device_id U __spi_register_driver U spi_setup U spi_write_then_read U __stack_chk_fail While when [M] -> we can see the symbol tables in the RO segment himanshu@himanshu-Vostro-3559:~/linux-next$ nm drivers/iio/chemical/bme680_spi.o 00000000000001a0 r bme680_acpi_match U bme680_core_probe 0000000000000000 r bme680_of_spi_match 00000000000000a0 d bme680_regmap_bus U bme680_regmap_config 0000000000000000 t bme680_regmap_spi_read 0000000000000010 t bme680_regmap_spi_write 0000000000000000 d bme680_spi_driver 0000000000000000 t bme680_spi_driver_exit 0000000000000000 t bme680_spi_driver_init 00000000000001e0 r bme680_spi_id 0000000000000070 t bme680_spi_probe 0000000000000000 T cleanup_module U _dev_err U __devm_regmap_init U driver_unregister 0000000000000000 T init_module 00000000000001a0 R __mod_acpi__bme680_acpi_match_device_table <--- 0000000000000000 R __mod_of__bme680_of_spi_match_device_table <--- 00000000000001e0 R __mod_spi__bme680_spi_id_device_table <--- U regmap_read U regmap_update_bits_base U regmap_write U spi_get_device_id U __spi_register_driver U spi_setup U spi_write_then_read U __stack_chk_fail U __this_module 0000000000000033 r __UNIQUE_ID_author38 000000000000000f r __UNIQUE_ID_description39 0000000000000000 r __UNIQUE_ID_license40 Thanks! -- Himanshu Jha Undergraduate Student Department of Electronics & Communication Guru Tegh Bahadur Institute of Technology