Wait, stop right there. Binary sysfs attributes are for sending/receiving
binary data that is not intrepreted/manipulated by the kernel at all.
And LED devices do not seem to fall into the category that needs this
type of sysfs file, so please do not create it.
> and it seems to be correct, but when I echo data to the
> write function, it seems to get called 11 times. Here's what I have
> and did:
>
> static ssize_t my_write(struct kobject *kobj, struct bin_attribute
> *attr, char *buf, loff_t pos, size_t size)
> {
> print_string("called my_write function correctly.");
> return 0;
> }
Did you read the documentation on what your write function should return?
(hint, 0 is not what you think it means here).
Fix this and your problem will be solved.
But again, don't create a binary sysfs attribute, that is almost
never what you want.
What specifically are you wanting to export to userspace for a LED device
that is not working with the existing LED api in the kernel?
thanks,
greg k-h
Why isn't it relevant? You are using a LED driver, which already
has a well-specified interface for interacting with userspace, why
are you trying to create a new one? That will only break userspace
tools and is not allowed.
> 3. Do you have an alternate way to pass an array of binary data to a
> driver that doesn't have such a capability, like an LED driver?
> For an LED driver, this is useful if you wanted to send it a particular
> pattern of blinking to run at a faster rate than just setting it off/
> on from userspace could do, for example.
Are you sure the existing user/kernel api can't handle this already?
Are you wanting to do PWM with the LED to get it to change to different
values somehow? If so, I think the existing interface can handle this
today, right? Just set the different values in your driver beforehand.
thanks,
greg k-h
That type of pattern is easy to do from userspace, please do it that
way and not from within the kernel, that's not the proper place to do
it.
> I'm not breaking anything with userspace as it's not a device anyone
> will/can access except for my app.
You are creating a user/kernel API which is important to get correct.
> And it won't be released into the code base.
What do you mean by this? All kernel code must be published when
the product is shipped.
thanks,
greg k-h
The fact that Greg is paying attention to your questions at all is
a sign that he's trying to help. Greg is a very experienced kernel
expert. When he asks a question about what you are doing, it is
so that he can provide the best help possible. When he says
that something can be done another way better, it's based on
what you've described so far in your e-mails.
Very, very often when people inexperienced with the kernel
ask how to do something, they are missing knowledge about
a kernel system that already supports their need. But also
very often, people aren't very forthcoming with what their
exact need really is.
> 2. No, I'm not creating a general kernel API, I'm creating something
> that only I will be using, for my purpose, so it can be "incorrect" or
> "not quite right" if I want. As I said, if you know of some other way
> to get a block of binary data into the driver, feel free to suggest
> it, but this way works great and will end my headache, so I don't care
> if it's proper.
If you don't plan to maintain the code, or push it to mainline,
or release binaries including it to anyone - you are of course
free to do anything you want. If you do plan any of the above, it
could save you time and trouble to listen to Greg.
There are LOTS of ways to move binary data between user space
and the kernel. Which one is appropriate depends on a LOT
of considerations.
> 3. Proprietary code is not published.
If you don't plan to ship the kernel to anyone (for example, if it's
just part of some internal test framework), then that's right.
Otherwise, that's wrong.
-- Tim
> On Feb 10, 11:57�am, Greg KH <gre...@gmail.com> wrote:
>> On Thu, Feb 10, 2011 at 11:42 AM, jon.schell <jon.sch...@kyocera.com> wrote:
>>> Yes, I'm sure it can't handle it. �Not a PWM, doing something like:
>>> Turn on for 3 ms, turn off for 5ms, turn on for 1 ms, turn off for 1
>>> ms, turn on for 2 ms, turn off for 8 ms, etc. for any arbitrary
>>> pattern you want to do.
>>
>> That type of pattern is easy to do from userspace, please do it that
>> way and not from within the kernel, that's not the proper place to do
>> it.
>>
>>> I'm not breaking anything with userspace as it's not a device anyone
>>> will/can access except for my app.
>>
>> You are creating a user/kernel API which is important to get correct.
>>
>>> �And it won't be released into the code base.
>>
>> What do you mean by this? �All kernel code must be published when
>> the product is shipped.
>>
>> thanks,
>>
>> greg k-h
>
--
=============================
Tim Bird
Architecture Group Chair, CE Linux Forum
Senior Staff Engineer, Sony Network Entertainment
=============================
Ok, you know best.
> 2. No, I'm not creating a general kernel API, I'm creating something
> that only I will be using, for my purpose, so it can be "incorrect" or
> "not quite right" if I want. As I said, if you know of some other way
> to get a block of binary data into the driver, feel free to suggest
> it, but this way works great and will end my headache, so I don't care
> if it's proper.
There are lots of ways to do this. Using sysfs is not the way.
> 3. Proprietary code is not published.
Then don't use open source and ask for questions on public mailing
lists.
good luck,
greg k-h
--
unsubscribe: android-kerne...@googlegroups.com
website: http://groups.google.com/group/android-kernel