Received: by 2002:ac2:4c26:0:0:0:0:0 with SMTP id u6csp2290429lfq; Mon, 14 Sep 2020 07:03:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxKAR/iC9WsPPJ49E8VT2nmrZZt07upw+OEXR82RN+Gazm1e9Y4iEg7aWnT6T0pJnkEPwZu X-Received: by 2002:a25:e4c6:: with SMTP id b189mr19379948ybh.503.1600092218015; Mon, 14 Sep 2020 07:03:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600092218; cv=none; d=google.com; s=arc-20160816; b=TqK6TBY2npu0Q2hP0XkMlSiFKOJnyAxv42Q5aNRjUGBoImON7TFQUdZypfigaxOnqp kIkk7y7T+YGYQpWIU2FSQuNYNlJ0KnkvSIWGBcvkGI6xhR+FvMGyXgsVglaEd7TdY4Ca ueRxZm1Ifzj7SNzlhQdiSEW5YsKztFK3OwCCzcixKes/fdAm10+G2eC/2i1hpja1IQ09 z4gLVX+hwP4h5GXdbMN8HqKy2OnK/nGKv7tjKLH5oyErqRyma1ny17Oeo2KJks21vtaf /eqaGsHSBDvj9oVppc29y7uQMpP5F04YLxln8+FVbrgiRrvDdpRXuzR1uHlx9xDW/xkT /EZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-disposition :content-transfer-encoding:in-reply-to:mime-version:references :message-id:subject:to:from:date:dkim-signature; bh=xJ61TQmGt05vYw/DZO3qxapq5iKMmEZHhYtUqvX2ceM=; b=aufyO9QO5Yyn6g1GMtliaNTAeBTDsGAHxMz7hrphO7GBj6Bka6P7/rzSRoI5/1d5XC jPQMkL5RfO/RxIHjJ+9OYs+ZvkPi5BMHZOxfHdYaFZGqTPovzCnoafVqf+saOvo3UQ59 Opk5ccL1wbhrLcTsdj2z49gMCmOdP1jxOuoQ8EqECqrnPgvyujhI4bAOZn5GUYsxSLyt GBkRpvt+Cpk+5q1OCnyFq13Lls8ySl32HkYx6ZXhiV4FpHBywEN0Vdtwz239PmxSP2+f kyBOnBuRfXAolL1TAROrEFzIvLHT+zk1hCTwwbMFCpq3qSsXIqyEOcuI0dvbKqgdoO99 Mreg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@redhat.com header.s=mimecast20190719 header.b=hhd4t5XW; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id k40si10335454ybj.140.2020.09.14.07.03.37 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 Sep 2020 07:03:38 -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=fail header.i=@redhat.com header.s=mimecast20190719 header.b=hhd4t5XW; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from localhost ([::1]:47174 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kHp4z-0000X7-Db for alex.bennee@linaro.org; Mon, 14 Sep 2020 10:03:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43986) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kHp4s-0000Wo-GC for qemu-arm@nongnu.org; Mon, 14 Sep 2020 10:03:30 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:23578 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kHp4q-0006tw-Nt for qemu-arm@nongnu.org; Mon, 14 Sep 2020 10:03:30 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600092207; h=from:from:reply-to:subject:subject: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=xJ61TQmGt05vYw/DZO3qxapq5iKMmEZHhYtUqvX2ceM=; b=hhd4t5XWyEC8iVd6ec3l5T7cXypNnvDY3z5UdqKZSmLfaUARcWYke1IgcGyXk8peS7Fvz7 vdsIm+/Lp+l5naVTsVJul5sZn7Ah+RpJCJMT0ebArSRYFZLRwx6w/4NCZloknmycTfAOKz fU/DhEx1K8Ke7vDK6+9oOkd+9UYPgoU= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-32-zMmteinvNLuujcT19pIyzQ-1; Mon, 14 Sep 2020 10:03:22 -0400 X-MC-Unique: zMmteinvNLuujcT19pIyzQ-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B022380ED8E; Mon, 14 Sep 2020 14:03:20 +0000 (UTC) Received: from localhost (ovpn-66-226.rdu2.redhat.com [10.10.66.226]) by smtp.corp.redhat.com (Postfix) with ESMTP id E107575139; Mon, 14 Sep 2020 14:03:19 +0000 (UTC) Date: Mon, 14 Sep 2020 10:03:19 -0400 From: Eduardo Habkost To: Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= Subject: Re: [PATCH v5 2/7] hw/misc/led: Allow connecting from GPIO output Message-ID: <20200914140319.GA1618070@habkost.net> References: <20200910205429.727766-1-f4bug@amsat.org> <20200910205429.727766-3-f4bug@amsat.org> <071b68a6-58e4-0d68-e056-ee7ae19e2227@linaro.org> <87imcg4y3l.fsf@dusky.pond.sub.org> MIME-Version: 1.0 In-Reply-To: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=ehabkost@redhat.com X-Mimecast-Spam-Score: 0.002 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Content-Disposition: inline Received-SPF: pass client-ip=205.139.110.120; envelope-from=ehabkost@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/14 01:39:17 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -38 X-Spam_score: -3.9 X-Spam_bar: --- X-Spam_report: (-3.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.792, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-arm@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Daniel =?utf-8?B?UC4gQmVycmFuZ8Op?= , Andrew Jeffery , Richard Henderson , Markus Armbruster , qemu-devel@nongnu.org, qemu-arm@nongnu.org, =?utf-8?Q?C=C3=A9dric?= Le Goater , Paolo Bonzini , Luc Michel , Joel Stanley Errors-To: qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org Sender: "Qemu-arm" X-TUID: J8Z+yD/zLHHq On Mon, Sep 14, 2020 at 09:48:45AM +0200, Philippe Mathieu-Daudé wrote: > On 9/14/20 9:27 AM, Markus Armbruster wrote: > > Philippe Mathieu-Daudé writes: > > > >> Eduardo is already in Cc, adding Markus. > >> > >> On 9/12/20 12:44 AM, Richard Henderson wrote: > >>> On 9/10/20 1:54 PM, Philippe Mathieu-Daudé wrote: > >>>> Some devices expose GPIO lines. > >>>> > >>>> Add a GPIO qdev input to our LED device, so we can > >>>> connect a GPIO output using qdev_connect_gpio_out(). > >>>> > >>>> When used with GPIOs, the intensity can only be either > >>>> minium or maximum. This depends of the polarity of the > >>>> GPIO (which can be inverted). > >>>> Declare the GpioPolarity type to model the polarity. > >>>> > >>>> Signed-off-by: Philippe Mathieu-Daudé > >>>> --- > >>>> include/hw/misc/led.h | 8 ++++++++ > >>>> include/hw/qdev-core.h | 8 ++++++++ > >>>> hw/misc/led.c | 17 ++++++++++++++++- > >>>> 3 files changed, 32 insertions(+), 1 deletion(-) > >>>> > >>>> diff --git a/include/hw/misc/led.h b/include/hw/misc/led.h > >>>> index f5afaa34bfb..71c9b8c59bf 100644 > >>>> --- a/include/hw/misc/led.h > >>>> +++ b/include/hw/misc/led.h > >>>> @@ -38,10 +38,16 @@ typedef struct LEDState { > >>>> /* Public */ > >>>> > >>>> uint8_t intensity_percent; > >>>> + qemu_irq irq; > >>>> > >>>> /* Properties */ > >>>> char *description; > >>>> char *color; > >>>> + /* > >>>> + * When used with GPIO, the intensity at reset is related > >>>> + * to the GPIO polarity. > >>>> + */ > >>>> + bool inverted_polarity; > >>> > >>> Why are you not using the GpioPolarity enum that you added? > >> > >> Because it is migrated... > >> > >> Using DEFINE_PROP_BOOL() is simpler that adding hardware specific > >> enum visitor in hw/core/qdev-properties.c (which is included in > >> user-mode builds because pulled by the CPU type). > > > > Yes. > > > > You could also use DEFINE_PROP_UINT8(), and use it with your enumeration > > constants. > > > > I'd be tempted to ditch the enum entirely. Matter of taste, no big deal > > either way. > > Done in v6! > > > > >> A sane cleanup would be to make get_enum(), set_enum() > >> and set_default_value_enum() public (prefixed with 'qdev_') > >> in include/hw/qdev-properties.h. > > Where and how exactly do you expect those functions to be used? Having additional PropertyInfo structs defined manually would not be desirable (especially if they are outside qdev*.c). Having a DEFINE_PROP_ENUM macro that does the enum magic behind the scenes would be nice. > > Purpose? To be able to define enum properties outside > > qdev-properties.c? > > Yes, to avoid pulling in PCI and MAC address properties > into qemu-storage-daemon and linux-user binaries... I don't understand what enum functions have to do with PCI and MAC address properties. -- Eduardo