linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: [PATCH] extcon : register for cable interest by cable name
@ 2012-10-10  6:52 MyungJoo Ham
  2012-10-11 10:37 ` Tc, Jenny
  0 siblings, 1 reply; 4+ messages in thread
From: MyungJoo Ham @ 2012-10-10  6:52 UTC (permalink / raw)
  To: Jenny TC, 최찬우, linux-kernel; +Cc: myungjoo.ham

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=euc-kr, Size: 1130 bytes --]

> There are some scnearios where a driver/framework needs to register
> interest for a particular cable without specifying the extcon device
> name. One such scenario is charger notifications. The platform will
> have charger cabel which will be bound to any extcon device. It's
> not mandatory for the charger driver to know which extcon device
> it should use. This patch enables the support for registering
> interest for a cable just by cable name wihtout specifying the
> extcon device name
> 
> Signed-off-by: Jenny TC <jenny.tc@intel.com>
> ---
[]
> +extern struct extcon_dev *register_interest_cable_byname
> +		(struct extcon_specific_cable_nb *extcon_dev,
> +		const char *cable_name, struct notifier_block *nb);

What about allowing extcon_register_interest() to support the functionality?

I.e., allowing extcon_register_interest() to accept NULL extcon_name.


ps. anyway, usually, the "platforms" have the list of node paths, don't they?

Cheers!
MyungJoo
ÿôèº{.nÇ+‰·Ÿ®‰­†+%ŠËÿ±éݶ\x17¥Šwÿº{.nÇ+‰·¥Š{±þG«éÿŠ{ayº\x1dʇڙë,j\a­¢f£¢·hšïêÿ‘êçz_è®\x03(­éšŽŠÝ¢j"ú\x1a¶^[m§ÿÿ¾\a«þG«éÿ¢¸?™¨è­Ú&£ø§~á¶iO•æ¬z·švØ^\x14\x04\x1a¶^[m§ÿÿÃ\fÿ¶ìÿ¢¸?–I¥

^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: [PATCH] extcon : register for cable interest by cable name
  2012-10-10  6:52 [PATCH] extcon : register for cable interest by cable name MyungJoo Ham
@ 2012-10-11 10:37 ` Tc, Jenny
  2012-10-15 14:53   ` MyungJoo Ham
  0 siblings, 1 reply; 4+ messages in thread
From: Tc, Jenny @ 2012-10-11 10:37 UTC (permalink / raw)
  To: myungjoo.ham, ???, linux-kernel; +Cc: myungjoo.ham

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="utf-8", Size: 2189 bytes --]



> Subject: Re: [PATCH] extcon : register for cable interest by cable name
> 
> > There are some scnearios where a driver/framework needs to register
> > interest for a particular cable without specifying the extcon device
> > name. One such scenario is charger notifications. The platform will
> > have charger cabel which will be bound to any extcon device. It's not
> > mandatory for the charger driver to know which extcon device it should
> > use. This patch enables the support for registering interest for a
> > cable just by cable name wihtout specifying the extcon device name
> >
> > Signed-off-by: Jenny TC <jenny.tc@intel.com>
> > ---
> []
> > +extern struct extcon_dev *register_interest_cable_byname
> > +		(struct extcon_specific_cable_nb *extcon_dev,
> > +		const char *cable_name, struct notifier_block *nb);
> 
> What about allowing extcon_register_interest() to support the functionality?
> 
register_interest_cable_byname  internally uses extcon_register_interest   function.
If we want to use  extcon_register_interest()  in both scenarios,  then we need to define
two local functions 

 extcon_register_interest__ and  register_interest_cable_byname. 

Then the code would be

int extcon_register_interest(struct extcon_specific_cable_nb *obj,
		 const char *extcon_name, const char *cable_name,
                             	struct notifier_block *nb) {

	if (extcon_name == NULL)
		return register_interest_cable_byname(obj,cable_name,nb);
	else
		return extcon_register_interest__(obj,extcon_name,cable_name,nb);
}

Is that fine?

> I.e., allowing extcon_register_interest() to accept NULL extcon_name.
> 
> 
> ps. anyway, usually, the "platforms" have the list of node paths, don't they?
>
My intention is to make it generic and less dependent on platform data. This way the same consumer
driver can work on any platform without looking for extcon dev name in the platform data. 
For example a charger driver can work on any platform without knowing the extcon provider name for
The charger cable.

 

ÿôèº{.nÇ+‰·Ÿ®‰­†+%ŠËÿ±éݶ\x17¥Šwÿº{.nÇ+‰·¥Š{±þG«éÿŠ{ayº\x1dʇڙë,j\a­¢f£¢·hšïêÿ‘êçz_è®\x03(­éšŽŠÝ¢j"ú\x1a¶^[m§ÿÿ¾\a«þG«éÿ¢¸?™¨è­Ú&£ø§~á¶iO•æ¬z·švØ^\x14\x04\x1a¶^[m§ÿÿÃ\fÿ¶ìÿ¢¸?–I¥

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] extcon : register for cable interest by cable name
  2012-10-11 10:37 ` Tc, Jenny
