lkml.org 
[lkml]   [2015]   [May]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v2 0/2] extcon: Inform the state of both ID and VBUS pin for USB
Hi Ivan,

On 05/28/2015 05:45 PM, Ivan T. Ivanov wrote:
>
> Hi Chanwoo,
>
> On Wed, 2015-05-27 at 21:15 +0900, Chanwoo Choi wrote:
>> Previously, I discussed how to inform the changed state of both ID
>> and VBUS pin for USB connector on patch-set[1].
>> [1] https://lkml.org/lkml/2015/4/2/310
>>
>> So, this patch adds the extcon_set_cable_line_state() function to inform
>> the additional state of external connectors without additional register/
>> unregister functions. This function uses the existing notifier chain
>> which is registered by extcon_register_notifier() / extcon_register_interest().
>>
>> The extcon_set_cable_line_state() can inform the new state of both
>> ID and VBUS pin state through extcon_set_cable_line_state().
>>
>> For exmaple:
>> - On extcon-usb-gpio.c as extcon provider driver as following:
>> static void usb_extcon_detect_cable(struct work_struct *work)
>> {
>> ...
>> /* check ID and update cable state */
>> id = gpiod_get_value_cansleep(info->id_gpiod);
>> if (id) {
>> extcon_set_cable_state_(info->edev, EXTCON_USB_HOST, false);
>> extcon_set_cable_state_(info->edev, EXTCON_USB, true);
>>
>> extcon_set_cable_line_state(info->edev, EXTCON_USB,
>> EXTCON_USB_ID_HIGH);
>
> I am getting more and more confused :-). Why EXTCON_USB is now used for ID notifications?
> It should be EXTCON_USB_HOST, no? Why we need another function, framework already have
> required information from the function one line above, do I miss something?

The EXTCON fwk has the follwoing different functions:
- extcon_set_cable_state()
: Send whether external connectors is attached or detached to the extcon consumer driver in kernel space and to the user-space by using the uevent.
- extcon_set_cable_line_state()
: Send the specific line state of both ID and VBUS pin state of USB connector to only the extcon consumer driver in kernel space. This function don't send the uevent to the user-space because user-space process don't consider the h/w pin state.

>
>> } else {
>> extcon_set_cable_state_(info->edev, EXTCON_USB, false);
>> extcon_set_cable_state_(info->edev, EXTCON_USB_HOST, true);
>>
>> extcon_set_cable_line_state(info->edev, EXTCON_USB,
>> EXTCON_USB_ID_LOW);
>> }
>> }
>>
>> - On specific extcon consumder driver as following:
>> static int xxx_probe(struct platform_device *pdev)
>> {
>> struct notifier_chain nh;
>>
>> nb.notifier_call = extcon_usb_notifier;
>> ret = extcon_register_notifier(edev, EXTCON_USB, &nb);
>
> This is bit misleading. 'nb' could not be in stack.

Right. It is my mistake. I'll fix it for example.

Thanks,
Chanwoo Choi



\
 
 \ /
  Last update: 2015-05-29 13:01    [W:0.168 / U:73.176 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site