From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E8637EB64D9 for ; Thu, 15 Jun 2023 15:06:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344501AbjFOPGA (ORCPT ); Thu, 15 Jun 2023 11:06:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45282 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343765AbjFOPF4 (ORCPT ); Thu, 15 Jun 2023 11:05:56 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 60918273D; Thu, 15 Jun 2023 08:05:55 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id F009160C36; Thu, 15 Jun 2023 15:05:54 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0C229C433C0; Thu, 15 Jun 2023 15:05:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1686841554; bh=4wkotvA1EgdVqwtRibR0PvE40CcTrbovkSp7EW/Frug=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=vEBoqfVoj7mhPuR6aCuMRHuXIpDWxK66fSBsmnokeudE7zxizcDxAqN3Xj9koXRYg NLagRHCPnNHPrNabNg11/nVLVCOKDO6Nf4RTL91Wy8nySr3SK/1X7iRaJJutI23vFC sLU44UAMao68eSvpdwrAtbRsyWL5V34FdC9Wnwh0= Date: Thu, 15 Jun 2023 17:05:52 +0200 From: Greg Kroah-Hartman To: Prashanth K Cc: Heikki Krogerus , AngeloGioacchino Del Regno , Matthias Brugger , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v7] usb: common: usb-conn-gpio: Set last role to unknown before initial detection Message-ID: <2023061556-hypnoses-quartet-766a@gregkh> References: <1685544074-17337-1-git-send-email-quic_prashk@quicinc.com> <2023061547-staleness-camper-ae8a@gregkh> <2023061512-vowed-panther-38ed@gregkh> <551145bb-18f7-45af-b75e-7caccca113bc@quicinc.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <551145bb-18f7-45af-b75e-7caccca113bc@quicinc.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jun 15, 2023 at 08:28:13PM +0530, Prashanth K wrote: > > > On 15-06-23 08:06 pm, Greg Kroah-Hartman wrote: > > On Thu, Jun 15, 2023 at 07:52:32PM +0530, Prashanth K wrote: > > > > > > In that case, can I resubmit v1 of this patch again, where I have used a > > > macro in usb-conn-gpio driver ? something like this. > > > > > > @@ -27,6 +27,8 @@ > > > #define USB_CONN_IRQF \ > > > (IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING | IRQF_ONESHOT) > > > > > > +#define USB_ROLE_UNKNOWN (USB_ROLE_NONE -1) > > > > Are you referencing an existing enum here and assuming it is a specific > > value? > > I' not assuming UBS_ROLE_NONE to be a specific value, but I want an integer > (for macro) which is not equal to USB_ROLE_NONE/DEVICE/HOST, that's why I'm > using (USB_ROLE_NONE - 1), assuming enumerators NONE, DEVICE & HOST will be > having adjacent integer values. Wouldn't that help? You can't do "math" on an enumerated type and expect the result to be anything constant over time. And yes, you can hope that enumerated types are sequential, and the spec says so, but please never rely on that as what happens if someone adds a new one in the list without you ever noticing it. Pleasae treat enumerated types as an opaque thing that you never know the real value of, it's a symbol only. thanks, greg k-h