Received: by 2002:a17:906:d7a2:b0:96f:a786:ac5c with SMTP id pk2csp2648226ejb; Tue, 30 May 2023 23:17:28 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4vqMAR+UFEa/rNFRbEmDFwfQJB0sy1CZVyDRlzXMoWQ02mYu/4vUzMUkkBJ8wZ/90v6jSH X-Received: by 2002:a05:6214:20ed:b0:622:199c:c4d0 with SMTP id 13-20020a05621420ed00b00622199cc4d0mr6262731qvk.15.1685513847741; Tue, 30 May 2023 23:17:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685513847; cv=none; d=google.com; s=arc-20160816; b=BzBvZyPpmXTpEHeoXnNUgg65GcIwZFuWA//rC0+dEjjU5js8ajGHfbz28SzFsqJKOh MTWo9/Hn0fLhtJLc4qKcaKq4Rd7UVgiBNrF453MoGpKu2a0fbBO8MuyNyklQjre0rBWy HUNnF8lbIzdke7cosy73GBni77yyMm7qQb5BcBArVs/BNGPE+lR7jHc6WCTjTlWPhwWV mdE5Q0VCtKBYz4LFJyRkcGuZ4oIl9PZ0JgyVJqLL8z1HtjCodOE8EKOoFm6apwMQSX43 OJS5/AVIt+DmhZUcDQslNeD3VqGmY9dQyRa3OOYrjy97GhokjJvO2sIlDw+I/f+RRIcS 9enQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe: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=58LCf2t6sXVtAGSisX4WsJKmdVzbSq6fC7hBy7R1rUU=; b=MnDemzbQJSBPGlvTMLNGVNYxHIyUyFYokMxaRd+eDs1dKg+bQrGK+PIELy595Z/khO I1g/S3VJMjFvHkIjQmUhTzSoPVKthHpvMvbMXBV/VlJy94HAkqudFIX8R5tSuu6TL7YF +SHEzLXorbBSS8/ib7tjRddR+Ons7Z0F8d86rjJ4yqXk8ObIKc8fu4Y0ReICllSmHLul 5ktFz8suvz3tXegnFD2ZeKzpGcOZ4k/R2JLShPo3/3D7m6YcPFzXjKrE43DjfRu5umx3 RNBHHnpnzq6zJkVu8cP5jdb9fZZbNnVP5iyMS/MIXPIv/1wYTbH1czOV4aeaLmNQJJB7 YW9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=AoPa4ZqL; spf=pass (google.com: domain of qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id a3-20020a056214062300b0061b6d63b196si7848950qvx.77.2023.05.30.23.17.27 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 30 May 2023 23:17:27 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=AoPa4ZqL; spf=pass (google.com: domain of qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q4F9B-0000Kd-67; Wed, 31 May 2023 02:17:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q4F9A-0000I4-3u for qemu-arm@nongnu.org; Wed, 31 May 2023 02:17:24 -0400 Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1q4F98-00083h-9V for qemu-arm@nongnu.org; Wed, 31 May 2023 02:17:23 -0400 Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-3f6e1394060so39589965e9.3 for ; Tue, 30 May 2023 23:17:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1685513839; x=1688105839; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=58LCf2t6sXVtAGSisX4WsJKmdVzbSq6fC7hBy7R1rUU=; b=AoPa4ZqLEHjKpD8q/Trh4MBVJKpcvDHLmL4n2ryABlyE3GyPK3epUulLJNkhpszHsR AGEwrnASpICAInptclI2ATUl0dNOR7YMfeHvFzkAmtkQd0aBz/yl88a/oicLIMhc2SDw QysGwSKaSS3v0llBETQunz2YmGbBx8P8HiyEmPsD1SvgsRCVzKMMXEyx6RD2UvNOvtf/ MVP5l/OURtjzeidhDVoFIwXAi5NG0gREYWU8SEXGcr1TIFWnu5vLPXvs4ltlbc4QJnBw b/u7cdo6rHN7fyRqP7kBWwUKlIfBZ9SC784om6S5yHXq+9TxxQvWtROTZgHDvhUMDPvh AmHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685513839; x=1688105839; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=58LCf2t6sXVtAGSisX4WsJKmdVzbSq6fC7hBy7R1rUU=; b=cT7AzZXhB6C/8pl1HnNhwh8tH0OYI7zU9/2zrvzDvTzzNxLEn66M59ZxbzwgSDKCup bS2ki1DWnP6d8aOg8S+JcbM4DD+GoxwX+6+ZhIiFPHGYEbxtkfeT9odOb9j+9iWk0V9f xq9uzjScpiO3pFYd00GrN+gicBYpsy2ZUcRa0yGPYmswxjZI+WzvbEFM7HXYty+OLgLv JCimFYgLblerwJIVx3EvFot4KfrsZEfHEI0Vyu0mtRwQK/V3dxgOtUYLE2vCdGhfyxMl vlcrh06SrfBERJE9qeJ2CrEHn0/zkD8Qd7ZDX6Hk9p/yjjY3oTP0vr6vPr0ivGHsZxMc plPg== X-Gm-Message-State: AC+VfDyVcoQ33HXBg0DzLwo7QlOCEOxil0GqCEypGB7kdXCS7wb7wfhQ 16ACXAYTYxFcOfNQp/0VZSlgEA== X-Received: by 2002:a7b:c3d4:0:b0:3f6:787:4a84 with SMTP id t20-20020a7bc3d4000000b003f607874a84mr3601123wmj.7.1685513839715; Tue, 30 May 2023 23:17:19 -0700 (PDT) Received: from [192.168.69.115] ([176.176.146.12]) by smtp.gmail.com with ESMTPSA id bg22-20020a05600c3c9600b003f4283f5c1bsm1734857wmb.2.2023.05.30.23.17.18 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 30 May 2023 23:17:19 -0700 (PDT) Message-ID: <6bfba08e-ce3e-539b-952d-697c8791fab2@linaro.org> Date: Wed, 31 May 2023 08:17:17 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 Subject: Re: [PATCH 05/12] hw/ssi: Introduce a ssi_get_cs() helper Content-Language: en-US To: =?UTF-8?Q?C=c3=a9dric_Le_Goater?= , qemu-arm@nongnu.org Cc: qemu-devel@nongnu.org, Peter Maydell , Joel Stanley , Andrew Jeffery , Alistair Francis , Mark Cave-Ayland , Eduardo Habkost , Bernhard Beschow , Markus Armbruster , Thomas Huth References: <20230508075859.3326566-1-clg@kaod.org> <20230508075859.3326566-6-clg@kaod.org> <40c8647d-201e-3ceb-97ca-ec98bdc84e88@linaro.org> <0d11b78e-56f7-553a-3e85-0edef9b649ac@linaro.org> <523179dd-7842-7f03-14d6-678ed680a017@kaod.org> From: =?UTF-8?Q?Philippe_Mathieu-Daud=c3=a9?= In-Reply-To: <523179dd-7842-7f03-14d6-678ed680a017@kaod.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2a00:1450:4864:20::32b; envelope-from=philmd@linaro.org; helo=mail-wm1-x32b.google.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, NICE_REPLY_A=-0.09, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-arm@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org Sender: qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org X-TUID: b6fCdclkoLaB +QOM tinkerers On 31/5/23 07:59, Cédric Le Goater wrote: > On 5/30/23 23:15, Philippe Mathieu-Daudé wrote: >> On 30/5/23 22:34, Philippe Mathieu-Daudé wrote: >>> On 8/5/23 09:58, Cédric Le Goater wrote: >>>> Simple routine to retrieve a DeviceState object on a SPI bus using its >>>> address/cs. It will be useful for the board to wire the CS lines. >>>> >>>> Cc: Alistair Francis >>>> Signed-off-by: Cédric Le Goater >>>> --- >>>>   include/hw/ssi/ssi.h |  2 ++ >>>>   hw/ssi/ssi.c         | 15 +++++++++++++++ >>>>   2 files changed, 17 insertions(+) >>>> >>>> diff --git a/include/hw/ssi/ssi.h b/include/hw/ssi/ssi.h >>>> index ffd3a34ba4..c7beabdb09 100644 >>>> --- a/include/hw/ssi/ssi.h >>>> +++ b/include/hw/ssi/ssi.h >>>> @@ -112,4 +112,6 @@ SSIBus *ssi_create_bus(DeviceState *parent, >>>> const char *name); >>>>   uint32_t ssi_transfer(SSIBus *bus, uint32_t val); >>>> +DeviceState *ssi_get_cs(SSIBus *bus, int addr); >> >> Also, this helper should (preferably) return a SSIPeripheral type. > > Well, having a DeviceState is handy for the callers (today) and > ssi_create_peripheral() returns a DeviceState. Let's keep it that > way. Yes I know it is handy :) I'm not against your patch; besides other APIs do that. I'm wondering about QOM design here. Having Foo device, should FOO API return the common qdev abstract type (DeviceState) or a Foo type? Either ways we keep QOM-casting around, but I still tend to consider FOO API returning Foo pointer provides some type check safety, and also provides the API user hints about what is used. Need more coffee.