Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp256539pxv; Wed, 30 Jun 2021 05:05:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyJZHunSS/R11baTDaXQVjU6FdsACCthoLgOhixFjjTMABf8s2zrrL814xckQDi4fcjBhdu X-Received: by 2002:a05:6e02:1251:: with SMTP id j17mr5317320ilq.217.1625054704825; Wed, 30 Jun 2021 05:05:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625054704; cv=none; d=google.com; s=arc-20160816; b=ibV3t9GXnHvTGclSkJrmhyWUGCHO8PhwEBfx+dVVnVFJFqkRo2vzBJnNU+kj3Yhr/s eNwK1DH7HrfsMwjzqdH7Z2/qt/0iq3w1dExxRlLDr0a4tBfY7/i13DokTGhtkFKWPhOQ bs+SO+A2t809im33GJ6HaH3ecF5G/h/2AUzc6avguViHyAdtZ7EuegImFPdfCoy7Yg+q tkW1yIn0SbavRy1V/yIhZP+kqO044DbQiMfVQCvtgugoN1fS5ZimmwK2mlSatw83TJTn 0QNlfrmkFZbSfzWqxzaengCvv3IhkB59MKh75QDzPyVc2k13Bslq/h3QK5FN1d7P4jL3 DpwA== 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=PGqfMLR1AMj29tMPKqbUUGw05oAykXOuNpPiQvs4AjI=; b=Hx7LTDMFsYRuG2ivfOkf5Dcdl96uW0lkXhFgBoZ2IZOcrd//vEPFLrkH221juTK16F K0VwlQtv8bTKH6iYb4Kr6OSTEI4CfvaXX+TYnA4DduGMTqbfYPBCZUvYDSryjnPoAsZL zLcridQl84pvd8QfM1Z/6LNbuPtnY5lUn68xHR56lIjQ4RDyem6o8wbclwR+lD9aU8yT HgcRE2ZyT1XKpIs6h16aI/1U9DIQpV76tZ9PvDIt+HyBvNCPBPcto5EbeFNvWsYzI5Zt 588gZT+cRRWfSCmjYInKBACayhU4630DKplJS8X2E5B9boYfWOfv+KfRyy2ne5JF2wnO vgJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@deviqon.com header.s=google header.b=ny8ehxZd; 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 l20si1049577ilk.149.2021.06.30.05.04.40; Wed, 30 Jun 2021 05:05:04 -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=ny8ehxZd; 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 S234353AbhF3MG0 (ORCPT + 99 others); Wed, 30 Jun 2021 08:06:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50092 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234148AbhF3MG0 (ORCPT ); Wed, 30 Jun 2021 08:06:26 -0400 Received: from mail-ed1-x532.google.com (mail-ed1-x532.google.com [IPv6:2a00:1450:4864:20::532]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C6386C061756 for ; Wed, 30 Jun 2021 05:03:56 -0700 (PDT) Received: by mail-ed1-x532.google.com with SMTP id df12so2901503edb.2 for ; Wed, 30 Jun 2021 05:03:56 -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=PGqfMLR1AMj29tMPKqbUUGw05oAykXOuNpPiQvs4AjI=; b=ny8ehxZdNZHCiNeSJf5TyJF2HdPeKNTIXbzHv6efvOvHjarKyeUrf41Pk+WqskwiQH VROciDUxRz6J8RNuboRe0XfBjl0JwzWoEFOOM2nQeaxJ/Aj5+J0DXZcUdD1NaLcKixwE InFwKmZnQI/PbG5x709d8XKhxSxkE9VZkb4TTNhvrGiKtywwyVIodcCuSfi0b38CbJQq 0l48i4A7I/JmGPqKT1NWQovrMj4KRVVHVaEuexJ0cxjdcXChn0yI3PCGAQFacf3CCfeB 1TWGrAu75OqfAOPMpHWwmFlGS0PmbLN3kCZYPyEsGQclNzYLX0jpMDbhp73IDqanw92B lJAQ== 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=PGqfMLR1AMj29tMPKqbUUGw05oAykXOuNpPiQvs4AjI=; b=uS0SwxDXalnzBi8XEIixWAitZvd/G8VLSRXvo5z9ufuk5ALw+I5LI/Ls3ryJeOmgg8 6Zc3ihX1nzFjHYusbI+8voiscxndynjM7buAsPGY/DLy95vTWYPgwLqVWrnzBumU2nQM /F6VzCeADorl4uuQzG8kTGi1fhsN8K7m0dT0qRcoZB/czhRZ07iGB5B6HO2e7u5WfdEA T5iiYrz0/mTYCsfpLZe4Nx1HJR4faw7B1U257hb2/a4TgLsqTaM4Sc2p6WViahKWI1zT rYGwrB5QeBSHFV7U1OdXeEqbEl/+8VBjj5ftppKRlbbmJ+shnBS/lPBa4FLV/lTZ2r7j l3Pg== X-Gm-Message-State: AOAM532fC1acTP/W6vzNOpmVMRy9RXl2DFCA8vvz9q9OKs2dMDcwE3SF kzoWltc9Ks2pUNjOJlDknPSYzA== X-Received: by 2002:a50:ef09:: with SMTP id m9mr3392887eds.130.1625054635250; Wed, 30 Jun 2021 05:03:55 -0700 (PDT) Received: from neptune.. ([5.2.193.191]) by smtp.gmail.com with ESMTPSA id u21sm9405610eja.59.2021.06.30.05.03.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Jun 2021 05:03:54 -0700 (PDT) From: Alexandru Ardelean To: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Cc: jic23@kernel.org, Alexandru Ardelean Subject: [PATCH] iio: accel: da311: convert probe to device-managed functions Date: Wed, 30 Jun 2021 15:03:38 +0300 Message-Id: <20210630120338.482426-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 is another simple conversion to device-managed functions, requiring the use of devm_iio_device_register() and moving the disabling of the device on a devm_add_action_or_reset() hook. The i2c_set_clientdata() can be removed, as the PM functions can work with just the device object, to obtain the i2c_client object. Signed-off-by: Alexandru Ardelean --- drivers/iio/accel/da311.c | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/drivers/iio/accel/da311.c b/drivers/iio/accel/da311.c index 92593a1cd1aa..04e13487e706 100644 --- a/drivers/iio/accel/da311.c +++ b/drivers/iio/accel/da311.c @@ -212,6 +212,11 @@ static const struct iio_info da311_info = { .read_raw = da311_read_raw, }; +static void da311_disable(void *client) +{ + da311_enable(client, false); +} + static int da311_probe(struct i2c_client *client, const struct i2c_device_id *id) { @@ -229,7 +234,6 @@ static int da311_probe(struct i2c_client *client, data = iio_priv(indio_dev); data->client = client; - i2c_set_clientdata(client, indio_dev); indio_dev->info = &da311_info; indio_dev->name = "da311"; @@ -245,22 +249,11 @@ static int da311_probe(struct i2c_client *client, if (ret < 0) return ret; - ret = iio_device_register(indio_dev); - if (ret < 0) { - dev_err(&client->dev, "device_register failed\n"); - da311_enable(client, false); - } - - return ret; -} - -static int da311_remove(struct i2c_client *client) -{ - struct iio_dev *indio_dev = i2c_get_clientdata(client); - - iio_device_unregister(indio_dev); + ret = devm_add_action_or_reset(&client->dev, da311_disable, client); + if (ret) + return ret; - return da311_enable(client, false); + return devm_iio_device_register(&client->dev, indio_dev); } #ifdef CONFIG_PM_SLEEP @@ -289,7 +282,6 @@ static struct i2c_driver da311_driver = { .pm = &da311_pm_ops, }, .probe = da311_probe, - .remove = da311_remove, .id_table = da311_i2c_id, }; -- 2.31.1