Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751806AbbEYCNu (ORCPT ); Sun, 24 May 2015 22:13:50 -0400 Received: from mail-by2on0108.outbound.protection.outlook.com ([207.46.100.108]:34272 "EHLO na01-by2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751548AbbEYCNq (ORCPT ); Sun, 24 May 2015 22:13:46 -0400 Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=freescale.com; samsung.com; dkim=none (message not signed) header.d=none; Date: Mon, 25 May 2015 10:12:48 +0800 From: Peter Chen To: Chanwoo Choi CC: , , , , , , Subject: Re: [PATCH 1/2] extcon: Add extcon_set_cable_line_state() to inform the additional state of external connectors Message-ID: <20150525021247.GA4967@shlinux2> References: <1432291790-4933-1-git-send-email-cw00.choi@samsung.com> <1432291790-4933-2-git-send-email-cw00.choi@samsung.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <1432291790-4933-2-git-send-email-cw00.choi@samsung.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1;BL2FFO11FD050;1:pV2sxg47zORkGNqRFwvXWBde+p9bNxd5r1RQOBLNfCO1pRTJYeUyupmiJK/Bs1zeIA/pKOEn1OrOJzl/DQEtR9nk/5jDAP93YCMWz5ku5ca4PGvnrxJ/j0mtkwC180szylAQYtatxHrLMomZhqa5g6UHYP5d7vk3NY5MPL62fcKB2BWy1JM/3QtMngb0be8bb/f0NqyBBsPPJUpNoemG7Kt2AG67wvo6/pH8JeObDBK7I6g0hKlhytp6kV03O/LMZM2dOusqBUh+7dhr6fc3kA== X-Forefront-Antispam-Report: CIP:192.88.168.50;CTRY:US;IPV:NLI;EFV:NLI;SFV:NSPM;SFS:(10019020)(6009001)(339900001)(51704005)(199003)(24454002)(189002)(92566002)(76176999)(54356999)(50986999)(6806004)(4001350100001)(5001830100001)(5890100001)(5001960100002)(110136002)(68736005)(23726002)(97756001)(47776003)(106466001)(105606002)(50466002)(85426001)(19580395003)(83506001)(64706001)(33716001)(19580405001)(86362001)(104016003)(87936001)(46406003)(97736004)(77096005)(5001920100001)(33656002)(62966003)(77156002)(189998001)(4001540100001)(5001860100001)(46102003)(81156007)(2950100001);DIR:OUT;SFP:1102;SCL:1;SRVR:CY1PR0301MB1276;H:tx30smr01.am.freescale.net;FPR:;SPF:Fail;PTR:InfoDomainNonexistent;A:1;MX:1;LANG:en; X-Microsoft-Exchange-Diagnostics: 1;CY1PR0301MB1276;2:5XKUSRPznT0MEiKSdqtB3K+e7o2KO5qKSO4J2G00MozCrzGuFYPHC77+wShvsI3O;2:NDR28Xqp8rU2pjsg78qd4uMto0JClG31pNvQwX9ad6tI/xFwtw7iUNPMMG8Nb0PdkEcJ9fy+3QMpdfpubzf0VUr+/WKCoI00L+D4hmPD8E8DLrzclA3Nswwa9AgBx5nIXKtSMiRnw+sFtp5XW7lC8W914m4lS80GDoqZfYIDUFx/H1TgINAkiI967e9JDidm3LNTjzpDxtJyn9UAlqJtI3+CZAW6PtdZBIf1uCw78YY=;6:CqhO+huWX2d+sp78gezfSzkWXs8a+j9V9KbCSf5eVtlyztVWzo65EffmsACifZQexIcnervxmL/5EmLLF5asoXPxWKtSK0uly/WKdqYcVHCOuJ1tOdbn4LxskzL3RkcYZdy6CgPGsU5Yg4qFGZpuGbuMaebxi4RMIYJdJP0gD4KA7sZdgDgkQ/s/1xUavuuF3qOniKf+q/UZb+tzypULMYkXSPZH1WeYo7H9YWlzZIaHrpV1eLuS4Z6CiHQiUm40Cp0cPNCWsh7PDjviOTKk7k9Z0XU3YAbCqQ79BFYupFotaDCMaoh3pnNCzhzn3LkTj3Oy7IeXLGckGxWzK27A7w== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:CY1PR0301MB1276; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(5005006)(520002)(3002001);SRVR:CY1PR0301MB1276;BCL:0;PCL:0;RULEID:;SRVR:CY1PR0301MB1276; X-Microsoft-Exchange-Diagnostics: 1;CY1PR0301MB1276;3:94lR5ZeTwGPwHNgh01dMmSOmXjci2pQFC0O9J5Pf+0Ttf74RGl3qsWhi4+gX0EOl3wm/qkt6LloE17kvIHh1uhz/syfAbdiobRfSrctLcz5yRBLbqhu2mWO/Rks73ILlrobVr1ozL1OGTU0q0BR6IKBEzRNbWr7zizVfF+zjhjrUiaBON3sS/T0xL0o21PnjMsSny6Goqwfw+MItHumG02jwb1i9mzb/E6YonHsrYCkCV7t1keBylaTzhebuWN6Ui1+FRoy+GFGv8bR/BlB25ySiporO5lZH/it56+DjBRaXMdQiwRVgsKgnjuun2Dm3 X-Forefront-PRVS: 058707456E X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;CY1PR0301MB1276;9:+G06GbZLxztelwbDJQq6WkUip2rE+/p6K4KRVABN?= =?us-ascii?Q?66/DpONnZK/POZmFh2JpVJ57JRpVO6c9Rj/b9hwf80+DHQzUSPsfoFhPvwBU?= =?us-ascii?Q?UVt2jns50WsB+NFbMIcgIJdRiy/rm+e9g7K1IRESy2CkCwuTYompCGp9IucN?= =?us-ascii?Q?MWEiRErhmdOrV4oXF1TI58sTvX7vjmZYsmyOAy8AmltaB3o2FC1O+/qoNmEw?= =?us-ascii?Q?SRlZh2RxGfEJcrqcrbc/URmj9Z3KBMOLRXAt6tErUR6M8WKh/YyP12GOgtiF?= =?us-ascii?Q?t+9PD+iQHNXN2ftVWUBaWNbtrguu65f109SeHuQTrNo5aEowoggQUgKMKNhY?= =?us-ascii?Q?3v+MBTgwUl/2WsJJrTg0IPqVxeX6Wtm7yIsm7cmg0GLW25MblMGxRZ8K74M+?= =?us-ascii?Q?oaW/AsGAbL09o3Q0R/BcN7aWj5DlnOgH52wBIXeveTWadM+aTHs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Bvn1suBPbHXR1um5KrcrgqL+Xs3H2ya+WXfnhOgOpxdfTLNX7vltWm0AUb2nMb4xw==;10:xE1U3LMfGkA8GJSYpkkGKXgUXR9Ii5rVfec1fq66bdRbe/gFs/oxTqnFEXuiSwGJUgD3MBNnSP3GxCbuo47dip8P3teO+rvloXG6Mm38+vk=;6:wgOqPO0jPnXErIX25BUcUy5EL9/2Kzxei9d1wojTbxaIy6ARMfLDVlC9q0XuILM9 X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 May 2015 02:13:42.2669 (UTC) X-MS-Exchange-CrossTenant-Id: 710a03f5-10f6-4d38-9ff4-a80b81da590d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=710a03f5-10f6-4d38-9ff4-a80b81da590d;Ip=[192.88.168.50];Helo=[tx30smr01.am.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR0301MB1276 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3328 Lines: 93 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 > Signed-off-by: Chanwoo Choi > --- > 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 majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/