From patchwork Thu Dec 10 13:14:49 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 7818841 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: X-Original-To: patchwork-linux-sh@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 18FEB9F1C2 for ; Thu, 10 Dec 2015 13:15:34 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1AAE3203C4 for ; Thu, 10 Dec 2015 13:15:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 092F3203A5 for ; Thu, 10 Dec 2015 13:15:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751369AbbLJNPT (ORCPT ); Thu, 10 Dec 2015 08:15:19 -0500 Received: from mout.kundenserver.de ([212.227.17.13]:57807 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750977AbbLJNPR (ORCPT ); Thu, 10 Dec 2015 08:15:17 -0500 Received: from wuerfel.localnet ([134.3.118.24]) by mrelayeu.kundenserver.de (mreue103) with ESMTPSA (Nemesis) id 0M35gF-1aQ3qP3rjb-00svhT; Thu, 10 Dec 2015 14:14:51 +0100 From: Arnd Bergmann To: Wolfram Sang , linux-i2c@vger.kernel.org Cc: Niklas =?ISO-8859-1?Q?S=F6derlund?= , linux-sh@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH] i2c: allow building emev2 without slave mode again Date: Thu, 10 Dec 2015 14:14:49 +0100 Message-ID: <2144222.LfzPx9mJ0p@wuerfel> User-Agent: KMail/4.11.5 (Linux/3.16.0-10-generic; K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EQSCK Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The emev2 driver stopped compiling in today's linux-next kernel: drivers/i2c/busses/i2c-emev2.c: In function 'em_i2c_slave_irq': drivers/i2c/busses/i2c-emev2.c:233:23: error: storage size of 'event' isn't known drivers/i2c/busses/i2c-emev2.c:250:3: error: implicit declaration of function 'i2c_slave_event' [-Werror=implicit-function-declaration] drivers/i2c/busses/i2c-emev2.c:250:32: error: 'I2C_SLAVE_STOP' undeclared (first use in this function) It works again if we enable CONFIG_I2C_SLAVE, but it seems wrong to add a dependency on that symbol: * The symbol is user-selectable, but only one or two (including this one) bus drivers actually implement it, and it makes no sense if you don't have one of them. * The other driver (R-Car) uses 'select I2C_SLAVE', which seems reasonable in principle, but we should not do that on user visible symbols. * I2C slave mode could be implemented in a lot of other drivers as an optional feature, but we shouldn't require enabling it if we don't use it. This changes the two drivers that provide I2C slave mode so they can again build if the slave mode being disabled. To do this, I move the definition of i2c_slave_event() and enum i2c_slave_event out of the #ifdef and instead make the assignment of the reg_slave and unreg_slave pointers optional in the bus drivers. The functions implementing the feature are unused in that case, so they get marked as __maybe_unused in order to still give compile-time coverage. Signed-off-by: Arnd Bergmann Fixes: c31d0a00021d ("i2c: emev2: add slave support") --- To unsubscribe from this list: send the line "unsubscribe linux-sh" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig index 69c46fe13777..1c8d53f34dd3 100644 --- a/drivers/i2c/busses/Kconfig +++ b/drivers/i2c/busses/Kconfig @@ -985,7 +985,6 @@ config I2C_XLP9XX config I2C_RCAR tristate "Renesas R-Car I2C Controller" depends on ARCH_SHMOBILE || COMPILE_TEST - select I2C_SLAVE help If you say yes to this option, support will be included for the R-Car I2C controller. diff --git a/drivers/i2c/busses/i2c-emev2.c b/drivers/i2c/busses/i2c-emev2.c index 96bb4e749012..75d6095c5fe1 100644 --- a/drivers/i2c/busses/i2c-emev2.c +++ b/drivers/i2c/busses/i2c-emev2.c @@ -316,7 +316,7 @@ static u32 em_i2c_func(struct i2c_adapter *adap) return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL | I2C_FUNC_SLAVE; } -static int em_i2c_reg_slave(struct i2c_client *slave) +static int __maybe_unused em_i2c_reg_slave(struct i2c_client *slave) { struct em_i2c_device *priv = i2c_get_adapdata(slave->adapter); @@ -334,7 +334,7 @@ static int em_i2c_reg_slave(struct i2c_client *slave) return 0; } -static int em_i2c_unreg_slave(struct i2c_client *slave) +static int __maybe_unused em_i2c_unreg_slave(struct i2c_client *slave) { struct em_i2c_device *priv = i2c_get_adapdata(slave->adapter); @@ -350,8 +350,10 @@ static int em_i2c_unreg_slave(struct i2c_client *slave) static struct i2c_algorithm em_i2c_algo = { .master_xfer = em_i2c_xfer, .functionality = em_i2c_func, +#ifdef CONFIG_I2C_SLAVE .reg_slave = em_i2c_reg_slave, .unreg_slave = em_i2c_unreg_slave, +#endif }; static int em_i2c_probe(struct platform_device *pdev) diff --git a/drivers/i2c/busses/i2c-rcar.c b/drivers/i2c/busses/i2c-rcar.c index 3ed1f0aa5eeb..e67824adeba0 100644 --- a/drivers/i2c/busses/i2c-rcar.c +++ b/drivers/i2c/busses/i2c-rcar.c @@ -521,7 +521,7 @@ out: return ret; } -static int rcar_reg_slave(struct i2c_client *slave) +static int __maybe_unused rcar_reg_slave(struct i2c_client *slave) { struct rcar_i2c_priv *priv = i2c_get_adapdata(slave->adapter); @@ -542,7 +542,7 @@ static int rcar_reg_slave(struct i2c_client *slave) return 0; } -static int rcar_unreg_slave(struct i2c_client *slave) +static int __maybe_unused rcar_unreg_slave(struct i2c_client *slave) { struct rcar_i2c_priv *priv = i2c_get_adapdata(slave->adapter); @@ -568,8 +568,10 @@ static u32 rcar_i2c_func(struct i2c_adapter *adap) static const struct i2c_algorithm rcar_i2c_algo = { .master_xfer = rcar_i2c_master_xfer, .functionality = rcar_i2c_func, +#ifdef CONFIG_I2C_SLAVE .reg_slave = rcar_reg_slave, .unreg_slave = rcar_unreg_slave, +#endif }; static const struct of_device_id rcar_i2c_dt_ids[] = { diff --git a/include/linux/i2c.h b/include/linux/i2c.h index 51028f351d13..69871e5ee44a 100644 --- a/include/linux/i2c.h +++ b/include/linux/i2c.h @@ -254,7 +254,6 @@ static inline void i2c_set_clientdata(struct i2c_client *dev, void *data) /* I2C slave support */ -#if IS_ENABLED(CONFIG_I2C_SLAVE) enum i2c_slave_event { I2C_SLAVE_READ_REQUESTED, I2C_SLAVE_WRITE_REQUESTED, @@ -269,9 +268,12 @@ extern int i2c_slave_unregister(struct i2c_client *client); 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; #endif +} /** * struct i2c_board_info - template for device creation