Received: by 2002:a05:6358:16cd:b0:dc:6189:e246 with SMTP id r13csp570108rwl; Fri, 4 Nov 2022 03:59:41 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6OloDw5cVj9yGSEoWrDlPS9e6mYimOfmef5LaGo1aEAZeX5ruDhV3bugCqAkZGkr3Uv1DW X-Received: by 2002:a05:6a02:112:b0:440:5515:b908 with SMTP id bg18-20020a056a02011200b004405515b908mr29925542pgb.13.1667559581117; Fri, 04 Nov 2022 03:59:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667559581; cv=none; d=google.com; s=arc-20160816; b=VQh52vhqrOqFcxVsonxxHXlqIaNc3QwEbFPcbGCLk9bZtplD0FwdsLTWuph/Ry7Ob3 bUqcvT82RFD6A8AQ3A/N0g1DbRRdHtnEdoxH+JZY2/DGIL9qWgwUG2D1aaQTvoU0/1g+ plsvufhVUJP0U5suW3LOH3A9QhsU7aJ0f1faLlrKDy+ZylUQPD12O6VHCQJwkU39IhSk 2N8HcGuH6nQwZKLm9l3OBDBUnUwlUBVaW+hEsG5zMKZsV7A9HfEK/H9BSBZ1p+y7CYiI HzD82WFOIc7EvA56ALNEr0pcQxj3R8BlusDOIn1BecuOrYzaIoCdGipLsnahJeBNLjkq 6FQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:cc:from :references:to:content-language:subject:user-agent:mime-version:date :message-id; bh=mxaqprzLOBKLL87LZjgTMq59kVIqpSv+c2VoD2MMz78=; b=WRqqQJJoKudbtNQ7w6PDBSY7aA9GeuCqs4oapR/PAsQM31+cKrlGW+04qEBbE/Zhcp +xoF7aWFZcXD8fvP8hFIDWgqYt3yv8yVE3Pf+Y/5EPGnYSqo7jGlI4h8GHGjLZfI6Qxw FEJU+66RczASaaeB6ilT+t5+ysGFX4t7qidJyiI6wdqvrtGwVprQiDAODTckWoq53KHd MhYpWEz/1trCIwBlx79eWOOK25odwk/7liDabYU7Mx0G2pyZuCCty/MEknlFhfxYi90V Ot0fPShc99LxlE2HTs3DQuoJy0KpqlQlxV7q3xs0FfDbR1B0YLaGg0kKVn3MWlHnGlrA Kxcg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o3-20020a056a0015c300b0056d89d8fba7si5022720pfu.154.2022.11.04.03.59.29; Fri, 04 Nov 2022 03:59:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231437AbiKDJq7 (ORCPT + 96 others); Fri, 4 Nov 2022 05:46:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58760 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231302AbiKDJqx (ORCPT ); Fri, 4 Nov 2022 05:46:53 -0400 Received: from smtp.smtpout.orange.fr (smtp-21.smtpout.orange.fr [80.12.242.21]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7B4946317 for ; Fri, 4 Nov 2022 02:46:50 -0700 (PDT) Received: from [192.168.1.18] ([86.243.100.34]) by smtp.orange.fr with ESMTPA id qtHkoE990iBgAqtHkogqeF; Fri, 04 Nov 2022 10:46:49 +0100 X-ME-Helo: [192.168.1.18] X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Fri, 04 Nov 2022 10:46:49 +0100 X-ME-IP: 86.243.100.34 Message-ID: <1325d0d4-1bff-af36-08c2-b4a9f01a4cd0@wanadoo.fr> Date: Fri, 4 Nov 2022 10:46:47 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.2.2 Subject: Re: [PATCH 2/4] iio: frequency: adf4377: add support for ADF4377 Content-Language: fr To: antoniu.miclaus@analog.com References: <20221104092802.90725-1-antoniu.miclaus@analog.com> <20221104092802.90725-3-antoniu.miclaus@analog.com> From: Christophe JAILLET Cc: devicetree@vger.kernel.org, jic23@kernel.org, krzysztof.kozlowski+dt@linaro.org, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, robh+dt@kernel.org In-Reply-To: <20221104092802.90725-3-antoniu.miclaus@analog.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Le 04/11/2022 à 10:28, Antoniu Miclaus a écrit : > The ADF4377 is a high performance, ultralow jitter, dual output integer-N > phased locked loop (PLL) with integrated voltage controlled oscillator > (VCO) ideally suited for data converter and mixed signal front end (MxFE) > clock applications. > > Datasheet: https://www.analog.com/media/en/technical-documentation/data-sheets/adf4377.pdf > Signed-off-by: Antoniu Miclaus > --- [] > +static int adf4377_properties_parse(struct adf4377_state *st) > +{ > + struct spi_device *spi = st->spi; > + > + st->clkin = devm_clk_get(&spi->dev, "ref_in"); Hi, this could be devm_clk_get_enabled() in order to... > + if (IS_ERR(st->clkin)) > + return dev_err_probe(&spi->dev, PTR_ERR(st->clkin), > + "failed to get the reference input clock\n"); > + > + st->gpio_ce = devm_gpiod_get_optional(&st->spi->dev, "ce-en", > + GPIOD_OUT_HIGH); > + if (IS_ERR(st->gpio_ce)) > + return dev_err_probe(&spi->dev, PTR_ERR(st->gpio_ce), > + "failed to get the CE GPIO\n"); > + > + st->gpio_enclk1 = devm_gpiod_get_optional(&st->spi->dev, "enclk1", > + GPIOD_OUT_HIGH); > + if (IS_ERR(st->gpio_enclk1)) > + return dev_err_probe(&spi->dev, PTR_ERR(st->gpio_enclk1), > + "failed to get the CE GPIO\n"); > + > + if (st->type == ADF4377) { > + st->gpio_enclk2 = devm_gpiod_get_optional(&st->spi->dev, "enclk2", > + GPIOD_OUT_HIGH); > + if (IS_ERR(st->gpio_enclk2)) > + return dev_err_probe(&spi->dev, PTR_ERR(st->gpio_enclk2), > + "failed to get the CE GPIO\n"); > + } > + > + return 0; > +} > + > +static int adf4377_freq_change(struct notifier_block *nb, unsigned long action, void *data) > +{ > + struct adf4377_state *st = container_of(nb, struct adf4377_state, nb); > + int ret; > + > + if (action == POST_RATE_CHANGE) { > + mutex_lock(&st->lock); > + ret = notifier_from_errno(adf4377_init(st)); > + mutex_unlock(&st->lock); > + return ret; > + } > + > + return NOTIFY_OK; > +} > + > +static void adf4377_clk_disable(void *data) > +{ > + clk_disable_unprepare(data); > +} ... remove this... > + > +static int adf4377_probe(struct spi_device *spi) > +{ > + struct iio_dev *indio_dev; > + struct regmap *regmap; > + struct adf4377_state *st; > + int ret; > + > + indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st)); > + if (!indio_dev) > + return -ENOMEM; > + > + regmap = devm_regmap_init_spi(spi, &adf4377_regmap_config); > + if (IS_ERR(regmap)) > + return PTR_ERR(regmap); > + > + st = iio_priv(indio_dev); > + > + indio_dev->info = &adf4377_info; > + indio_dev->name = "adf4377"; > + indio_dev->channels = adf4377_channels; > + indio_dev->num_channels = ARRAY_SIZE(adf4377_channels); > + > + st->regmap = regmap; > + st->spi = spi; > + st->type = spi_get_device_id(spi)->driver_data; > + mutex_init(&st->lock); > + > + ret = adf4377_properties_parse(st); > + if (ret) > + return ret; > + > + ret = clk_prepare_enable(st->clkin); > + if (ret) > + return ret; ... and this... > + > + ret = devm_add_action_or_reset(&spi->dev, adf4377_clk_disable, st->clkin); > + if (ret) > + return ret; ... and this. CJ > + > + st->nb.notifier_call = adf4377_freq_change; > + ret = devm_clk_notifier_register(&spi->dev, st->clkin, &st->nb); > + if (ret) > + return ret; > + > + ret = adf4377_init(st); > + if (ret) { > + dev_err(&spi->dev, "adf4377 init failed\n"); > + return ret; > + } > + > + return devm_iio_device_register(&spi->dev, indio_dev); > +} []