Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp10099pxv; Thu, 24 Jun 2021 01:20:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzjuN7+Et83GZBg0QVLkkhscr+kAf0OYuRkxdhMogzKaZ+XeM1zp9Xocb8OV9nAo6JZNsTU X-Received: by 2002:a92:901:: with SMTP id y1mr2948305ilg.212.1624522818727; Thu, 24 Jun 2021 01:20:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624522818; cv=none; d=google.com; s=arc-20160816; b=dhqBMRJIxmdc/UwaJAzs8SrgR90i73F5jCaJGCDujkLsMEZ+Pk41snJ9DC+Rpn6boJ D7gUun2TRVSkJW5eLpdG+jcemN07A0t4LN6VuNm+o9MCOr8OLpFrLRHrd8e6sRa8/pB5 qKmrYo1FsQbY3hyG8BYX5tq0oZruJgi54+4xi1VFZ5yVvOWDzcTS0D94DmigylVa5maC HbCCuqSHUAV8eSSj5i7b1d/pr8JuNVG3uphWdbcIDjZdYU6YcZPHervvQ4ktsM2oT5Ao DR2dCO3fg3FXGxhmOrDinhJ6nuSaO2+OgzYBEkYvnt6acyzwp5aSJnAxZSdr1Ly4+zfC fJKQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=EaNSCMGV5qh1CquvxbjGYHMLSp9S15q2vTJ0o9vKxN0=; b=HznWWcXiXlHuIuDQS/9uRo1aiFwX+9TzrGjQFCM7EwoGWYwN92zkVS+EKek38xoboi BFTDl7agZnTnvpqUnUaLejz2cTisqmnW7+OpN65PcuXt+tzBcKNPazHXgsNF5SBw8YT/ RwNZDWncdzVWe134J+EduwXnZutQOh4DyzMSDkD63MjmP3ExpULRIAH9AfQyHTHsKhkz dyzbfseDpEPwckiBTWEpkgKwX5dACJT6HfgZntRh+/tDQzwMV9T6kD161TJ7U1+Yd8xv CcqgE9EoGy8MasvgRbvyhp3drZNjhIiRBUErIifvOwKPklu1dUph5WHadBsFVx4ePmTE e4sA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@deviqon.com header.s=google header.b=TLyee5ou; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=deviqon.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n1si2772185ilt.140.2021.06.24.01.20.06; Thu, 24 Jun 2021 01:20:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@deviqon.com header.s=google header.b=TLyee5ou; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=deviqon.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231878AbhFXIVz (ORCPT + 99 others); Thu, 24 Jun 2021 04:21:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44526 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231846AbhFXIVy (ORCPT ); Thu, 24 Jun 2021 04:21:54 -0400 Received: from mail-ed1-x52c.google.com (mail-ed1-x52c.google.com [IPv6:2a00:1450:4864:20::52c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 050B1C061756 for ; Thu, 24 Jun 2021 01:19:33 -0700 (PDT) Received: by mail-ed1-x52c.google.com with SMTP id i24so7281689edx.4 for ; Thu, 24 Jun 2021 01:19:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=deviqon.com; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=EaNSCMGV5qh1CquvxbjGYHMLSp9S15q2vTJ0o9vKxN0=; b=TLyee5ouAerT+C1yZLIoqowVjsiAD5gKsKq5chr0XpfUfnNX9rEcymsL5yVgHGxccp qaGcW9AlYF5rN8uL7o2qQALyFPLy0V+h0RC2zzwP48de8tfPqULW94YsYip0NJSTSxWd lskXHzb3R9kakbSUCIk4Y6fw/ig+Uuis9FwwG23rx7+SLI8c47AS6xnxsnFkHIi6ZtPi NFyzbVcrIz2gy4u0OQCr+kSlT1HJJSoUy/ryDW9vkB2KeCvNjt4Vr2wzloRyq49ExR59 m4leYGoCzK8EWTg+xHFQ8l3fKLte4Z4McYNcniAwTwiRXomdMHG8g+BKSYw9x8qGrghS oygA== 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:mime-version :content-transfer-encoding; bh=EaNSCMGV5qh1CquvxbjGYHMLSp9S15q2vTJ0o9vKxN0=; b=CARN4OED1jqSlydt7GvtFufrztRmcipqo5rMd0dK7cC6fFJC0U2+Kwlh5F/AInOt4p 3xHazPya1+69Jea8aju+A1nPTvPJk/DE+rr1IZa1i1qS19cXnrCQkqiE7ZzePaF+nHQF R+dW6G61561qeLPrMW8d89vKQJt6whEwGFyAvAp8o+5zBNMqqVFh9BiDqLER2pu9y/OJ QsX/QxDEctOkkkyJkQSiIowUTgWnEjZg7jLd4O0TH2Qs+N81qbiBg4j07tLV1Lcqj5bj Wks3TIAft/0Wza/16vaxNGUCWGCNhHVDgAxtpoDt3p1LFcoVZykakUaCRpw+Ftz8Bs/I jsrg== X-Gm-Message-State: AOAM5329Nww3VQfuqgtkTbT5gGJ1qXn1QCyBQn5gnTiRoZIO+r/V8IBb 132Ldiy5uAf4gBIDosMC04BxuA== X-Received: by 2002:a05:6402:18f6:: with SMTP id x54mr5689099edy.53.1624522772214; Thu, 24 Jun 2021 01:19:32 -0700 (PDT) Received: from neptune.. ([5.2.193.191]) by smtp.gmail.com with ESMTPSA id o4sm1374641edc.94.2021.06.24.01.19.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Jun 2021 01:19:31 -0700 (PDT) From: Alexandru Ardelean To: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Cc: jic23@kernel.org, pmeerw@pmeerw.net, Alexandru Ardelean Subject: [PATCH 1/2] iio: temperature: tmp006: convert probe to device-managed Date: Thu, 24 Jun 2021 11:19:23 +0300 Message-Id: <20210624081924.15897-1-aardelean@deviqon.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This change converts the driver to register via devm_iio_device_register(). For the tmp006_powerdown() hook, this uses a devm_add_action() hook to put the device in powerdown mode when it's unregistered. With these changes, the remove hook can be removed. The i2c_set_clientdata() call is staying around as the private data is used in the PM routines. Signed-off-by: Alexandru Ardelean --- drivers/iio/temperature/tmp006.c | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/drivers/iio/temperature/tmp006.c b/drivers/iio/temperature/tmp006.c index 54976c7dad92..db1ac6029c27 100644 --- a/drivers/iio/temperature/tmp006.c +++ b/drivers/iio/temperature/tmp006.c @@ -193,6 +193,17 @@ static bool tmp006_check_identification(struct i2c_client *client) return mid == TMP006_MANUFACTURER_MAGIC && did == TMP006_DEVICE_MAGIC; } +static int tmp006_powerdown(struct tmp006_data *data) +{ + return i2c_smbus_write_word_swapped(data->client, TMP006_CONFIG, + data->config & ~TMP006_CONFIG_MOD_MASK); +} + +static void tmp006_powerdown_cleanup(void *data) +{ + tmp006_powerdown(data); +} + static int tmp006_probe(struct i2c_client *client, const struct i2c_device_id *id) { @@ -228,23 +239,11 @@ static int tmp006_probe(struct i2c_client *client, return ret; data->config = ret; - return iio_device_register(indio_dev); -} - -static int tmp006_powerdown(struct tmp006_data *data) -{ - return i2c_smbus_write_word_swapped(data->client, TMP006_CONFIG, - data->config & ~TMP006_CONFIG_MOD_MASK); -} - -static int tmp006_remove(struct i2c_client *client) -{ - struct iio_dev *indio_dev = i2c_get_clientdata(client); - - iio_device_unregister(indio_dev); - tmp006_powerdown(iio_priv(indio_dev)); + ret = devm_add_action(&client->dev, tmp006_powerdown_cleanup, data); + if (ret < 0) + return ret; - return 0; + return devm_iio_device_register(&client->dev, indio_dev); } #ifdef CONFIG_PM_SLEEP @@ -277,7 +276,6 @@ static struct i2c_driver tmp006_driver = { .pm = &tmp006_pm_ops, }, .probe = tmp006_probe, - .remove = tmp006_remove, .id_table = tmp006_id, }; module_i2c_driver(tmp006_driver); -- 2.31.1