From mboxrd@z Thu Jan 1 00:00:00 1970 From: Arnd Bergmann Date: Mon, 14 Dec 2015 22:27:22 +0000 Subject: Re: [PATCH] i2c: allow building emev2 without slave mode again Message-Id: <13702087.6o87OAVdIx@wuerfel> List-Id: References: <201512102224.cVm7Hcp0%fengguang.wu@intel.com> <15285750.UWXWiNJ6YU@wuerfel> <20151214135206.GA1520@katana> In-Reply-To: <20151214135206.GA1520@katana> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: linux-arm-kernel@lists.infradead.org On Monday 14 December 2015 14:52:06 Wolfram Sang wrote: > > > What about not ifdeffing the inline function and keep the build error > > > whenever someone uses it without I2C_SLAVE being selected? > > > > The inline function is only added there for the case that I2C_SLAVE is > > disabled, so that would be pointless. > > > > However, what we could do is move the extern declaration outside of > > the #ifdef to make it always visible. The if(IS_ENABLED(CONFIG_I2C_SLAVE)) > > check should then ensure that it never actually gets called, and we > > get a link error if some driver gets it wrong. > > Yes, that's what I meant: move the whole function (as it was before your > patch) out of the CONFIG_I2C_SLAVE block. We should get a compiler error > even, because for !I2C_SLAVE, the client struct will not have the > slave_cb member. > But we don't want a compile-error for randconfig builds, and we don't want unnecessary #ifdef in the driver. This change on top of my earlier patch should do what I meant: diff --git a/include/linux/i2c.h b/include/linux/i2c.h index 0236e5f2b5be..536641bad92d 100644 --- a/include/linux/i2c.h +++ b/include/linux/i2c.h @@ -265,15 +265,15 @@ enum i2c_slave_event { extern int i2c_slave_register(struct i2c_client *client, i2c_slave_cb_t slave_cb); extern int i2c_slave_unregister(struct i2c_client *client); +#if IS_ENABLED(CONFIG_I2C_SLAVE) static inline int i2c_slave_event(struct i2c_client *client, enum i2c_slave_event event, u8 *val) { -#if IS_ENABLED(CONFIG_I2C_SLAVE) return client->slave_cb(client, event, val); +} #else - return 0; +extern int i2c_slave_event(struct i2c_client *client, enum i2c_slave_event event, u8 *val); #endif -} /** * struct i2c_board_info - template for device creation Arnd From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932683AbbLNW2E (ORCPT ); Mon, 14 Dec 2015 17:28:04 -0500 Received: from mout.kundenserver.de ([217.72.192.74]:63259 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753567AbbLNW2B (ORCPT ); Mon, 14 Dec 2015 17:28:01 -0500 From: Arnd Bergmann To: Wolfram Sang Cc: kbuild test robot , kbuild-all@01.org, linux-i2c@vger.kernel.org, Niklas =?ISO-8859-1?Q?S=F6derlund?= , linux-sh@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] i2c: allow building emev2 without slave mode again Date: Mon, 14 Dec 2015 23:27:22 +0100 Message-ID: <13702087.6o87OAVdIx@wuerfel> User-Agent: KMail/4.11.5 (Linux/3.16.0-10-generic; KDE/4.11.5; x86_64; ; ) In-Reply-To: <20151214135206.GA1520@katana> References: <201512102224.cVm7Hcp0%fengguang.wu@intel.com> <15285750.UWXWiNJ6YU@wuerfel> <20151214135206.GA1520@katana> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Provags-ID: V03:K0:uMV90doA+1DFXO2owHQtdNIhylwClIMVyakFI3nJ+nd9spPgkHo GWodUgsppQbIhAns4gNlRWw2mDCtnRdbuwdxvF4xggis00Q3IrpBotrQJJPK/ITSzE8cfq9 djh0xlzakv28c72SKesNfUwmRceDZm1uIlxaMcRxxkbmnDeiCgHB2WK2PFCCIC1NZwOH/qL unrQFf72+M9z7NI9GiuzA== X-UI-Out-Filterresults: notjunk:1;V01:K0:nrLtbraXv/c=:lovr9lN686tSJ3Z35TYE83 b6dYHsk898xkAnfSYbL6GIDnZ22GUeDTewk4uAdqnp8NM7hOnSeo50lVuFvtrWWof2YdnJFHu yQTK4/t/nxYv7xrXajGF2s8qTIAzRL4oEogvR0fNBcNiLbYCXZkMGzZp0sOVTIot9z4hcy/3C jD2HZg+q8t15c44j4sLgenu013kHl9kjIPK4u3ja/WI01uFms4hAOoEEsOojritzF0xH/DAL0 0dO2nki6n7FcqtJxLfLNV+jSJNxncS4WkC/7afNLSvXT1aa6THxx8+MVtZNErn9t5SVPKgTG4 Zj3dju8yF938NHQPwt2A5zv8Tlj5QLbrKh3lm42282ArLxGyyuAx7pI5EEt+FMRJpIWduThFY +dw1T9XNvHSYPwaVExUarb2dWYTo//kzvnO8D4OoG7CT23EybNpYtimda4NWdEOWrM54HDrSW k/zockujWNUH62z8fGMk7PaPO4LjQIONwSl7F2IEELWckBlMWIncIPD6tIwwyKPWxsSNhaLQ3 oJx3//zLYITY/E+xaGVfH+jwHBUSztArVzsmFjbAVy1eqFnFmNltiaHOT+A1G6L8sVvmqg49G oFXltZWJkjKz+5FtMI1ugK9RwMPFXh8Vd9sK2cMt7uJr53dWY2QM2hPtF1eYi8QiDugNvPBpI 4NUGuig3mNBf2Kbw274R9ZBb6j81noCosLxTHGZGAJYToKY3hx8nyAuDy8dLvzlrmKzz9CEYs GfM5nuNtRYxXC894 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Monday 14 December 2015 14:52:06 Wolfram Sang wrote: > > > What about not ifdeffing the inline function and keep the build error > > > whenever someone uses it without I2C_SLAVE being selected? > > > > The inline function is only added there for the case that I2C_SLAVE is > > disabled, so that would be pointless. > > > > However, what we could do is move the extern declaration outside of > > the #ifdef to make it always visible. The if(IS_ENABLED(CONFIG_I2C_SLAVE)) > > check should then ensure that it never actually gets called, and we > > get a link error if some driver gets it wrong. > > Yes, that's what I meant: move the whole function (as it was before your > patch) out of the CONFIG_I2C_SLAVE block. We should get a compiler error > even, because for !I2C_SLAVE, the client struct will not have the > slave_cb member. > But we don't want a compile-error for randconfig builds, and we don't want unnecessary #ifdef in the driver. This change on top of my earlier patch should do what I meant: diff --git a/include/linux/i2c.h b/include/linux/i2c.h index 0236e5f2b5be..536641bad92d 100644 --- a/include/linux/i2c.h +++ b/include/linux/i2c.h @@ -265,15 +265,15 @@ enum i2c_slave_event { extern int i2c_slave_register(struct i2c_client *client, i2c_slave_cb_t slave_cb); extern int i2c_slave_unregister(struct i2c_client *client); +#if IS_ENABLED(CONFIG_I2C_SLAVE) static inline int i2c_slave_event(struct i2c_client *client, enum i2c_slave_event event, u8 *val) { -#if IS_ENABLED(CONFIG_I2C_SLAVE) return client->slave_cb(client, event, val); +} #else - return 0; +extern int i2c_slave_event(struct i2c_client *client, enum i2c_slave_event event, u8 *val); #endif -} /** * struct i2c_board_info - template for device creation Arnd From mboxrd@z Thu Jan 1 00:00:00 1970 From: arnd@arndb.de (Arnd Bergmann) Date: Mon, 14 Dec 2015 23:27:22 +0100 Subject: [PATCH] i2c: allow building emev2 without slave mode again In-Reply-To: <20151214135206.GA1520@katana> References: <201512102224.cVm7Hcp0%fengguang.wu@intel.com> <15285750.UWXWiNJ6YU@wuerfel> <20151214135206.GA1520@katana> Message-ID: <13702087.6o87OAVdIx@wuerfel> To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org On Monday 14 December 2015 14:52:06 Wolfram Sang wrote: > > > What about not ifdeffing the inline function and keep the build error > > > whenever someone uses it without I2C_SLAVE being selected? > > > > The inline function is only added there for the case that I2C_SLAVE is > > disabled, so that would be pointless. > > > > However, what we could do is move the extern declaration outside of > > the #ifdef to make it always visible. The if(IS_ENABLED(CONFIG_I2C_SLAVE)) > > check should then ensure that it never actually gets called, and we > > get a link error if some driver gets it wrong. > > Yes, that's what I meant: move the whole function (as it was before your > patch) out of the CONFIG_I2C_SLAVE block. We should get a compiler error > even, because for !I2C_SLAVE, the client struct will not have the > slave_cb member. > But we don't want a compile-error for randconfig builds, and we don't want unnecessary #ifdef in the driver. This change on top of my earlier patch should do what I meant: diff --git a/include/linux/i2c.h b/include/linux/i2c.h index 0236e5f2b5be..536641bad92d 100644 --- a/include/linux/i2c.h +++ b/include/linux/i2c.h @@ -265,15 +265,15 @@ enum i2c_slave_event { extern int i2c_slave_register(struct i2c_client *client, i2c_slave_cb_t slave_cb); extern int i2c_slave_unregister(struct i2c_client *client); +#if IS_ENABLED(CONFIG_I2C_SLAVE) static inline int i2c_slave_event(struct i2c_client *client, enum i2c_slave_event event, u8 *val) { -#if IS_ENABLED(CONFIG_I2C_SLAVE) return client->slave_cb(client, event, val); +} #else - return 0; +extern int i2c_slave_event(struct i2c_client *client, enum i2c_slave_event event, u8 *val); #endif -} /** * struct i2c_board_info - template for device creation Arnd