Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp71793ybx; Wed, 6 Nov 2019 13:24:38 -0800 (PST) X-Google-Smtp-Source: APXvYqxmNKjoip00Dwu8BI8y+y087i2y/nLfZpMWLDdKJ0iwItuFr96wLmdaImr5yUNrt90Ntjo8 X-Received: by 2002:a05:6402:1452:: with SMTP id d18mr5300893edx.158.1573075478349; Wed, 06 Nov 2019 13:24:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573075478; cv=none; d=google.com; s=arc-20160816; b=l+bCfm9a2jpmsB95tzu4lL1WRzGJ22BI/ExVwimwvWMG4m/cp1782d50exr97BJQuB y9xUcJhqraM5GST6SoYGHxsZ7ocvqYFCPd/6q5X3yHdT/AJkdBLdqXLDWi7Cgrfq8P8I fEp86pd7N4tDYiqttj5kSbgjLFZw8N2qyW8ZLD+iEhF1yMwemTC94QIHdWSp+/pVXCRb DDYO68okiojA1noVAmKts9d6Q+kzParg83HKQQTHYkp1ICeW60jy6f8veWPXyLj4VbVl SzboWIQRRPViGjp3Ki7fI9PtO5enxUbR3gsXuxO7kKg0WXEmK+eKNWiJgyDzEdNSs9/1 dZZw== 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:date:subject:cc:to:from; bh=zukiZVaOe7AFoRyOjOx0fiNuN5NwdpP4aLIQJBhIG6c=; b=NreZSZZjOFh1bTIA2/4S7bDkR+0750H3e6akUs/pAzaIwrl7CHlf2K0v2nsyA3SKN8 EIoc8J2uQ/IG4gh2jOihle6hgw73lrJj5Rn5usgVOBCMVD5E631t2XSSiGqgSr9Xat9e 7xt8KOtdYjx1NsMJ6yYUE+dLnf0W5i0Iw9qob6azKdJNVFQs7pIjJxhGVoBJZyNsaAKK Vt5eSo/giPovVjcJwVYaAE9SMXEDRz/M/dJzvRD9/+KWA1DoJg9fwuS/Gu7/VqEZ8Hhh zvjku2UOAVTyZEu/E60ed8RuIoix0Z5ckk5ylSIdLTTv6AmeaIoEH9Ihmt3RxQ26aLB5 hRtw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m13si12794021edc.243.2019.11.06.13.24.14; Wed, 06 Nov 2019 13:24:38 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731889AbfKFVVX (ORCPT + 99 others); Wed, 6 Nov 2019 16:21:23 -0500 Received: from sauhun.de ([88.99.104.3]:58976 "EHLO pokefinder.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727949AbfKFVVW (ORCPT ); Wed, 6 Nov 2019 16:21:22 -0500 Received: from localhost (p54B33505.dip0.t-ipconnect.de [84.179.53.5]) by pokefinder.org (Postfix) with ESMTPSA id 0C5FC2C054A; Wed, 6 Nov 2019 22:21:21 +0100 (CET) From: Wolfram Sang To: linux-media@vger.kernel.org Cc: linux-i2c@vger.kernel.org, Wolfram Sang , Wolfram Sang , linux-kernel@vger.kernel.org Subject: [PATCH 01/17] i2c: add helper to check if a client has a driver attached Date: Wed, 6 Nov 2019 22:21:01 +0100 Message-Id: <20191106212120.27983-2-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191106212120.27983-1-wsa+renesas@sang-engineering.com> References: <20191106212120.27983-1-wsa+renesas@sang-engineering.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Factoring out something used in the media subsystem. As an improvement, it bails out on both, NULL and ERRPTR. Signed-off-by: Wolfram Sang --- include/linux/i2c.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/linux/i2c.h b/include/linux/i2c.h index aaf57d9b41db..93b315c9a062 100644 --- a/include/linux/i2c.h +++ b/include/linux/i2c.h @@ -850,6 +850,11 @@ extern void i2c_del_driver(struct i2c_driver *driver); #define i2c_add_driver(driver) \ i2c_register_driver(THIS_MODULE, driver) +static inline bool i2c_client_has_driver(struct i2c_client *client) +{ + return !IS_ERR_OR_NULL(client) && client->dev.driver; +} + extern struct i2c_client *i2c_use_client(struct i2c_client *client); extern void i2c_release_client(struct i2c_client *client); -- 2.20.1