All of lore.kernel.org
 help / color / mirror / Atom feed
* Importance of kobject
@ 2017-05-17  7:08 Madhu K
       [not found] ` <CAJ1xhMUghEO1NLOhmq_O02KHz7YioTWyu=TNLTcQP8aRxAgV8A@mail.gmail.com>
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Madhu K @ 2017-05-17  7:08 UTC (permalink / raw)
  To: kernelnewbies

Hi All,

I am kernel newbie, I want to know the importance of kobject, can anybody
explain the importance of kobject with an example.

Thanks in advance.
Madhu
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20170517/18e52904/attachment.html 

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

* Fwd: Importance of kobject
       [not found] ` <CAJ1xhMUghEO1NLOhmq_O02KHz7YioTWyu=TNLTcQP8aRxAgV8A@mail.gmail.com>
@ 2017-05-17  7:21   ` Alexander Kapshuk
  2017-05-17  9:18     ` Rami Rosen
  0 siblings, 1 reply; 7+ messages in thread
From: Alexander Kapshuk @ 2017-05-17  7:21 UTC (permalink / raw)
  To: kernelnewbies

---------- Forwarded message ----------
From: Alexander Kapshuk <alexander.kapshuk@gmail.com>
Date: Wed, May 17, 2017 at 10:20 AM
Subject: Re: Importance of kobject
To: Madhu K <madhu.sk89@gmail.com>


On Wed, May 17, 2017 at 10:08 AM, Madhu K <madhu.sk89@gmail.com> wrote:
> Hi All,
>
> I am kernel newbie, I want to know the importance of kobject, can anybody
> explain the importance of kobject with an example.
>
> Thanks in advance.
> Madhu
>
> _______________________________________________
> Kernelnewbies mailing list
> Kernelnewbies at kernelnewbies.org
> https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>

Kobjects play an essential role in the Device Model.
The documentation below may be a good starting point in learning about kobjects:

https://lwn.net/images/pdf/LDD3/ch14.pdf
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/plain/Documentation/kobject.txt?h=v4.12-rc1

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

* Importance of kobject
  2017-05-17  7:21   ` Fwd: " Alexander Kapshuk
@ 2017-05-17  9:18     ` Rami Rosen
  0 siblings, 0 replies; 7+ messages in thread
From: Rami Rosen @ 2017-05-17  9:18 UTC (permalink / raw)
  To: kernelnewbies

Hi,
Also sysfs is tied inherently to the kobject infrastructure. So I
suggest that you will take a look also in
http://elixir.free-electrons.com/linux/latest/source/Documentation/filesystems/sysfs.txt

Chapter 14 of Linux Device Drivers, 3rd edition, was written in 2005,
so you should take in account that things change a bit since then in
terms of implementation details. The principles are for a large extent
quite the same, though.

Regards,
Rami Rosen




On 17 May 2017 at 10:21, Alexander Kapshuk <alexander.kapshuk@gmail.com> wrote:
> ---------- Forwarded message ----------
> From: Alexander Kapshuk <alexander.kapshuk@gmail.com>
> Date: Wed, May 17, 2017 at 10:20 AM
> Subject: Re: Importance of kobject
> To: Madhu K <madhu.sk89@gmail.com>
>
>
> On Wed, May 17, 2017 at 10:08 AM, Madhu K <madhu.sk89@gmail.com> wrote:
>> Hi All,
>>
>> I am kernel newbie, I want to know the importance of kobject, can anybody
>> explain the importance of kobject with an example.
>>
>> Thanks in advance.
>> Madhu
>>
>> _______________________________________________
>> Kernelnewbies mailing list
>> Kernelnewbies at kernelnewbies.org
>> https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>>
>
> Kobjects play an essential role in the Device Model.
> The documentation below may be a good starting point in learning about kobjects:
>
> https://lwn.net/images/pdf/LDD3/ch14.pdf
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/plain/Documentation/kobject.txt?h=v4.12-rc1
>
> _______________________________________________
> Kernelnewbies mailing list
> Kernelnewbies at kernelnewbies.org
> https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

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

