Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp306781rdb; Thu, 30 Nov 2023 05:31:21 -0800 (PST) X-Google-Smtp-Source: AGHT+IEAtXM3CudSdkI+HFhLenwbGIvFdI3yTxkhILlv+pOA7FmvfjYfraNRB0Ed9li7H9E/AEdt X-Received: by 2002:a05:6a20:1483:b0:186:e53:b64b with SMTP id o3-20020a056a20148300b001860e53b64bmr15898915pzi.47.1701351080557; Thu, 30 Nov 2023 05:31:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701351080; cv=none; d=google.com; s=arc-20160816; b=JaAswQqUPAm9EzHuQfgS/0AO0n5TmOoVZt4fcASobhk2BuAMuMyXteVp7/OVG5xdav x25IBvfk1eKkRB0JEyNXq1XduPdHy96ZTp3jxVjH3dGOXR4RVHBdSEJSQTGIci2jwyQ+ vpuRabVstjs2W1K+4DAi8nGLxCxvAedcyjpnz1QCM5U0BfOoqaAIX4VDbxrx6hoVs636 MXcoEbb17wEfL8ZuErtM9FCqxgz0EqQIF46UrpU0hAnU2G2wGbsFXcsVi/CIn0NY4oHv BqKay0tn5sgvafznGXyJvFvF8f5WbhuGfQ5g8ouusCscZZMFe9aAPnsD0vddtTEVyvGV K+hg== 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; bh=T9p5K8kMNd+W5DrTwW+yqwhzwLYmCfLClSIkhzDTrDI=; fh=ZoD3UlJTHciOmcv7UrIS6WfcVCmveUnIERON7S5Ndyg=; b=pTHnfkFoaBVTFxIJB1TrKaXvD5zs9dxU9SGs5kztCEPzuz13LP3i8pkMKdlOjujKNQ lVsmXdgXRiAq1yfMOzFbJ8XKExZlvt0v0P1DqBZvW8cRMs8NVT3DEasr5XNYeBUnuLHu HzkZ8GkFFPlwlJP5GoQsL5qA8zGzqYbwgYKJMb1TLvk9Ca9TwhL3k2fC0hbx2goS+q2q /mFxxcOc0LbyawWNinvTEybd25LA4VV3GcPD8YqACgHFUD68MtZB9dfqJK4ExkQ9J9HF a8PsrmHvE/U8INTVEqQa7OEX+er0O0RIG73wmLE2RMy0N8VwEZ/J5SScfVBgp+2NDjGv pfdg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=jtW0lJYR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id x20-20020a634a14000000b005c62a23ddffsi1032021pga.778.2023.11.30.05.31.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 05:31:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=jtW0lJYR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 57F7E809F382; Thu, 30 Nov 2023 05:31:17 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345565AbjK3Na5 (ORCPT + 99 others); Thu, 30 Nov 2023 08:30:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37938 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345610AbjK3Nax (ORCPT ); Thu, 30 Nov 2023 08:30:53 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 31C8610F0 for ; Thu, 30 Nov 2023 05:31:00 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 69D8AC433C7; Thu, 30 Nov 2023 13:30:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1701351059; bh=GGplx6KpuPLw09bMktqftv7giakn9VmpBAD9cWeP0fc=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=jtW0lJYRSL7dznQ7fezXH+buD8jYnkyUoT+HbKbWKbxCAi3sst+qXhzIVNiL6c7Uz lvZJyolOYkJz35OkUIAzCVzb+nCibFIrfj2qpe8l1oKuF6ruc+GGttu89pSFf/I0xo 873vChbi5Uqk3YqnGmk3U6S4/0OCgexyUbV7JstzO8o5MxJbeTBFksjnP7hCQL+LMY a18ka/HuHx1xp6MAKwZPzTOJFOQwRE9eFA9pfX0yRIAt9fdOlrI4DwQFuSyq19Hsc5 oLulGoS2LS3QzpMc+0/3ao8X1THpu5N3FpwUZgcthjb+NgNU6yH82WaGEHj5b9+fmq XuWTLEuS2gSVA== Message-ID: <292f5d48-8567-4b60-ad03-6cf70f71bacc@kernel.org> Date: Thu, 30 Nov 2023 15:30:54 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] USB: typec: tps6598x: use device 'type' field to identify devices Content-Language: en-US To: Heikki Krogerus Cc: Alexandru Ardelean , linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, gregkh@linuxfoundation.org, christophe.jaillet@wanadoo.fr, a-govindraju@ti.com, trix@redhat.com, abdelalkuor@geotab.com, Bryan O'Donoghue , Krzysztof Kozlowski References: <20231123210021.463122-1-alex@shruggie.ro> <47ffbb30-34a7-4f5b-b262-3e068e574c8a@kernel.org> From: Roger Quadros In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,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 groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Thu, 30 Nov 2023 05:31:17 -0800 (PST) Hi Heikki, On 30/11/2023 12:54, Heikki Krogerus wrote: > Hi Roger, > >>> Why not just match against the structures themselves? >>> >>> if (tps->data == &tps25750_data) >>> ... >> >> Then you need to declare tps25750_data and friends at the top of the file? >> >> A better approach might be to have type agnostic quirk flags for the special >> behavior required for different types. This way, multiple devices can share >> the same quirk if needed. >> >> e.g. >> NEEDS_POWER_UP instead of TIPD_TYPE_APPLE_CD321X >> SKIP_VID_READ instead of TIPD_TYPE_TI_TPS25750X >> INIT_ON_RESUME instead of TIPD_TYPE_TI_TPS25750X >> >> Also rename cd321x_switch_power_state() to tps6598x_switch_power_state(). > > No. Functions like that isolate cd321x specific functionality into an > actual "function" just like they should. > > Quirk flags mean that if something breaks, it will almost always break > for everybody (there is no real isolation with quirk flags), and when > things are fixed and when features are added, we are forced to always > "dance" around those quirk flags - you always have to consider them. > > Platform/device type checks are just as bad IMO, but in one way they > are better than quirk flags. There is no question about what a > platform check is checking, but quirk flags can so easily become > incomprehensible (just what exactly does it mean when you say > NEEDS_POWER_UP, SKIP_VID_READ and so on (you would need to document > those quirks, which is waste of effort, and in reality nobody will do). > > In case of tipd/code.c, it should be converted into a library that > only has the common/shared functionality. CD321, TPS2579x, TPS6598x > and what ever there is, then will have a glue driver that handles > everything that specific for their controller type. Do you mean that you want to treat the 3 devices as different incompatible devices so each one has a separate driver which warrants for a different DT binding for each and also Kconfig symbol? > > Before this driver is reorganised like that (any volunteers?), we'll > have the PD controller type checks, but quirk flags we will not have. > > In general, you should only use quirk flags if there is no other > way to move forward - they are the last resort. They are dangerous, > and even in the best case they reduce the maintenability of the code. > > thanks, > -- cheers, -roger