Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp231584pxb; Fri, 3 Sep 2021 00:30:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzYItpsVlhG51mXSfrcxIeO8BDmyA7dknwt7kw1Dbj4qBJHkCqb66l8FJY7eZ8v5NsAj48Y X-Received: by 2002:a6b:5c0c:: with SMTP id z12mr1935627ioh.171.1630654255128; Fri, 03 Sep 2021 00:30:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630654255; cv=none; d=google.com; s=arc-20160816; b=g7Ih6AhM+6kh7FI6laDeL53bkyIBadR2J10ZBvniItEII3zyeCscPxbeoI3eKG78vh yeTyRq1jJ1+czOjWzXnmf7rVMDtrBBdeTBpXgUdfczzXUKEcFibNdcNZR7G1ADxJI3ib inv3UBhxBDgkg2sIIsImzOiGHkdd1Q5NOBpIjjUbbM3eMkW4ldjI3nKVZ5itqdYZOpco 4TnnWlUmhr3E6vy/YoBimywNx5N23MBiHGGw9XV5G+Txa9sEsui8IEB8T5e4miDPZKbk yLRl32hN8nsujvSNdpM31gmBY40H0z5B9DXitzwaYlRFZpS4zMJpAuGQnJSRhgIk6Ecn 78MA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=HnKxxaQYNnWTD9UVNnr24MR8zjRJb29eptl0bMy8Qq4=; b=CYS1c6VOlmP1QQ6ld2Rm7PrlwNIMCTAu4VVv84aWkwiFs1RdWVU1FzFzY+uhlyUZo3 2gl/P7FCemQic9FIOXOAaDsmI5j7nKccvFajwdDQCd4C6JVUT1sg4ooAfWP5YsaDD3v4 iR1VuggAVEDpQSH8WnKxNuDg3MfBJa5KG38QTi6hT5lT7EswOrQP9C8bgJOJ008pVun0 OCIJLzaiCZjtFA4ElGtwhpWemS9Ci+fHYs2Io/OUiMQeKq2wB01IKp+YeKV5HTE+0Peo BMa0sc5I2I+Hv4U9V1Fo9iFqrQo9evm5U3NJlmCDBFNWgGBIPCWMYojS+xf+zUJdtVZ6 KE0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@deviqon.com header.s=google header.b=Qcz0qeTu; 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 g13si4531446jao.114.2021.09.03.00.30.35; Fri, 03 Sep 2021 00:30:55 -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=Qcz0qeTu; 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 S1347975AbhICHai (ORCPT + 99 others); Fri, 3 Sep 2021 03:30:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54888 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347932AbhICHaf (ORCPT ); Fri, 3 Sep 2021 03:30:35 -0400 Received: from mail-ej1-x629.google.com (mail-ej1-x629.google.com [IPv6:2a00:1450:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EA3FEC061757 for ; Fri, 3 Sep 2021 00:29:34 -0700 (PDT) Received: by mail-ej1-x629.google.com with SMTP id a25so10174006ejv.6 for ; Fri, 03 Sep 2021 00:29:34 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=HnKxxaQYNnWTD9UVNnr24MR8zjRJb29eptl0bMy8Qq4=; b=Qcz0qeTuAYOCren9Bte0rJrya/cpxtrK46NHFyqZw0Mlz1MB0RvC//GSaMk1pNJsge u1l1AxWZiJhMBK3JzofjfGSEYBUpXsUTMBf7NUbECF+itGa3CujJQbKacFN0ry9qY5sb uD0p6ZLx1KxONRQOhQCaMz4UJdNRNYFC7TLCEznC3HyfY1/arEYDJd+NiTAWJUrknYiV CPd+1Bm/vFwa4fA2rAD53RKml9MaerqrAEZcJj98yco2ot1fxHdEqhXaqZB3eT+HMsks kERZJGTZlreijmnTbeJsYTlUP9q9ayz1Y5ORKOI0wVDAFuuQ9zPqA3T3pzQC3Vrt0PV1 HqpA== 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=HnKxxaQYNnWTD9UVNnr24MR8zjRJb29eptl0bMy8Qq4=; b=uTqm3J/Rbf+ttRLNxi/mil7z8yV4XrhdN6VIMCySdoGvBYmEQklk010HxL9x70Er9I P7u2G5ml1czh/hBr0kegOMoxXJoWjQj+/+iUqiWPDHJ5veiVK+eFjfH2F6fRil8bmKIV KTkQiLx7IMA4quuhH0xHa/2WXYtZawjr+RU5fdt9+v9sbWG7/mdfSJr4RJsND7zMY84m twdSRYWV3BnI2FyP0TbTnmVQj4g+pkLvqtdt0QER2iF8vjBoGhbZvPwwB48WlMy4w4Vh H1ZJeCVEM5l6s03C+XaK9n6P+H90kV9SFXhYfg8/bVlZ/zIMZTPyXuJ+iaJUZ5s0WmBf TzTg== X-Gm-Message-State: AOAM532C2pCPTLvDpHuwQviHNZy1eIjO7n1nxpZNh7dXs7dd+3pAIO+P qTDiQH7zsrp4DRxD1OeFTrtlLvZz52nlYQ== X-Received: by 2002:a17:906:d20a:: with SMTP id w10mr2724357ejz.426.1630654173566; Fri, 03 Sep 2021 00:29:33 -0700 (PDT) Received: from neptune.. ([5.2.193.191]) by smtp.gmail.com with ESMTPSA id a15sm2376969edr.2.2021.09.03.00.29.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Sep 2021 00:29:33 -0700 (PDT) From: Alexandru Ardelean To: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org Cc: jic23@kernel.org, hdegoede@redhat.com, wens@csie.org, andriy.shevchenko@linux.intel.com, Alexandru Ardelean Subject: [PATCH 3/5] iio: adc: axp288_adc: convert probe to full device-managed Date: Fri, 3 Sep 2021 10:29:15 +0300 Message-Id: <20210903072917.45769-4-aardelean@deviqon.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210903072917.45769-1-aardelean@deviqon.com> References: <20210903072917.45769-1-aardelean@deviqon.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This change converts the probe of this driver to use device-managed functions only, which means that the remove hook can be removed. The remove hook has only 2 calls to iio_device_unregister() and iio_map_array_unregister(). Both these can now be done via devm register functions, now that there's also a devm_iio_map_array_register() function. The platform_set_drvdata() can also be removed now. This change also removes the error print for when the iio_device_register() call fails. This isn't required now. Signed-off-by: Alexandru Ardelean --- drivers/iio/adc/axp288_adc.c | 28 ++++------------------------ 1 file changed, 4 insertions(+), 24 deletions(-) diff --git a/drivers/iio/adc/axp288_adc.c b/drivers/iio/adc/axp288_adc.c index 5f5e8b39e4d2..a4b8be5b8f88 100644 --- a/drivers/iio/adc/axp288_adc.c +++ b/drivers/iio/adc/axp288_adc.c @@ -259,7 +259,7 @@ static int axp288_adc_probe(struct platform_device *pdev) info->irq = platform_get_irq(pdev, 0); if (info->irq < 0) return info->irq; - platform_set_drvdata(pdev, indio_dev); + info->regmap = axp20x->regmap; /* * Set ADC to enabled state at all time, including system suspend. @@ -276,31 +276,12 @@ static int axp288_adc_probe(struct platform_device *pdev) indio_dev->num_channels = ARRAY_SIZE(axp288_adc_channels); indio_dev->info = &axp288_adc_iio_info; indio_dev->modes = INDIO_DIRECT_MODE; - ret = iio_map_array_register(indio_dev, axp288_adc_default_maps); + + ret = devm_iio_map_array_register(&pdev->dev, indio_dev, axp288_adc_default_maps); if (ret < 0) return ret; - ret = iio_device_register(indio_dev); - if (ret < 0) { - dev_err(&pdev->dev, "unable to register iio device\n"); - goto err_array_unregister; - } - return 0; - -err_array_unregister: - iio_map_array_unregister(indio_dev); - - return ret; -} - -static int axp288_adc_remove(struct platform_device *pdev) -{ - struct iio_dev *indio_dev = platform_get_drvdata(pdev); - - iio_device_unregister(indio_dev); - iio_map_array_unregister(indio_dev); - - return 0; + return devm_iio_device_register(&pdev->dev, indio_dev); } static const struct platform_device_id axp288_adc_id_table[] = { @@ -310,7 +291,6 @@ static const struct platform_device_id axp288_adc_id_table[] = { static struct platform_driver axp288_adc_driver = { .probe = axp288_adc_probe, - .remove = axp288_adc_remove, .id_table = axp288_adc_id_table, .driver = { .name = "axp288_adc", -- 2.31.1