* Importance of kobject
  2017-05-17  7:08 Importance of kobject Madhu K
       [not found] ` <CAJ1xhMUghEO1NLOhmq_O02KHz7YioTWyu=TNLTcQP8aRxAgV8A@mail.gmail.com>
@ 2017-05-17 10:56 ` Bjørn Mork
  2017-05-17 11:34 ` Okash Khawaja
  2 siblings, 0 replies; 7+ messages in thread
From: Bjørn Mork @ 2017-05-17 10:56 UTC (permalink / raw)
  To: kernelnewbies

Madhu K <madhu.sk89@gmail.com> writes:

> I am kernel newbie, I want to know the importance of kobject, can anybody
> explain the importance of kobject with an example.

I think the best generic example is that you can write Linux drivers,
using kobjects all over, without ever having to actually worry about
kobjects.  You just use struct device, often without even realizing that
there is a kobject embedded in it.

At least that's all I know about them :-)

If you want code exaples, then "git grep kobj drivers/" will provide
enough for a lifetime.  And more.


Bj?rn

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

* Importance of kobject
  2017-05-17  7:08 Importance of kobject Madhu K
       [not found] ` <CAJ1xhMUghEO1NLOhmq_O02KHz7YioTWyu=TNLTcQP8aRxAgV8A@mail.gmail.com>
  2017-05-17 10:56 ` Bjørn Mork
@ 2017-05-17 11:34 ` Okash Khawaja
  2017-05-17 11:50   ` Greg KH
  2 siblings, 1 reply; 7+ messages in thread
From: Okash Khawaja @ 2017-05-17 11:34 UTC (permalink / raw)
  To: kernelnewbies

Hi,

On Wed, May 17, 2017 at 8:08 AM, Madhu K <madhu.sk89@gmail.com> wrote:
> Hi All,
>
> I am kernel newbie, I want to know the importance of kobject, can anybody
> explain the importance of kobject with an example.

To state a not-so-popular analogy, kobjects can also be viewed as root
object in object oriented programming. So a bit like java.lang.Object.
Of course it is not a root object and indeed C is not OO, but this
view helps in thinking about it.

This section from ldd3 lists some of the tasks handled by kobject:
http://www.makelinux.net/ldd3/chp-14-sect-1. So whichever struct
ultimately encapsulates (inherits from) kobject will have those tasks
handled for it for free. This view is in addition to others expressed
here.

HTH
Okash

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

* Importance of kobject
  2017-05-17 11:34 ` Okash Khawaja
@ 2017-05-17 11:50   ` Greg KH
  2017-05-17 18:36     ` Luis de Bethencourt
  0 siblings, 1 reply; 7+ messages in thread
From: Greg KH @ 2017-05-17 11:50 UTC (permalink / raw)
  To: kernelnewbies

On Wed, May 17, 2017 at 12:34:28PM +0100, Okash Khawaja wrote:
> Hi,
> 
> On Wed, May 17, 2017 at 8:08 AM, Madhu K <madhu.sk89@gmail.com> wrote:
> > Hi All,
> >
> > I am kernel newbie, I want to know the importance of kobject, can anybody
> > explain the importance of kobject with an example.
> 
> To state a not-so-popular analogy, kobjects can also be viewed as root
> object in object oriented programming. So a bit like java.lang.Object.
> Of course it is not a root object and indeed C is not OO, but this
> view helps in thinking about it.

Well, it _is_ a "root object", and you can write OO code in C, which is
what we did for kobjects (and struct device, and struct class, and kref,
and other things like that.)

So it is a "popular" analogy, as this is exactly what the authors of the
code were intending for people to see.

thanks,

greg k-h

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

* Importance of kobject
  2017-05-17 11:50   ` Greg KH
@ 2017-05-17 18:36     ` Luis de Bethencourt
  0 siblings, 0 replies; 7+ messages in thread
From: Luis de Bethencourt @ 2017-05-17 18:36 UTC (permalink / raw)
  To: kernelnewbies

On Wed, May 17, 2017, at 04:50 AM, Greg KH wrote:
> On Wed, May 17, 2017 at 12:34:28PM +0100, Okash Khawaja wrote:
> > Hi,
> > 
> > On Wed, May 17, 2017 at 8:08 AM, Madhu K <madhu.sk89@gmail.com> wrote:
> > > Hi All,
> > >
> > > I am kernel newbie, I want to know the importance of kobject, can anybody
> > > explain the importance of kobject with an example.
> > 
> > To state a not-so-popular analogy, kobjects can also be viewed as root
> > object in object oriented programming. So a bit like java.lang.Object.
> > Of course it is not a root object and indeed C is not OO, but this
> > view helps in thinking about it.
> 
> Well, it _is_ a "root object", and you can write OO code in C, which is
> what we did for kobjects (and struct device, and struct class, and kref,
> and other things like that.)
> 
> So it is a "popular" analogy, as this is exactly what the authors of the
> code were intending for people to see.
> 
> thanks,
> 
> greg k-h
> 

Hi,

You also have GObject proving that you can do OOP in C.
Use kobject like you would a base class.

Luis

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

end of thread, other threads:[~2017-05-17 18:36 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-17  7:08 Importance of kobject Madhu K
     [not found] ` <CAJ1xhMUghEO1NLOhmq_O02KHz7YioTWyu=TNLTcQP8aRxAgV8A@mail.gmail.com>
2017-05-17  7:21   ` Fwd: " Alexander Kapshuk
2017-05-17  9:18     ` Rami Rosen
2017-05-17 10:56 ` Bjørn Mork
2017-05-17 11:34 ` Okash Khawaja
2017-05-17 11:50   ` Greg KH
2017-05-17 18:36     ` Luis de Bethencourt

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.