Received: by 10.192.165.156 with SMTP id m28csp899254imm; Fri, 13 Apr 2018 09:42:02 -0700 (PDT) X-Google-Smtp-Source: AIpwx49661PdQx0ap0YvHa0HdjBWfzG8QaZetKX3ECPCf2o/V6t9PZh+m5s+7pLe1TGVgZZdRQIa X-Received: by 10.98.102.79 with SMTP id a76mr12081428pfc.162.1523637722812; Fri, 13 Apr 2018 09:42:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523637722; cv=none; d=google.com; s=arc-20160816; b=FazULjSIMfUUGUhRvHPVZaprafQBf/iFuh3KEgM6Nllw3lu25xC+kL3NArkhmxppAl gmp9g8T4PdQZEXiYqRXLTxRlS6/gBkJvj2ysyiv8MX6T5f8TTdR2ylqL480hpBcoSJmP eHPWOQUpnjElhvrNz8LwT0YhQP66w/Ifx/K0cL7Sbq2nCdJ/PdFiZH2lvrB/AfvXi4no bJyn2kB009OBoSD9N4kKNuZMOUqVty0khMOx6OXeTlmogVEDIWryBGWy94cBDEEtSfKQ tbdlnnclBqqSRou19pXq/Ei5ukJHVriT7OZtVZswzM2YIDbV4MhNea5xRKv2VYQxj8VC klPg== 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 :dkim-signature:arc-authentication-results; bh=g7nGO8bR3Zc6fs6EfJAtMeq6spNuLwzu3LhfHYcCQRY=; b=mJe2/+6h3uz4QPCCUvF8gdfpG5mCRmd6lerKFA0vC3izIjmwYRgXUGOLSX0fO9bVrA JJVO/a4UDM7gAy3I0Iu2LjTxY+1A1Kr++yia6f75nv3wDNGOSAcKxqcBmFnGwd3bgtgt j5Fqpj2RnQhB7CB5g0+hzs6otM/5tY82VL2F0B+Anr5EZg96CHjEU7lN8wHJaa6KIyen /P6ZcVVEEpdw8V4UcIJz9k0HiouFFvf4ywu4TuiackcoWbUzZzfvo/P4gLGNag+TvYI1 l4vSyK5kKwzhxxxtJY8CkceKwf/WVA3T/9XZ9XKAzYjYbBT31IghczrzbA4Kv7fvC+ng 50Lw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@vanguardiasur-com-ar.20150623.gappssmtp.com header.s=20150623 header.b=WZAik8LO; 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 v12-v6si595974plk.241.2018.04.13.09.41.48; Fri, 13 Apr 2018 09:42:02 -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=@vanguardiasur-com-ar.20150623.gappssmtp.com header.s=20150623 header.b=WZAik8LO; 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 S1753165AbeDMQil (ORCPT + 99 others); Fri, 13 Apr 2018 12:38:41 -0400 Received: from mail-qt0-f193.google.com ([209.85.216.193]:43556 "EHLO mail-qt0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751961AbeDMQif (ORCPT ); Fri, 13 Apr 2018 12:38:35 -0400 Received: by mail-qt0-f193.google.com with SMTP id s48so8631042qtb.10 for ; Fri, 13 Apr 2018 09:38:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vanguardiasur-com-ar.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=g7nGO8bR3Zc6fs6EfJAtMeq6spNuLwzu3LhfHYcCQRY=; b=WZAik8LOF2dzbXgrxHJRNxPplDUKARQ7vfFO1AJNp7lUogfHPi8ZetqXPe10vRs/y5 T2AqawBP3TC4y1GlQ7x8u7RIUuXQL/XL2zEduJhRi+xIUO2+vUA56so367PeSBx5LOYV 5jz96LEVKI1a/udOinW0P8ciLMTDMZyqeu+EFW8AnEZy+WojjPaNczNU8HqqOvLpP0Gz VXG5pPV4gwj+4ru2U89y6jX365K1IF//RJ9SN5HxekeMcMoE8Q26P+uTJNW1tAQgrR9B vC6AbcJxbTGf4lUs59Ceab4SwEhetlT4LgrNaH/R0pZwsbrFDbhizeTIj7pbxxehvsBz 503Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=g7nGO8bR3Zc6fs6EfJAtMeq6spNuLwzu3LhfHYcCQRY=; b=dddJdOIQJ0eoiR4Ez4ln4ltNwQzUbzkkC5yOn27TiFsu1uVpZvBoD2WwzbsxuhGQdM xVE+DALEkM7Pp94o7HSjfDHhOK6WDH2Xjg3OKYattcyeDhudU7b82Vv5ezSK4C7Twbjb 9paVPjiVRlIMwDx7ydOJtpuqih7RfUMfIrjCfQyTPrR2tLvqfnllEFEl1X8vVlKk8QNE nJg03kboT/XNKv+vcT/vgxKU+o0ArXXJygoSoAEE6LcRH6eEpkNewRaihOa5Ab7VkQse GnfYx0ZttFYQu8CvlJhgz2uxfOrEH5LJ8h62ubs7qzcScwMhvLzY/yvwZa3u5uce9tFb /paA== X-Gm-Message-State: ALQs6tDR0TEM41kMLIqGXY8MJKzvCLFI5kXt9JZVP8HhMAf0w/RL/idi V5pcPnx+KiDSNirmtVzZ6PNnsw== X-Received: by 10.200.34.57 with SMTP id o54mr3823518qto.117.1523637515300; Fri, 13 Apr 2018 09:38:35 -0700 (PDT) Received: from localhost.localdomain ([190.210.56.45]) by smtp.gmail.com with ESMTPSA id t82sm5024687qke.52.2018.04.13.09.38.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 13 Apr 2018 09:38:34 -0700 (PDT) From: =?UTF-8?q?Hern=C3=A1n=20Gonzalez?= To: jic23@kernel.org, knaack.h@gmx.de, lars@metafoo.de, pmeerw@pmeerw.net, gregkh@linuxfoundation.org, Michael.Hennerich@analog.com, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Cc: =?UTF-8?q?Hern=C3=A1n=20Gonzalez?= Subject: [PATCH v2 09/14] staging: iio: ad7746: Add remove() Date: Fri, 13 Apr 2018 13:36:46 -0300 Message-Id: <1523637411-8531-10-git-send-email-hernan@vanguardiasur.com.ar> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1523637411-8531-1-git-send-email-hernan@vanguardiasur.com.ar> References: <1523637411-8531-1-git-send-email-hernan@vanguardiasur.com.ar> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This allows the driver to be probed and removed as a module powering it down on remove(). Signed-off-by: HernĂ¡n Gonzalez --- drivers/staging/iio/cdc/ad7746.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/drivers/staging/iio/cdc/ad7746.c b/drivers/staging/iio/cdc/ad7746.c index c29a221..05506bf9 100644 --- a/drivers/staging/iio/cdc/ad7746.c +++ b/drivers/staging/iio/cdc/ad7746.c @@ -775,6 +775,31 @@ static int ad7746_probe(struct i2c_client *client, return 0; } +static int ad7746_remove(struct i2c_client *client) +{ + struct iio_dev *indio_dev = i2c_get_clientdata(client); + struct ad7746_chip_info *chip = iio_priv(indio_dev); + unsigned char regval; + int ret; + + mutex_lock(&chip->lock); + + regval = chip->config | AD7746_CONF_MODE_PWRDN; + ret = i2c_smbus_write_byte_data(chip->client, AD7746_REG_CFG, regval); + + mutex_unlock(&chip->lock); + + if (ret < 0) { + dev_warn(&client->dev, "Could NOT Power Down!\n"); + goto out; + } + + iio_device_unregister(indio_dev); + +out: + return ret; +} + static const struct i2c_device_id ad7746_id[] = { { "ad7745", 7745 }, { "ad7746", 7746 }, @@ -799,6 +824,7 @@ static struct i2c_driver ad7746_driver = { .of_match_table = of_match_ptr(ad7746_of_match), }, .probe = ad7746_probe, + .remove = ad7746_remove, .id_table = ad7746_id, }; module_i2c_driver(ad7746_driver); -- 2.7.4