linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Ivan T. Ivanov" <iivanov@mm-sol.com>
To: cw00.choi@samsung.com
Cc: Roger Quadros <rogerq@ti.com>,
	linux-kernel <linux-kernel@vger.kernel.org>,
	Robert Baldyga <r.baldyga@samsung.com>,
	Peter Chen <peter.chen@freescale.com>,
	Kishon Vijay Abraham I <kishon@ti.com>,
	Felipe Balbi <balbi@ti.com>,
	"myungjoo.ham@samsung.com" <myungjoo.ham@samsung.com>
Subject: Re: [PATCH v2 1/2] extcon: Add extcon_set_cable_line_state() to inform the additional state of external connectors
Date: Thu, 28 May 2015 12:37:25 +0300	[thread overview]
Message-ID: <1432805845.2348.33.camel@mm-sol.com> (raw)
In-Reply-To: <CAGTfZH2rn7OfqaTmr0d5-MfWW3ZFdt05_7vtLKqbEQee53999w@mail.gmail.com>

Hi, 

On Thu, 2015-05-28 at 18:17 +0900, Chanwoo Choi wrote:
> 
> 
> 2015년 5월 28일 목요일, Ivan T. Ivanov<iivanov@mm-sol.com>님이 작성한 메시지:
> > Hi Chanwoo,
> > 
> > On Thu, 2015-05-28 at 00:06 +0900, Chanwoo Choi wrote:
> > > On Wed, May 27, 2015 at 11:38 PM, Roger Quadros <rogerq@ti.com> wrote:
> > > > Chanwoo,
> > > >
> > > > On 27/05/15 15:15, Chanwoo Choi wrote:
> > > > > This patch adds the extcon_set_cable_line_state() function to inform
> > > > > the additional state of each external connector and 'enum
> > > > > extcon_line_state'
> > > > > enumeration which include the specific states of each external connector.
> > > > >
> > > > > The each external connector might need the different line state. So,
> > > > > current
> > > > > 'extcon_line_state' enumeration contains the specific state for USB as
> > > > > following:
> > > > >
> > > > > - Following the state mean the state of both ID and VBUS line for USB:
> > > > > enum extcon_line_state {
> > > > >         EXTCON_USB_ID_LOW       = BIT(1),       /* ID line is low. */
> > > > >         EXTCON_USB_ID_HIGH      = BIT(2),       /* ID line is high. */
> > > >
> > > >
> > > > ID_LOW and ID_HIGH cannot happen simultaneously so they can use the same bit
> > > > position.
> > > > if the bit is set means it is high, if it is cleared means it is low.
> > >
> > > These are the notifier event. So, extcon_line_state have to include
> > > each event for both low or high state of ID.
> > > because the extcon consumer driver using the
> > > extcon_register_notifier() need the each event to distinguish the type
> > > of event.
> > >
> > > > >         EXTCON_USB_VBUS_LOW     = BIT(3),       /* VBUS line is low. */
> > > > >         EXTCON_USB_VBUS_HIGH    = BIT(4),       /* VBUS line is high. */
> > > >
> > > >
> > > > same here.
> > >
> > > ditto.
> > >
> > > > enum doesn't look like the right type for extcon_line_state as it is more of
> > > > a bitmask.
> > >
> > > Why? I prefer to use the enum if there are no problem.
> > 
> If you insist your opinion, you shoud suggest the reason. Could you tell me the reason?

It looks unreadable. There is no need to mix interface API (enum extcon_line_state)
with implementation details. You can use plain enum at interface level and hide
shifting inside implementation.

> 
> 
> > > > >
> > > > > +enum extcon_line_state {
> > > > > +       /* Following two definition are used for whether external
> > > > > connectors
> > > > > +        * is attached or detached. */
> > > > > +       EXTCON_DETACHED         = 0x0,
> > > > > +       EXTCON_ATTACHED         = 0x1,
> > > > > +
> > > > > +       /* Following states are only used for EXTCON_USB. */
> > > > > +       EXTCON_USB_ID_LOW       = BIT(1),       /* ID line is low. */
> > > > > +       EXTCON_USB_ID_HIGH      = BIT(2),       /* ID line is high. */
> > > > > +       EXTCON_USB_VBUS_LOW     = BIT(3),       /* VBUS line is low. */
> > > > > +       EXTCON_USB_VBUS_HIGH    = BIT(4),       /* VBUS line is high. */
> > > > > +};
> > > >
> > > >
> > > > Why do you use enum? How about the following bit definitions for line state.
> > > >
> > > > #define EXTCON_ATTACHED_DETACHED_BIT    BIT(0)
> > > > #define EXTCON_USB_ID_BIT               BIT(1)
> > > > #define EXTCON_USB_VBUS_BIT             BIT(2)
> > > > ...
> > > >
> > > > code must check if appropriate bit is set or cleared to get the high/low
> > > > state.
> > >
> > > I answer about it on upper.
> > >
> > 
> > Funny. We can use the one bit for DETACHED/ATTACHED, but we
> hmm. Did you read my answer about low/high?
> 
> But, I'm considering again about using the detached/attached value.

Ok, but consumers will receive one event at time, right?

Regards,
Ivan


  parent reply	other threads:[~2015-05-28  9:38 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-27 12:15 [PATCH v2 0/2] extcon: Inform the state of both ID and VBUS pin for USB Chanwoo Choi
2015-05-27 12:15 ` [PATCH v2 1/2] extcon: Add extcon_set_cable_line_state() to inform the additional state of external connectors Chanwoo Choi
2015-05-27 14:38   ` Roger Quadros
2015-05-27 15:06     ` Chanwoo Choi
2015-05-28  9:02       ` Ivan T. Ivanov
     [not found]         ` <CAGTfZH2rn7OfqaTmr0d5-MfWW3ZFdt05_7vtLKqbEQee53999w@mail.gmail.com>
2015-05-28  9:37           ` Ivan T. Ivanov [this message]
2015-05-29  7:58             ` Chanwoo Choi
2015-05-27 12:15 ` [PATCH v2 2/2] extcon: usb-gpio: Update the ID pin state of USB when cable state is changed Chanwoo Choi
2015-05-27 14:40   ` Roger Quadros
2015-05-27 14:09 ` [PATCH v2 0/2] extcon: Inform the state of both ID and VBUS pin for USB Roger Quadros
2015-05-27 14:19   ` Chanwoo Choi
2015-05-28  8:45 ` Ivan T. Ivanov
2015-05-28 14:23   ` Roger Quadros
2015-05-29  1:22     ` Peter Chen
2015-05-29 10:53       ` Chanwoo Choi
2015-05-29 12:15         ` Chanwoo Choi
2015-06-02  6:51           ` Roger Quadros
2015-05-29  7:35     ` Ivan T. Ivanov
2015-05-29  7:36     ` Ivan T. Ivanov
2015-05-29 10:39     ` Chanwoo Choi
2015-05-29 10:44   ` Chanwoo Choi
2015-05-29 14:32     ` Ivan T. Ivanov
2015-05-29 17:15       ` Chanwoo Choi
2015-05-29 17:39         ` Chanwoo Choi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1432805845.2348.33.camel@mm-sol.com \
    --to=iivanov@mm-sol.com \
    --cc=balbi@ti.com \
    --cc=cw00.choi@samsung.com \
    --cc=kishon@ti.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=myungjoo.ham@samsung.com \
    --cc=peter.chen@freescale.com \
    --cc=r.baldyga@samsung.com \
    --cc=rogerq@ti.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).