issues dealing with kobjects

2014-06-20 Thread Raghavendra
Hello all,

I am facing a small issue dealing with kobjects.
I am writing a simple i2c driver for which I would like to export a few 
sysfs attributes(files).
The files are many, so I've decided to pack them into a directory in 
sysfs (inside the i2c device) and so I thought of kobjects.

My private data struture is something like this :
struct my_private {
 struct i2c_client *client;
 ...
 struct kobject kobj;
};

In my probe function, I am doing something like this :
int my_probe(struct i2c_client *client, ...)
{
 struct my_private *dev;

 dev = devm_kzalloc(...);
 pr_info(%x, dev);/* The address that I got is 
: 0xdbf94210 */

 

 /* Init. and add kboject */
 kobject_init(dev-kobj, client-dev.kobj.ktype);
 kobject_add(dev-kobj, client-dev.kobj, my_dir);

 /* Export sysfs group */
 sysfs_create_group(dev-kobj, my_attr_grp);

 
}

My show function for one of the attribute is something like this :
ssize_t show(struct kobject *kobj, ... )
{
 struct my_private *dev = container_of(kobj, struct my_private, kobj);
 pr_info(%x, dev);/* The address that I got is 
: 0xdbf94208 */

 
}

I tried to probe and remove the device mutilple times. Every time I am 
getting a difference of 2bytes for the 'dev'
pointer between probe and show functions.

Can anyone explain me where am I going wrong or is there any better way 
to create directories in sysfs?
I am building this module against 3.13.2 kernel.

Thank you.
Raghavendra.