@ 2012-10-15 14:53   ` MyungJoo Ham
  0 siblings, 0 replies; 4+ messages in thread
From: MyungJoo Ham @ 2012-10-15 14:53 UTC (permalink / raw)
  To: Tc, Jenny; +Cc: ???, linux-kernel

On Thu, Oct 11, 2012 at 7:37 PM, Tc, Jenny <jenny.tc@intel.com> wrote:
>
>
>> Subject: Re: [PATCH] extcon : register for cable interest by cable name
>>
>> > There are some scnearios where a driver/framework needs to register
>> > interest for a particular cable without specifying the extcon device
>> > name. One such scenario is charger notifications. The platform will
>> > have charger cabel which will be bound to any extcon device. It's not
>> > mandatory for the charger driver to know which extcon device it should
>> > use. This patch enables the support for registering interest for a
>> > cable just by cable name wihtout specifying the extcon device name
>> >
>> > Signed-off-by: Jenny TC <jenny.tc@intel.com>
>> > ---
>> []
>> > +extern struct extcon_dev *register_interest_cable_byname
>> > +           (struct extcon_specific_cable_nb *extcon_dev,
>> > +           const char *cable_name, struct notifier_block *nb);
>>
>> What about allowing extcon_register_interest() to support the functionality?
>>
> register_interest_cable_byname  internally uses extcon_register_interest   function.
> If we want to use  extcon_register_interest()  in both scenarios,  then we need to define
> two local functions

Then, you can use recursion. (calling recursively if the extcon_name
is NULL and when it calls recursively itself, extcon_name should not
be NULL)

>
>  extcon_register_interest__ and  register_interest_cable_byname.
>
> Then the code would be
>
> int extcon_register_interest(struct extcon_specific_cable_nb *obj,
>                  const char *extcon_name, const char *cable_name,
>                                 struct notifier_block *nb) {
>
>         if (extcon_name == NULL)
>                 return register_interest_cable_byname(obj,cable_name,nb);
>         else
>                 return extcon_register_interest__(obj,extcon_name,cable_name,nb);
> }
>
> Is that fine?
>
>> I.e., allowing extcon_register_interest() to accept NULL extcon_name.
>>
>>
>> ps. anyway, usually, the "platforms" have the list of node paths, don't they?
>>
> My intention is to make it generic and less dependent on platform data. This way the same consumer
> driver can work on any platform without looking for extcon dev name in the platform data.
> For example a charger driver can work on any platform without knowing the extcon provider name for
> The charger cable.
>
>
>



-- 
MyungJoo Ham, Ph.D.
Mobile Software Platform Lab, DMC Business, Samsung Electronics

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH] extcon : register for cable interest by cable name
@ 2012-10-10 10:20 Jenny TC
  0 siblings, 0 replies; 4+ messages in thread
From: Jenny TC @ 2012-10-10 10:20 UTC (permalink / raw)
  To: myungjoo.ham, cw00.choi, linux-kernel; +Cc: jenny.tc

There are some scnearios where a driver/framework needs to register
interest for a particular cable without specifying the extcon device
name. One such scenario is charger notifications. The platform will
have charger cabel which will be bound to any extcon device. It's
not mandatory for the charger driver to know which extcon device
it should use. This patch enables the support for registering
interest for a cable just by cable name wihtout specifying the
extcon device name

Signed-off-by: Jenny TC <jenny.tc@intel.com>
---
 drivers/extcon/extcon-class.c |   52 +++++++++++++++++++++++++++++++++++++++++
 include/linux/extcon.h        |    3 +++
 2 files changed, 55 insertions(+)

diff --git a/drivers/extcon/extcon-class.c b/drivers/extcon/extcon-class.c
index 946a318..3d8e825 100644
--- a/drivers/extcon/extcon-class.c
+++ b/drivers/extcon/extcon-class.c
@@ -485,6 +485,58 @@ int extcon_register_interest(struct extcon_specific_cable_nb *obj,
 }
 
 /**
+ * extcon_register_interest_cable_byname() - Register a notifier for a state
+ *			change of a specific cable, on any extcon device
+ *			extcon device.
+ * @obj:	an empty extcon_specific_cable_nb object to be returned.
+ * @cable_name:		the target cable name.
+ * @nb:		the notifier block to get notified.
+ *
+ * Provide an empty extcon_specific_cable_nb.
+ * extcon_register_interest_cable_name() sets the struct for you.
+ *
+ * extcon_register_cable_interest is a helper function for those who want to get
+ * notification for a single specific cable's status change without knowing the
+ * extcon device name.
+ *
+ * Note : This will register the interest with the first extcon device which
+ * reports the status for the cable. If multiple extcon devices reports the
+ * same cable name, this API will register interest with the first extcon device
+ */
+
+struct extcon_dev *register_interest_cable_byname
+		(struct extcon_specific_cable_nb *extcon_dev,
+		const char *cable_name, struct notifier_block *nb)
+{
+	struct class_dev_iter iter;
+	struct device *dev;
+	struct extcon_dev *extd = NULL;
+
+	/* Identify the extcon device which supports the cable and register
+	* interest.
+	*/
+	if (extcon_class == NULL)
+		return NULL;
+	class_dev_iter_init(&iter, extcon_class, NULL, NULL);
+	while ((dev = class_dev_iter_next(&iter))) {
+		extd = (struct extcon_dev *)dev_get_drvdata(dev);
+		/* check for cable  support */
+		if (extcon_find_cable_index(extd, cable_name) < 0) {
+			extd = NULL;
+			continue;
+		}
+
+		if (extcon_register_interest(extcon_dev, extd->name,
+						cable_name, nb) < 0) {
+			extd = NULL;
+			continue;
+		}
+	}
+	class_dev_iter_exit(&iter);
+	return extd;
+}
+
+/**
  * extcon_unregister_interest() - Unregister the notifier registered by
  *				extcon_register_interest().
  * @obj:	the extcon_specific_cable_nb object returned by
diff --git a/include/linux/extcon.h b/include/linux/extcon.h
index 7443a56..9be8286 100644
--- a/include/linux/extcon.h
+++ b/include/linux/extcon.h
@@ -222,6 +222,9 @@ extern int extcon_register_interest(struct extcon_specific_cable_nb *obj,
 				    const char *extcon_name,
 				    const char *cable_name,
 				    struct notifier_block *nb);
+extern struct extcon_dev *register_interest_cable_byname
+		(struct extcon_specific_cable_nb *extcon_dev,
+		const char *cable_name, struct notifier_block *nb);
 extern int extcon_unregister_interest(struct extcon_specific_cable_nb *nb);
 
 /*
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-10-15 14:53 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-10-10  6:52 [PATCH] extcon : register for cable interest by cable name MyungJoo Ham
2012-10-11 10:37 ` Tc, Jenny
2012-10-15 14:53   ` MyungJoo Ham
2012-10-10 10:20 Jenny TC

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).