From: Peter Chen <peter.chen@freescale.com>
To: Chanwoo Choi <cw00.choi@samsung.com>
Cc: <linux-kernel@vger.kernel.org>, <rogerq@ti.com>,
<r.baldyga@samsung.com>, <kishon@ti.com>, <balbi@ti.com>,
<iivanov@mm-sol.com>, <myungjoo.ham@samsung.com>
Subject: Re: [PATCH 1/2] extcon: Add extcon_set_cable_line_state() to inform the additional state of external connectors
Date: Mon, 25 May 2015 10:12:48 +0800 [thread overview]
Message-ID: <20150525021247.GA4967@shlinux2> (raw)
In-Reply-To: <1432291790-4933-2-git-send-email-cw00.choi@samsung.com>
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.choi@samsung.com>
> Signed-off-by: Chanwoo Choi <cw00.choi@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
next prev parent reply other threads:[~2015-05-25 2:13 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-22 10:49 [PATCH 0/2] extcon: Inform the state of both ID and VBUS pin for USB Chanwoo Choi
2015-05-22 10:49 ` [PATCH 1/2] extcon: Add extcon_set_cable_line_state() to inform the additional state of external connectors Chanwoo Choi
2015-05-25 2:12 ` Peter Chen [this message]
2015-05-22 10:49 ` [PATCH 2/2] extcon: usb-gpio: Update the ID pin state of USB when cable state is changed 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=20150525021247.GA4967@shlinux2 \
--to=peter.chen@freescale.com \
--cc=balbi@ti.com \
--cc=cw00.choi@samsung.com \
--cc=iivanov@mm-sol.com \
--cc=kishon@ti.com \
--cc=linux-kernel@vger.kernel.org \
--cc=myungjoo.ham@samsung.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