Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp1047479iob; Fri, 13 May 2022 21:01:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx0Q/reZv+dr8RBJjZ3d6XUvKp+Is4hi91yXbHi9nrkKNFY4068fgAXUo3GX/uQEjiLARNz X-Received: by 2002:adf:fe10:0:b0:20c:4fd8:1d68 with SMTP id n16-20020adffe10000000b0020c4fd81d68mr6181670wrr.388.1652500874539; Fri, 13 May 2022 21:01:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652500874; cv=none; d=google.com; s=arc-20160816; b=Y+TX4XsSKSYIla5KPWXtTNqkc78NmuhlJk1OwiX4agd+SlOt4ND3pHxsG65W3jERs9 aNAvRJ4nvJPRlMVte03WNXqVDmc8T4Il0a7Yz34R94TL9aGCD9YV9oRTgF7YUdxO2mPQ uLMZsQhxA6fJUEf99WLFk6y4u/04bv24xCBIq/HtrieXnLJ2TFLAHLCaFBaPz+Ga4r7D 0uA52NEjGxNb2Cq5R1Ntwlhi1eutzkQtjVBthFg3fbcFKt2QTeeXdXHuafQhKYizV3eE PIfWUXCHxY3q8osNKL8HJhwejo63qJ1/tDhSpK3GgdNjuzyeQKOI9HyuPPCTsg4cApkp B05A== 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:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature:dkim-signature; bh=tRQS9L/0bznAdWbDafHhTvbRIqnEumt8vUfzjQrF2aY=; b=N75GqE2/a2bopLyUvFmxPRrwT/GeaJOPSF3TBm1hN+QfBz59uliZ3ZkI+RuHw2H2sc vbAu8reAqXAbSbJ1ifU4JTWvR7uonrmVG9/kjtR0iQY0B8r2yqwPr1ju0GJCphUQN3HA USf+nCr4Ku1IcLHD5EIj10XVhU8ZFVuv0BmF5dN+RcHI0O8qubix3yiBm2Hxsdu7tRH2 pdQa9j/cIaAztQgoJxL1GJEhQHdhrTPuP11m2uHN9icY+6A4dU0TayAh6goklHWdcH9L kwMKU97VM6HGC3rXphD4M+Sv8G3PMto4f2Q1r5yNDd6RPwTGuQA9lGfzNsQqjmc+3x/U T8Kw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=tBEJeDGa; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=2yaVCxnn; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id g5-20020adffc85000000b00207a7d7ba74si3676583wrr.64.2022.05.13.21.01.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 May 2022 21:01:14 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=tBEJeDGa; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=2yaVCxnn; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 3C60B4A6140; Fri, 13 May 2022 17:32:34 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350440AbiELGbr (ORCPT + 99 others); Thu, 12 May 2022 02:31:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45096 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350455AbiELGbo (ORCPT ); Thu, 12 May 2022 02:31:44 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 099DC590AE; Wed, 11 May 2022 23:31:38 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 9F6751F8D1; Thu, 12 May 2022 06:31:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1652337096; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=tRQS9L/0bznAdWbDafHhTvbRIqnEumt8vUfzjQrF2aY=; b=tBEJeDGa5baSIwxn79Wzt2IGDPoxfom0djedUuiHJPkxhKRjYsQVgbLeW1/RmtdD4qBStd JhanFA1ChP2fo9Ap5al2uL8WfYKvYGzqnQI7KsO6sbRKyHyoE5GmyX14hUG+3XcODwC6Q+ 4lcbiUH5GCtzqvnDQykqIDO+tlgTg1A= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1652337096; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=tRQS9L/0bznAdWbDafHhTvbRIqnEumt8vUfzjQrF2aY=; b=2yaVCxnnyGHVu31nVMoEONHw/E9ouHo/YIbgDA4UMG1ro591mbKuerkia4J2Lqt9RREeM4 wXKXdMI3R6sXLhDw== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 88C8F13ABE; Thu, 12 May 2022 06:31:36 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id ccnqH8ipfGL5TwAAMHmgww (envelope-from ); Thu, 12 May 2022 06:31:36 +0000 Message-ID: <558a7c85-03a2-8c30-5b2e-80cc88b7e693@suse.de> Date: Thu, 12 May 2022 08:31:35 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.4.0 Subject: Re: [PATCH v3 07/23] ata: libahci_platform: Convert to using devm bulk clocks API Content-Language: en-US To: Serge Semin , Damien Le Moal , Hans de Goede , Jens Axboe Cc: Serge Semin , Alexey Malahov , Pavel Parkhomenko , Rob Herring , linux-ide@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org References: <20220511231810.4928-1-Sergey.Semin@baikalelectronics.ru> <20220511231810.4928-8-Sergey.Semin@baikalelectronics.ru> From: Hannes Reinecke In-Reply-To: <20220511231810.4928-8-Sergey.Semin@baikalelectronics.ru> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,RDNS_NONE,SPF_HELO_NONE, T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 On 5/12/22 01:17, Serge Semin wrote: > In order to simplify the clock-related code there is a way to convert the > current fixed clocks array into using the common bulk clocks kernel API > with dynamic set of the clock handlers and device-managed clock-resource > tracking. It's a bit tricky due to the complication coming from the > requirement to support the platforms (da850, spear13xx) with the > non-OF-based clock source, but still doable. > > Before this modification there are two methods have been used to get the > clocks connected to an AHCI device: clk_get() - to get the very first > clock in the list and of_clk_get() - to get the rest of them. Basically > the platforms with non-OF-based clocks definition could specify only a > single reference clock source. The platforms with OF-hw clocks have been > luckier and could setup up to AHCI_MAX_CLKS clocks. Such semantic can be > retained with using devm_clk_bulk_get_all() to retrieve the clocks defined > via the DT firmware and devm_clk_get_optional() otherwise. In both cases > using the device-managed version of the methods will cause the automatic > resources deallocation on the AHCI device removal event. The only > complicated part in the suggested approach is the explicit allocation and > initialization of the clk_bulk_data structure instance for the non-OF > reference clocks. It's required in order to use the Bulk Clocks API for > the both denoted cases of the clocks definition. > > Note aside with the clock-related code reduction and natural > simplification, there are several bonuses the suggested modification > provides. First of all the limitation of having no greater than > AHCI_MAX_CLKS clocks is now removed, since the devm_clk_bulk_get_all() > method will allocate as many reference clocks data descriptors as there > are clocks specified for the device. Secondly the clock names are > auto-detected. So the LLDD (glue) drivers can make sure that the required > clocks are specified just by checking the clock IDs in the clk_bulk_data > array. Thirdly using the handy Bulk Clocks kernel API improves the > clocks-handling code readability. And the last but not least this > modification implements a true optional clocks support to the > ahci_platform_get_resources() method. Indeed the previous clocks getting > procedure just stopped getting the clocks on any errors (aside from > non-critical -EPROBE_DEFER) in a way so the callee wasn't even informed > about abnormal loop termination. The new implementation lacks of such > problem. The ahci_platform_get_resources() will return an error code if > the corresponding clocks getting method ends execution abnormally. > > Signed-off-by: Serge Semin > > --- > > Changelog v2: > - Convert to checking the error-case first in the devm_clk_bulk_get_all() > method invocation. (@Damien) > - Fix some grammar mistakes in the comments. > --- > drivers/ata/ahci.h | 4 +- > drivers/ata/libahci_platform.c | 84 ++++++++++++++++------------------ > 2 files changed, 41 insertions(+), 47 deletions(-) > Reviewed-by: Hannes Reinecke Cheers, Hannes -- Dr. Hannes Reinecke Kernel Storage Architect hare@suse.de +49 911 74053 688 SUSE Software Solutions Germany GmbH, Maxfeldstr. 5, 90409 Nürnberg HRB 36809 (AG Nürnberg), GF: Felix Imendörffer