Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp353345pxv; Thu, 15 Jul 2021 05:58:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxRaF1ecQeMvXOystRYbiPROy7mtFvStZ417htuzwrMK53WcgxbwAJDcjzEzzGabcw37cUx X-Received: by 2002:a5e:9e02:: with SMTP id i2mr3109529ioq.198.1626353894404; Thu, 15 Jul 2021 05:58:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626353894; cv=none; d=google.com; s=arc-20160816; b=y2MB0yXBi1qyNXErjVSOA3Tv0OnvxK5Wsxm9e0/QF+b0QQaK+eM2Uw8kL8fBp9PsKK LxnSXZM3NSBT4p/Ub+k6Gi7yltwusNmw+xTTZukqcVN3Bb06QD6vKfFh8KIxUl5MAfnw YegyGdoBcxv9No809cO7ALjLK3HRc7z1h4aefDBcQHbHqtnPgWZ9JqswyKT0IwqSTCqP EKdTI9thHz+lkUVUUqqDVqdqvfu2sYMdcIPKcJfGknj7KyWubomGxGhCLTfoSoaCBrI7 C6FY75cUCWqnW864W2WRXRV8mHM2rqHyDa1UMuODT7rLWId4z/f8lGnG//p1p/L56GUt i0WA== 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 :organization:references:in-reply-to:message-id:subject:cc:to:from :date; bh=5KeZmNYv2+oxFXirKfWq4bTfW/V2n1fDhPXCqxeBXcM=; b=ps0oxnDX2jZ/X5ptPc+5STfEwg0DjXqycXtUVO5HtS7xv1p/8ubaWJKqkgcLz7sgtv BqRoghT04lMJKbkjeHAM/0DTUHEna39gDBcVBe3Bz3jNLKJbRjZw4UaxPdnjs4YLHvVg igzfhWO2QdVUN+7AWCVzI/dVVRFajFE5HMPmax9aIZFA/fZRMlzu5XpdlxMkfJUgRT7r wwlAyrkRTGsNxd6dgGuUnFMExX8g2cdxdF2PWmnuGPdy/SjVM4GeYZGiKZuFTULkKJpS nhc+/a6+xiNIrMuzVe2YDlhRh2NH7FKIysu4UEgfohIQ0mJN807/4q/4dYxKEuYoItmo l+Ng== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a21si6579665jam.67.2021.07.15.05.57.58; Thu, 15 Jul 2021 05:58:14 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231921AbhGOMzj (ORCPT + 99 others); Thu, 15 Jul 2021 08:55:39 -0400 Received: from frasgout.his.huawei.com ([185.176.79.56]:3415 "EHLO frasgout.his.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231224AbhGOMzi (ORCPT ); Thu, 15 Jul 2021 08:55:38 -0400 Received: from fraeml715-chm.china.huawei.com (unknown [172.18.147.226]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4GQYs670FPz6L8SL; Thu, 15 Jul 2021 20:41:30 +0800 (CST) Received: from lhreml710-chm.china.huawei.com (10.201.108.61) by fraeml715-chm.china.huawei.com (10.206.15.34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Thu, 15 Jul 2021 14:52:42 +0200 Received: from localhost (10.47.82.59) by lhreml710-chm.china.huawei.com (10.201.108.61) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Thu, 15 Jul 2021 13:52:41 +0100 Date: Thu, 15 Jul 2021 13:52:21 +0100 From: Jonathan Cameron To: Anand Ashok Dumbre CC: Jonathan Cameron , "lars@metafoo.de" , "linux-iio@vger.kernel.org" , git-dev , Michal Simek , "pmeerw@pmeerw.net" , "devicetree@vger.kernel.org" , "linux-kernel@vger.kernel.org" , Manish Narani Subject: Re: [PATCH v6 2/4] iio: adc: Add Xilinx AMS driver Message-ID: <20210715135221.00001d4f@Huawei.com> In-Reply-To: References: <20210624182939.12881-1-anand.ashok.dumbre@xilinx.com> <20210624182939.12881-3-anand.ashok.dumbre@xilinx.com> <20210704193108.20e19692@jic23-huawei> Organization: Huawei Technologies Research and Development (UK) Ltd. X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.33; i686-w64-mingw32) MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.47.82.59] X-ClientProxiedBy: lhreml732-chm.china.huawei.com (10.201.108.83) To lhreml710-chm.china.huawei.com (10.201.108.61) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org ... > > > > > + if (IS_ERR(ams->base)) > > > + return PTR_ERR(ams->base); > > > + > > > + ams->clk = devm_clk_get(&pdev->dev, NULL); > > > + if (IS_ERR(ams->clk)) > > > + return PTR_ERR(ams->clk); > > > + clk_prepare_enable(ams->clk); > > > + devm_add_action_or_reset(&pdev->dev, (void > > *)clk_disable_unprepare, > > > + ams->clk); > > > + > > > + INIT_DELAYED_WORK(&ams->ams_unmask_work, > > ams_unmask_worker); > > > + devm_add_action_or_reset(&pdev->dev, (void > > *)cancel_delayed_work, > > > > I'm not keen on casting away the function pointer type. Normally we'd just > > wrap it in a local function, to make it clear it was deliberate and avoid > > potential nasty problems if the signature of the function ever changes. > > > > It's 3 lines of boilerplate, but will give me warm fuzzy feelings! > > Same for the other case above. The fact this isn't done in exising kernel code > > make this particularly risky. > > Makes sense. I will revert the code back to its original and handle the cases using goto > and inside remove() Ah. Not what I meant. I was suggesting you add a little function locally that has the right type and in turn calls cancel_delayed_work(). As that directly exposes the actual function calls, any signature change in future will cause compile breakage (or be picked up any automated tools doing that refactor). > > > > > > + &ams->ams_unmask_work); > > > + > > > + ret = ams_init_device(ams); > > > + if (ret) { > > > + dev_err(&pdev->dev, "failed to initialize AMS\n"); > > > + return ret; > > > + } > > > + > > > + ret = ams_parse_dt(indio_dev, pdev); > > > + if (ret) { > > > + dev_err(&pdev->dev, "failure in parsing DT\n"); > > > + return ret; > > > + } > > > + > > > + ams_enable_channel_sequence(indio_dev); > > > + > > > + ams->irq = platform_get_irq(pdev, 0); > > > > platform_get_irq () can return errors, in particular -EPROBE_DEFER so I'd > > check that and return before you call devm_request_irq() I'm not sure > > devm_request_irq() will not eat that error code. > > > > Will fix this in next series. > > > > > > + ret = devm_request_irq(&pdev->dev, ams->irq, &ams_irq, 0, "ams- > > irq", > > > + indio_dev); > > > + if (ret < 0) { > > > + dev_err(&pdev->dev, "failed to register interrupt\n"); > > > + return ret; > > > + } > > > + > > > + platform_set_drvdata(pdev, indio_dev); > > > + > > > + return iio_device_register(indio_dev); } > > > + > > > +static int ams_remove(struct platform_device *pdev) { > > > + struct iio_dev *indio_dev = platform_get_drvdata(pdev); > > > + > > > + iio_device_unregister(indio_dev); > > > > If this is all you have in remove, then you can use devm_iio_device_register() > > in probe() and not need an remove() callback at all. > > I think remove will have more functions since I am getting rid of devm_add_action_or_reset() See above. J > > > > > > + > > > + return 0; > > > +} > > > + > > > > ...