Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp3556456pxv; Mon, 28 Jun 2021 07:19:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz+m11kjG6+b4ICJ3+m6h9/YdhxGFhAWOeu/ki+XtP86wnv/5+h1aZmSRB2apSV/8qt1aFz X-Received: by 2002:a05:6e02:11ae:: with SMTP id 14mr16290779ilj.52.1624889987225; Mon, 28 Jun 2021 07:19:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624889987; cv=none; d=google.com; s=arc-20160816; b=L6VcQUJCucLgye/I/0597NXwXpaLy1fxGcqkL37s6HC7wclvhxPpoPdRuMvKr9RvVr 4hZiQqq/gwoJYyzfbBbYIdD/ZvrZsBrknPgfslEjqvE8FnyI0a/c4AmVbSARaDp4ekJO NFNrysk8H016IgJi8Fz4+7VGmUqCWbj9zy+QVSikbpP9RAMBLg1upCqoy2g1W261/rVW ATl+8i5xEMkxlk4GSGNLZG2Ihv7PXjN09dHy0p1d+qUYmf1BrZG/T0diuPf4Zndt6TCK TqXIYuUfxrioBRMSlk41JWCpciwO+dc1xvFTAs3rRycq/9qDeeDO2CnOngh4OI4TJXaU beag== 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=JuNJweosuipucr4vhg0XhclqW1q8Ja8Oi1r1gTGSAjc=; b=Vr0G3Ck6rrBYtW63oaJhw+lj3U3iHETtzxdHJWXGfy26bbobwzqWG9rLBAR2JDATV1 p/abNit98Kxq2enFxX2f9PqPwdjL4sS8Q14ZtNVxKBhw3N1PMoOP1qyZP9YoKYuhRPVR ij9y1FYMQqM7JjKqhrvrh9t1Yx/9Dsovlh8oipneOWYhBEpMLuZAeXCyLdtqNFsBFKiB rga2ymS2FaAewU7VUpRcC+cRDGGVRJT8f/lcnBvYIWW73pdTJ/YKY2+NE1mSmI75y9UE vEP1xywBb79y0UvN3AFmoN6OjuXhFikOODK8McwHhiJEdGLf4QzbqxGcEkhesUYTxSSJ 92lg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@deviqon.com header.s=google header.b=QygiPxCH; 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 w23si3991365ioc.3.2021.06.28.07.19.34; Mon, 28 Jun 2021 07:19:47 -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=QygiPxCH; 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 S232552AbhF1OTw (ORCPT + 99 others); Mon, 28 Jun 2021 10:19:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33524 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232540AbhF1OTu (ORCPT ); Mon, 28 Jun 2021 10:19:50 -0400 Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0BB3EC061574 for ; Mon, 28 Jun 2021 07:17:25 -0700 (PDT) Received: by mail-wm1-x32f.google.com with SMTP id g198so3638439wme.5 for ; Mon, 28 Jun 2021 07:17:24 -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=JuNJweosuipucr4vhg0XhclqW1q8Ja8Oi1r1gTGSAjc=; b=QygiPxCHhdIGBTdAvUgBSVXLuBadR+p7jLqHUw3tyMpunPOzeNyjovnSSD4TTT8RyR roQKK2BbsVBmSHAm82YwdthcpaN6J1rsmeJDjV+amE+v6tEduKw9K7g7mmt0kJtd7Nfp UQAvV6s5pggiDGHDClkwZeIzyRhXCZaoWP4WGsh1cPHqyoa7iDDn8/aENJ+IeWrRnu2G hmd4HFBwUJT7E9zf3P6+wjpgjCP+yzvVbghQXOYY59H8jn1PBm8z7WW5l4aIFSSuvE8g fhoygFTLfbUVeAr0gg0mMAtXS9yHuqhCoNie5QwM0W5I0NYiZ/F7DPgMewo5ruLID+iI +l3Q== 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=JuNJweosuipucr4vhg0XhclqW1q8Ja8Oi1r1gTGSAjc=; b=L/roz/xDxESqhtEkfL7b49KB7GM4ify/+Verl+/MAJo6n87PtvKcU376caef+h28LA rlnp4pDToyTN/9Rp6OE2OZMhZeePFtJcZpO2VqneRrA/i4Tunem5XO+KaapzIM2rKwLD jx6phcmCJbYeXzTUjXthkheWBn+ad5Yq86HR/eIVL9oXOkWY2Y+Cnihcrtl25w3CPV4e 3j64P5XSqyO4G6UYS1WkxPAHnBJp56Mpl/Q9g8MvgL+q9XdlQcI16rpB9fDIdZt7IpC0 2MmEjk+AdKlX4kNXXJRDexLGNOFi9B/MJs9aTDUJrWZ/aJmc/YLHYz3haazw95rESQFC rGRA== X-Gm-Message-State: AOAM533GnkQ3RMIwj7djXUQT87RY4XW6Y33TtO2v2XaZrFH5kojOHbQO csXhmphToCL/TMxVMzOcB32QEw== X-Received: by 2002:a05:600c:2318:: with SMTP id 24mr27530614wmo.36.1624889843664; Mon, 28 Jun 2021 07:17:23 -0700 (PDT) Received: from neptune.anevia.com (ip-149-62-159-73.naitways.net. [149.62.159.73]) by smtp.gmail.com with ESMTPSA id x81sm22524012wmg.36.2021.06.28.07.17.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Jun 2021 07:17:23 -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: da280: convert probe to device-managed functions Date: Mon, 28 Jun 2021 17:17:09 +0300 Message-Id: <20210628141709.80534-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/da280.c | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/drivers/iio/accel/da280.c b/drivers/iio/accel/da280.c index 5edff9ba72da..9633bdae5fd4 100644 --- a/drivers/iio/accel/da280.c +++ b/drivers/iio/accel/da280.c @@ -100,6 +100,11 @@ static enum da280_chipset da280_match_acpi_device(struct device *dev) return (enum da280_chipset) id->driver_data; } +static void da280_disable(void *client) +{ + da280_enable(client, false); +} + static int da280_probe(struct i2c_client *client, const struct i2c_device_id *id) { @@ -118,7 +123,6 @@ static int da280_probe(struct i2c_client *client, data = iio_priv(indio_dev); data->client = client; - i2c_set_clientdata(client, indio_dev); indio_dev->info = &da280_info; indio_dev->modes = INDIO_DIRECT_MODE; @@ -142,22 +146,11 @@ static int da280_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"); - da280_enable(client, false); - } - - return ret; -} - -static int da280_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, da280_disable, client); + if (ret) + return ret; - return da280_enable(client, false); + return devm_iio_device_register(&client->dev, indio_dev); } #ifdef CONFIG_PM_SLEEP @@ -194,7 +187,6 @@ static struct i2c_driver da280_driver = { .pm = &da280_pm_ops, }, .probe = da280_probe, - .remove = da280_remove, .id_table = da280_i2c_id, }; -- 2.31.1