On Fri, May 22, 2015 at 07:49:49PM +0900, 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. */ > EXTCON_USB_VBUS_LOW = BIT(3), /* VBUS line is low. */ > EXTCON_USB_VBUS_HIGH = BIT(4), /* VBUS line is high. */ > }; > > Cc: Myungjoo Ham <cw00.c...@samsung.com> > Signed-off-by: Chanwoo Choi <cw00.c...@samsung.com> > --- > drivers/extcon/extcon.c | 74 > ++++++++++++++++++++++++++++++++++++++++++++++++- > include/linux/extcon.h | 24 ++++++++++++++++ > 2 files changed, 97 insertions(+), 1 deletion(-) > > diff --git a/drivers/extcon/extcon.c b/drivers/extcon/extcon.c > index 5099c11..2f7db54 100644 > --- a/drivers/extcon/extcon.c > +++ b/drivers/extcon/extcon.c > @@ -279,7 +279,9 @@ int extcon_update_state(struct extcon_dev *edev, u32 > mask, u32 state) > > for (index = 0; index < edev->max_supported; index++) { > if (is_extcon_changed(edev->state, state, index, > &attached)) > - raw_notifier_call_chain(&edev->nh[index], > attached, edev); > + raw_notifier_call_chain(&edev->nh[index], > + attached ? EXTCON_ATTACHED : > + EXTCON_DETACHED, edev); > } > > edev->state &= ~mask; > @@ -418,6 +420,69 @@ int extcon_set_cable_state(struct extcon_dev *edev, > EXPORT_SYMBOL_GPL(extcon_set_cable_state); > > /** > + * extcon_set_cable_line_state() - Set the line state of specific cable. > + * @edev: the extcon device that has the cable. > + * @id: the unique id of each external connector. > + * @state: the line state for specific cable. > + * > + * Note that this function support the only USB connector to inform the state > + * of both ID and VBUS line until now. This function may be extended to > support > + * the additional external connectors. > + * > + * If the id is EXTCON_USB, it can support only following line states: > + * - EXTCON_USB_ID_LOW > + * - EXTCON_USB_ID_HIGH, > + * - EXTCON_USB_VBUS_LOW > + * - EXTCON_USB_VBUS_HIGH > + */ > +int extcon_set_cable_line_state(struct extcon_dev *edev, enum extcon id, > + enum extcon_line_state state) > +{ > + unsigned long flags; > + unsigned long line_state; > + int ret = 0, index; > + > + index = find_cable_index_by_id(edev, id); > + if (index < 0) > + return index; > + > + spin_lock_irqsave(&edev->lock, flags); > + line_state = edev->line_state[index]; > + > + switch (id) { > + case EXTCON_USB: > + if (line_state & state) { > + dev_info(&edev->dev, > + "0x%x state is already set for %s\n", > + state, extcon_name[id]); > + goto err; > + }
dev_warning? -- Best Regards, Peter Chen -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/