---
[ C-DAC is on Social-Media too. Kindly follow us at:
Facebook: https://www.facebook.com/CDACINDIA  Twitter: @cdacindia ]

This e-mail is for the sole use of the intended recipient(s) and may
contain confidential and privileged information. If you are not the
intended recipient, please contact the sender by reply e-mail and destroy
all copies and the original message. Any unauthorized review, use,
disclosure, dissemination, forwarding, printing or copying of this email
is strictly prohibited and appropriate legal action will be taken.
---


___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: issues dealing with kobjects

2014-06-20 Thread enjoy mindful
You have two *different* local pointer with same name.

On Fri, Jun 20, 2014 at 2:01 PM, Raghavendra ar...@cdac.in wrote:
 Hello all,

 I am facing a small issue dealing with kobjects.
 I am writing a simple i2c driver for which I would like to export a few
 sysfs attributes(files).
 The files are many, so I've decided to pack them into a directory in
 sysfs (inside the i2c device) and so I thought of kobjects.

 My private data struture is something like this :
 struct my_private {
  struct i2c_client *client;
  ...
  struct kobject kobj;
 };

 In my probe function, I am doing something like this :
 int my_probe(struct i2c_client *client, ...)
 {
  struct my_private *dev;

  dev = devm_kzalloc(...);
  pr_info(%x, dev);/* The address that I got is
 : 0xdbf94210 */

  

  /* Init. and add kboject */
  kobject_init(dev-kobj, client-dev.kobj.ktype);
  kobject_add(dev-kobj, client-dev.kobj, my_dir);

  /* Export sysfs group */
  sysfs_create_group(dev-kobj, my_attr_grp);

  
 }

 My show function for one of the attribute is something like this :
 ssize_t show(struct kobject *kobj, ... )
 {
  struct my_private *dev = container_of(kobj, struct my_private, kobj);
  pr_info(%x, dev);/* The address that I got is
 : 0xdbf94208 */

  
 }

 I tried to probe and remove the device mutilple times. Every time I am
 getting a difference of 2bytes for the 'dev'
 pointer between probe and show functions.

 Can anyone explain me where am I going wrong or is there any better way
 to create directories in sysfs?
 I am building this module against 3.13.2 kernel.

 Thank you.
 Raghavendra.



 ---
 [ C-DAC is on Social-Media too. Kindly follow us at:
 Facebook: https://www.facebook.com/CDACINDIA  Twitter: @cdacindia ]

 This e-mail is for the sole use of the intended recipient(s) and may
 contain confidential and privileged information. If you are not the
 intended recipient, please contact the sender by reply e-mail and destroy
 all copies and the original message. Any unauthorized review, use,
 disclosure, dissemination, forwarding, printing or copying of this email
 is strictly prohibited and appropriate legal action will be taken.
 ---


 ___
 Kernelnewbies mailing list
 Kernelnewbies@kernelnewbies.org
 http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: issues dealing with kobjects

2014-06-20 Thread Raghavendra
On Friday 20 June 2014 11:31 AM, Raghavendra wrote:
 Hello all,

 I am facing a small issue dealing with kobjects.
 I am writing a simple i2c driver for which I would like to export a few
 sysfs attributes(files).
 The files are many, so I've decided to pack them into a directory in
 sysfs (inside the i2c device) and so I thought of kobjects.

 My private data struture is something like this :
 struct my_private {
   struct i2c_client *client;
   ...
   struct kobject kobj;
 };

 In my probe function, I am doing something like this :
 int my_probe(struct i2c_client *client, ...)
 {
   struct my_private *dev;

   dev = devm_kzalloc(...);
   pr_info(%x, dev);/* The address that I got is
 : 0xdbf94210 */

   

   /* Init. and add kboject */
   kobject_init(dev-kobj, client-dev.kobj.ktype);
   kobject_add(dev-kobj, client-dev.kobj, my_dir);

   /* Export sysfs group */
   sysfs_create_group(dev-kobj, my_attr_grp);

   
 }

 My show function for one of the attribute is something like this :
 ssize_t show(struct kobject *kobj, ... )
 {
   struct my_private *dev = container_of(kobj, struct my_private, kobj);
   pr_info(%x, dev);/* The address that I got is
 : 0xdbf94208 */

   
 }

 I tried to probe and remove the device mutilple times. Every time I am
 getting a difference of 2bytes for the 'dev'
 pointer between probe and show functions.

 Can anyone explain me where am I going wrong or is there any better way
 to create directories in sysfs?
 I am building this module against 3.13.2 kernel.

 Thank you.
 Raghavendra.



 ---
 [ C-DAC is on Social-Media too. Kindly follow us at:
 Facebook: https://www.facebook.com/CDACINDIA  Twitter: @cdacindia ]

 This e-mail is for the sole use of the intended recipient(s) and may
 contain confidential and privileged information. If you are not the
 intended recipient, please contact the sender by reply e-mail and destroy
 all copies and the original message. Any unauthorized review, use,
 disclosure, dissemination, forwarding, printing or copying of this email
 is strictly prohibited and appropriate legal action will be taken.
 ---


 ___
 Kernelnewbies mailing list
 Kernelnewbies@kernelnewbies.org
 http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
I guess I've solved the issue. Now the code looks something like this :

struct my_private {
  struct i2c_client *client;
  ...
  struct kobject *kobj; /* Converted variable to ptr */
};

int my_probe(struct i2c_client *client, ...)
{
  struct my_private *dev;

  dev = devm_kzalloc(...);
  
  

/* Replaced with kobject_init and kobject_add calls */
  dev-kobj = kobject_create_and_add(my_dir, client-dev.kobj);  

  /* Export sysfs group */
  sysfs_create_group(dev-kobj, my_attr_grp);

  
}

ssize_t show(struct kobject *kobj, ... )
{
struct device *i2cdev = kobj_to_dev(kobj-parent);
struct i2c_client *client = to_i2c_client(i2cdev);
struct my_private *dev = i2c_get_clientdata(client);

  
}

This approach worked, but there's a lot of redundancy in the show() function, 
just to obtain the pointer to the private data.
I would be glad if anyone suggested any better approach to create and manage 
sysfs directories and attribute groups.

Thank you,
Raghavendra

  






---
[ C-DAC is on Social-Media too. Kindly follow us at:
Facebook: https://www.facebook.com/CDACINDIA  Twitter: @cdacindia ]

This e-mail is for the sole use of the intended recipient(s) and may
contain confidential and privileged information. If you are not the
intended recipient, please contact the sender by reply e-mail and destroy
all copies and the original message. Any unauthorized review, use,
disclosure, dissemination, forwarding, printing or copying of this email
is strictly prohibited and appropriate legal action will be taken.
---


___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Understanding #ifdef in .h files

2014-06-20 Thread Harold André
Hi,

I try to understand how #ifdef in .h files works.

I read Greg Kroah-Hartman's Coding style paper
http://www.kroah.com/linux/talks/ols_2002_kernel_codingstyle_talk/html/mgp00031.html

And as he says, i try to do a simple example but it does not work. I
try with a small piece of C outside the kernel. I have 3 files.


test_ifdef.h:

#ifdef TEST_FUNCTION
void test(int *value);
#else
static inline void test(int *value) { }
#endif

test_ifdef.c:

#include test_ifdef.h

void test(int *value)
{
*value += 1;
}

main.c:

#include stdio.h
#include test_ifdef.h

int main(int argc, char *argv[])
{
int i = 3;

printf(i = %d\n, i);

test(i);

printf(i = %d\n, i);

return 0;
}


And when i compile:

$ gcc -Wall -g main.c test_ifdef.c -o test_ifdef -DTEST_FUNCTION
$ ./test_ifdef 
i = 3
i = 4
$ gcc -Wall -g main.c test_ifdef.c -o test_ifdef
test_ifdef.c:14:6: error: redefinition of ‘test’
 void test(int *value)
  ^
In file included from test_ifdef.c:12:0:
test_ifdef.h:17:20: note: previous definition of ‘test’ was here
 static inline void test(int *value) { }
^
$

I understand why it does not compile. But:
- How it can work in the kernel code ?
- Is-it possible to do this in code outside the kernel ?

Thank you.

Harold

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: Understanding #ifdef in .h files

2014-06-20 Thread Pranay Srivastava
Hi Harold

On 6/20/14, Harold André harold.an...@gmx.fr wrote:
 Hi,

 I try to understand how #ifdef in .h files works.

 I read Greg Kroah-Hartman's Coding style paper
 http://www.kroah.com/linux/talks/ols_2002_kernel_codingstyle_talk/html/mgp00031.html

 And as he says, i try to do a simple example but it does not work. I
 try with a small piece of C outside the kernel. I have 3 files.


 test_ifdef.h:


You say here you will define the function else where if TEST_FUNCTION is defined

   #ifdef TEST_FUNCTION
   void test(int *value);
   #else
   static inline void test(int *value) { }
   #endif

 test_ifdef.c:

   #include test_ifdef.h

But here you do on and define it any way. You must stick to the rule
you created earlier. If you are defining it here then this must also
be under the test of ifdef TEST_FUNCTION
   void test(int *value)
   {
   *value += 1;
   }

 main.c:

   #include stdio.h
   #include test_ifdef.h

   int main(int argc, char *argv[])
   {
   int i = 3;
   
   printf(i = %d\n, i);

   test(i);

   printf(i = %d\n, i);

   return 0;
   }


 And when i compile:

 $ gcc -Wall -g main.c test_ifdef.c -o test_ifdef -DTEST_FUNCTION
 $ ./test_ifdef
 i = 3
 i = 4
 $ gcc -Wall -g main.c test_ifdef.c -o test_ifdef
 test_ifdef.c:14:6: error: redefinition of ‘test’
  void test(int *value)
   ^
 In file included from test_ifdef.c:12:0:
 test_ifdef.h:17:20: note: previous definition of ‘test’ was here
  static inline void test(int *value) { }
 ^
 $

 I understand why it does not compile. But:
 - How it can work in the kernel code ?
 - Is-it possible to do this in code outside the kernel ?

 Thank you.

 Harold

 ___
 Kernelnewbies mailing list
 Kernelnewbies@kernelnewbies.org
 http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies



-- 
---P.K.S

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


TASK05

2014-06-20 Thread Akam
Hello,

I am stuck on Task05. Can you help me with more pointers for this task ? So
I can read and understand and write my own code.

I am sorry, I am lazy. I tried following LDD chapter mentioned but I am not
able to get it into the code, so as to get it working. Either I am not
trying hard enough or I am not understanding it as I am lacking some basics
to get  right clarity from reading chapter 14 of LDD.

Can somebody give a push to my stuck threads so I get it right?

Thanks in advance. Sorry if I sound vague.

-- 
cheers
Akam
___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: TASK05

2014-06-20 Thread Sudip Mukherjee
On Fri, Jun 20, 2014 at 5:32 PM, Akam azurelus...@gmail.com wrote:
 Hello,

 I am stuck on Task05. Can you help me with more pointers for this task ? So
 I can read and understand and write my own code.

 I am sorry, I am lazy. I tried following LDD chapter mentioned but I am not
 able to get it into the code, so as to get it working. Either I am not
 trying hard enough or I am not understanding it as I am lacking some basics
 to get  right clarity from reading chapter 14 of LDD.

 Can somebody give a push to my stuck threads so I get it right?

 Thanks in advance. Sorry if I sound vague.

Hi Akram,
The rule for the Challenge says you really should be doing your own
work , so  you really should be doing your own work . shouldn't you ?
And besides task 5 is very easy ... although I was stuck with it for
almost 3 weeks :) , but still its very easy ..

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: TASK05

2014-06-20 Thread Fernando Apesteguía
El 20/06/2014 14:02, Akam azurelus...@gmail.com escribió:

 Hello,

 I am stuck on Task05. Can you help me with more pointers for this task ?
So I can read and understand and write my own code.

 I am sorry, I am lazy. I tried following LDD chapter mentioned but I am
not able to get it into the code, so as to get it working. Either I am not
trying hard enough or I am not understanding it as I am lacking some basics
to get  right clarity from reading chapter 14 of LDD.

 Can somebody give a push to my stuck threads so I get it right?

 Thanks in advance. Sorry if I sound vague.

Hi Akam,

Since this is a challenge, you're supposed to find your own solutions.
Little was pretty specific about this.

Just relax. Leave the computer untouched for a couple of days and forget
the challenge. Then try to tackle it again. Have another read to the ldd
and search in the kernel for similar code (that can give you a good hint).
If you don't get it right the first time, don't despair, do one step at a
time until you are done.

Good luck!


 --
 cheers
 Akam

 ___
 Kernelnewbies mailing list
 Kernelnewbies@kernelnewbies.org
 http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: TASK05

2014-06-20 Thread karthik nayak
Hello,
Even i found it difficult at first, read online , search a bit. it's better
when you do it yourself :D
Regards,
Karthik


On Fri, Jun 20, 2014 at 5:32 PM, Akam azurelus...@gmail.com wrote:

 Hello,

 I am stuck on Task05. Can you help me with more pointers for this task ?
 So I can read and understand and write my own code.

 I am sorry, I am lazy. I tried following LDD chapter mentioned but I am
 not able to get it into the code, so as to get it working. Either I am not
 trying hard enough or I am not understanding it as I am lacking some basics
 to get  right clarity from reading chapter 14 of LDD.

 Can somebody give a push to my stuck threads so I get it right?

 Thanks in advance. Sorry if I sound vague.

 --
 cheers
 Akam

 ___
 Kernelnewbies mailing list
 Kernelnewbies@kernelnewbies.org
 http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: TASK05

2014-06-20 Thread Sudip Mukherjee
On Fri, Jun 20, 2014 at 5:41 PM, Sudip Mukherjee
sudipm.mukher...@gmail.com wrote:
 On Fri, Jun 20, 2014 at 5:32 PM, Akam azurelus...@gmail.com wrote:
 Hello,

 I am stuck on Task05. Can you help me with more pointers for this task ? So
 I can read and understand and write my own code.

 I am sorry, I am lazy. I tried following LDD chapter mentioned but I am not
 able to get it into the code, so as to get it working. Either I am not
 trying hard enough or I am not understanding it as I am lacking some basics
 to get  right clarity from reading chapter 14 of LDD.

 Can somebody give a push to my stuck threads so I get it right?

 Thanks in advance. Sorry if I sound vague.

 Hi Akram,
 The rule for the Challenge says you really should be doing your own
 work , so  you really should be doing your own work . shouldn't you ?
 And besides task 5 is very easy ... although I was stuck with it for
 almost 3 weeks :) , but still its very easy ..
And if you think you are lacking the basics, I will advice you to go
back to the basics first.

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: TASK05

2014-06-20 Thread parinay
 So I can read and understand and write my own code.

I think I already mentioned it, write my own code .

I take this as, I was vague in the email and will correct myself next time

Thanks  Fernando, that’s conducive.

Thanks all.
PS BTW My name is AKAM.




On Fri, Jun 20, 2014 at 5:44 PM, Sudip Mukherjee sudipm.mukher...@gmail.com
 wrote:

 On Fri, Jun 20, 2014 at 5:41 PM, Sudip Mukherjee
 sudipm.mukher...@gmail.com wrote:
  On Fri, Jun 20, 2014 at 5:32 PM, Akam azurelus...@gmail.com wrote:
  Hello,
 
  I am stuck on Task05. Can you help me with more pointers for this task
 ? So
  I can read and understand and write my own code.
 
  I am sorry, I am lazy. I tried following LDD chapter mentioned but I am
 not
  able to get it into the code, so as to get it working. Either I am not
  trying hard enough or I am not understanding it as I am lacking some
 basics
  to get  right clarity from reading chapter 14 of LDD.
 
  Can somebody give a push to my stuck threads so I get it right?
 
  Thanks in advance. Sorry if I sound vague.
 
  Hi Akram,
  The rule for the Challenge says you really should be doing your own
  work , so  you really should be doing your own work . shouldn't you ?
  And besides task 5 is very easy ... although I was stuck with it for
  almost 3 weeks :) , but still its very easy ..
 And if you think you are lacking the basics, I will advice you to go
 back to the basics first.

 ___
 Kernelnewbies mailing list
 Kernelnewbies@kernelnewbies.org
 http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies




-- 
easy is right
begin right and you're easy
continue easy and you're right
the right way to go easy is to forget the right way
and forget that the going is easy
___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: Understanding #ifdef in .h files

2014-06-20 Thread Pranay Srivastava
On Fri, Jun 20, 2014 at 6:29 PM, Harold André harold.an...@gmx.fr wrote:
 Le Fri, 20 Jun 2014 16:36:58 +0530,
 Pranay Srivastava pran...@gmail.com a écrit :


 You say here you will define the function else where if TEST_FUNCTION
 is defined

  #ifdef TEST_FUNCTION
  void test(int *value);
  #else
  static inline void test(int *value) { }
  #endif
 
  test_ifdef.c:
 
  #include test_ifdef.h
 
 But here you do on and define it any way. You must stick to the rule
 you created earlier. If you are defining it here then this must also
 be under the test of ifdef TEST_FUNCTION
  void test(int *value)
  {
  *value += 1;
  }
 

 Thank you Pranay for your answer. I understand this now.

 But when i look at the kernel code, i don't see ifdef test around the
 definition of the function. For example, i look for the function
 hiddev_hid_event:

 In include/linux/hiddev.h:
 #ifdef CONFIG_USB_HIDDEV
 ...
 void hiddev_hid_event(struct hid_device *hid, struct hid_field *field,
 struct hid_usage *usage, __s32 value);
 ...
 #else
 ...
 static inline void hiddev_hid_event(struct hid_device *hid, struct
 hid_field *field, struct hid_usage *usage, __s32 value) { }
 ...
 #endif

 In drivers/hid/usbhid/hiddev.c:
 /*
  * This is where hid.c calls into hiddev to pass an event that occurred
 over

That's right but the magic doesn't happen here :-)

if you see usbhid/Makefile you'll understand what I mean :-). If not ,
please do ask.


  * the interrupt pipe
  */
 void hiddev_hid_event(struct hid_device *hid, struct hid_field *field,
   struct hid_usage *usage, __s32 value)
 {
 unsigned type = field-report_type;
 struct hiddev_usage_ref uref;

 uref.report_type =
   (type == HID_INPUT_REPORT) ? HID_REPORT_TYPE_INPUT :
   ((type == HID_OUTPUT_REPORT) ? HID_REPORT_TYPE_OUTPUT :
((type == HID_FEATURE_REPORT) ? HID_REPORT_TYPE_FEATURE :
 0)); uref.report_id = field-report-id;
 uref.field_index = field-index;
 uref.usage_index = (usage - field-usage);
 uref.usage_code = usage-hid;
 uref.value = value;

 hiddev_send_event(hid, uref);
 }
 EXPORT_SYMBOL_GPL(hiddev_hid_event);

 And in drivers/hid/hid-core.c:
 ...

 if (hid-claimed  HID_CLAIMED_INPUT)
 hidinput_hid_event(hid, field, usage, value);
 if (hid-claimed  HID_CLAIMED_HIDDEV  interrupt 
 hid-hiddev_hid_event)
 hid-hiddev_hid_event(hid, field, usage, value);
 ...

 If i'm right. The function hiddev_hid_event is always defined in
 hiddev.c whatever CONFIG_USB_HIDDEV is defined or not ?
 How is it possible ?



-- 
---P.K.S

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: Understanding #ifdef in .h files

2014-06-20 Thread Harold André
Le Fri, 20 Jun 2014 16:36:58 +0530,
Pranay Srivastava pran...@gmail.com a écrit :


 You say here you will define the function else where if TEST_FUNCTION
 is defined
 
  #ifdef TEST_FUNCTION
  void test(int *value);
  #else
  static inline void test(int *value) { }
  #endif
 
  test_ifdef.c:
 
  #include test_ifdef.h
 
 But here you do on and define it any way. You must stick to the rule
 you created earlier. If you are defining it here then this must also
 be under the test of ifdef TEST_FUNCTION
  void test(int *value)
  {
  *value += 1;
  }
 

Thank you Pranay for your answer. I understand this now.

But when i look at the kernel code, i don't see ifdef test around the
definition of the function. For example, i look for the function
hiddev_hid_event:

In include/linux/hiddev.h:
#ifdef CONFIG_USB_HIDDEV
...
void hiddev_hid_event(struct hid_device *hid, struct hid_field *field,
struct hid_usage *usage, __s32 value);
...
#else
...
static inline void hiddev_hid_event(struct hid_device *hid, struct
hid_field *field, struct hid_usage *usage, __s32 value) { }
...
#endif

In drivers/hid/usbhid/hiddev.c:
/*
 * This is where hid.c calls into hiddev to pass an event that occurred
over
 * the interrupt pipe
 */
void hiddev_hid_event(struct hid_device *hid, struct hid_field *field,
  struct hid_usage *usage, __s32 value)
{
unsigned type = field-report_type;
struct hiddev_usage_ref uref;

uref.report_type =
  (type == HID_INPUT_REPORT) ? HID_REPORT_TYPE_INPUT :
  ((type == HID_OUTPUT_REPORT) ? HID_REPORT_TYPE_OUTPUT :
   ((type == HID_FEATURE_REPORT) ? HID_REPORT_TYPE_FEATURE :
0)); uref.report_id = field-report-id;
uref.field_index = field-index;
uref.usage_index = (usage - field-usage);
uref.usage_code = usage-hid;
uref.value = value;

hiddev_send_event(hid, uref);
}
EXPORT_SYMBOL_GPL(hiddev_hid_event);

And in drivers/hid/hid-core.c:
...

if (hid-claimed  HID_CLAIMED_INPUT)
hidinput_hid_event(hid, field, usage, value);
if (hid-claimed  HID_CLAIMED_HIDDEV  interrupt 
hid-hiddev_hid_event)
hid-hiddev_hid_event(hid, field, usage, value);
...

If i'm right. The function hiddev_hid_event is always defined in
hiddev.c whatever CONFIG_USB_HIDDEV is defined or not ?
How is it possible ?

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: How to get the average/max process scheduling latency

2014-06-20 Thread Teto
Thanks for the answer.

Do you know any tool/software to retrieve the average latency for a
specific program on a specific platform. This is to modelize the
application rate for data processing.



2014-06-19 22:16 GMT+02:00  valdis.kletni...@vt.edu:
 On Mon, 16 Jun 2014 18:23:56 +0200, Teto said:

 I could not find an answer yet. I've found that on latest kernel
 latency is on average around 3us with a max at 64us (I consider a
 moderate load). Is that correct ?

 Depends on your hardware and system load.  I'd hardly expect the same numbers
 from a busy Beaglebone or Raspberry Pi as from a idle high-end Intel i7 
 system

 (And things like processors that drop into sleep states when idle, with
 a latency hit to wake up, just add to the confusion)

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: Understanding #ifdef in .h files

2014-06-20 Thread Harold André
Le Fri, 20 Jun 2014 18:44:35 +0530,
Pranay Srivastava pran...@gmail.com a écrit :

 On Fri, Jun 20, 2014 at 6:29 PM, Harold André harold.an...@gmx.fr
 wrote:
  Le Fri, 20 Jun 2014 16:36:58 +0530,
  Pranay Srivastava pran...@gmail.com a écrit :
 
 
  You say here you will define the function else where if
  TEST_FUNCTION is defined
 
   #ifdef TEST_FUNCTION
   void test(int *value);
   #else
   static inline void test(int *value) { }
   #endif
  
   test_ifdef.c:
  
   #include test_ifdef.h
  
  But here you do on and define it any way. You must stick to the
  rule you created earlier. If you are defining it here then this
  must also be under the test of ifdef TEST_FUNCTION
   void test(int *value)
   {
   *value += 1;
   }
  
 
  Thank you Pranay for your answer. I understand this now.
 
  But when i look at the kernel code, i don't see ifdef test around
  the definition of the function. For example, i look for the function
  hiddev_hid_event:
 
  In include/linux/hiddev.h:
  #ifdef CONFIG_USB_HIDDEV
  ...
  void hiddev_hid_event(struct hid_device *hid, struct hid_field
  *field, struct hid_usage *usage, __s32 value);
  ...
  #else
  ...
  static inline void hiddev_hid_event(struct hid_device *hid, struct
  hid_field *field, struct hid_usage *usage, __s32 value) { }
  ...
  #endif
 
  In drivers/hid/usbhid/hiddev.c:
  /*
   * This is where hid.c calls into hiddev to pass an event that
  occurred over
 
 That's right but the magic doesn't happen here :-)
 
 if you see usbhid/Makefile you'll understand what I mean :-). If not ,
 please do ask.

Ah yes !! Ok, i understand !! ;-)
Thank Pranay for sharing your knowledge !

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: issues dealing with kobjects

2014-06-20 Thread Greg KH
On Fri, Jun 20, 2014 at 11:31:03AM +0530, Raghavendra wrote:
 Hello all,
 
 I am facing a small issue dealing with kobjects.
 I am writing a simple i2c driver for which I would like to export a few 
 sysfs attributes(files).

Please don't, unless these attributes are something that all other i2c
drivers export and are documented in Documentation/ABI/

 The files are many, so I've decided to pack them into a directory in 
 sysfs (inside the i2c device) and so I thought of kobjects.

No, please never use raw kobjects in a driver, use the driver core
functions instead.  You can have an attribute group that is associated
with your driver or device, and the driver core will automatically
create the files for you (in a subdir if you want it), in a race-free
manner.  Please use that interface instead.

thanks,

greg k-h

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: How to get the average/max process scheduling latency

2014-06-20 Thread Valdis . Kletnieks
On Fri, 20 Jun 2014 15:36:47 +0200, Teto said:
 Do you know any tool/software to retrieve the average latency for a
 specific program on a specific platform. This is to modelize the
 application rate for data processing.

You need to add while running under a specific application load, because
latencies can be different if you're under high enough load to keep the CPU
running at high clock rate, versus if it's dropping to a low clock rate and
then into a sleep state

The 'latencytop' utility may help here.



pgp92z76I_xzN.pgp
Description: PGP signature
___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies