linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* read() via USB bus
@ 2021-08-09  7:58 Muni Sekhar
  2021-08-09  8:15 ` Oliver Neukum
  0 siblings, 1 reply; 11+ messages in thread
From: Muni Sekhar @ 2021-08-09  7:58 UTC (permalink / raw)
  To: kernelnewbies, linux-usb, linux-kernel

Hi all,

PCIe memory mapped registers can be read via readb(), readw(), readl()
kernel API's. Similarly what are the kernel API to read the device
registers via USB bus

-- 
Thanks,
Sekhar

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

* Re: read() via USB bus
  2021-08-09  7:58 read() via USB bus Muni Sekhar
@ 2021-08-09  8:15 ` Oliver Neukum
  2021-08-09  8:44   ` Greg KH
                     ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: Oliver Neukum @ 2021-08-09  8:15 UTC (permalink / raw)
  To: Muni Sekhar, kernelnewbies, linux-usb, linux-kernel


On 09.08.21 09:58, Muni Sekhar wrote:
> Hi all,
>
> PCIe memory mapped registers can be read via readb(), readw(), readl()
> kernel API's. Similarly what are the kernel API to read the device
> registers via USB bus
>

Hi,

I am afraid this is based on a fundamental misunderstanding on how
USB works. It is based on passing messages, not reading and writing
registers.

USB devices are primarily based on endpoints, not registers. A literal
answer to your question would point you to the clear/set/get_feature
standard requests of chapter 9 of the specification, but that really
will not help you, as you are making assumption that fundamentally
do not apply.

I hope this list stays friendly to newcomers and we will answer
specific questions, but at this point I must advise you to first
read an introductory book.

    HTH
        Oliver



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

* Re: read() via USB bus
  2021-08-09  8:15 ` Oliver Neukum
@ 2021-08-09  8:44   ` Greg KH
  2021-08-12  9:45     ` LDD 3rd ed. - It was: " Fabio M. De Francesco
  2021-08-09 16:19   ` Muni Sekhar
  2021-08-10 14:13   ` Muni Sekhar
  2 siblings, 1 reply; 11+ messages in thread
From: Greg KH @ 2021-08-09  8:44 UTC (permalink / raw)
  To: Muni Sekhar; +Cc: Oliver Neukum, kernelnewbies, linux-usb, linux-kernel

On Mon, Aug 09, 2021 at 10:15:29AM +0200, Oliver Neukum wrote:
> 
> On 09.08.21 09:58, Muni Sekhar wrote:
> > Hi all,
> >
> > PCIe memory mapped registers can be read via readb(), readw(), readl()
> > kernel API's. Similarly what are the kernel API to read the device
> > registers via USB bus
> >
> 
> Hi,
> 
> I am afraid this is based on a fundamental misunderstanding on how
> USB works. It is based on passing messages, not reading and writing
> registers.
> 
> USB devices are primarily based on endpoints, not registers. A literal
> answer to your question would point you to the clear/set/get_feature
> standard requests of chapter 9 of the specification, but that really
> will not help you, as you are making assumption that fundamentally
> do not apply.
> 
> I hope this list stays friendly to newcomers and we will answer
> specific questions, but at this point I must advise you to first
> read an introductory book.

Along these lines, take a look at the book, Linux Device Drivers, third
edition, which is free online, as it has a chapter about USB drivers and
how they work.  That should help you out to understand the issues
involved with USB devices.

If you have specific questions after looking at that, and reading the
basic usb-skeleton.c driver in the kernel source tree, please let us
know!

thanks,

greg k-h

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

* Re: read() via USB bus
  2021-08-09  8:15 ` Oliver Neukum
  2021-08-09  8:44   ` Greg KH
@ 2021-08-09 16:19   ` Muni Sekhar
  2021-08-10 14:13   ` Muni Sekhar
  2 siblings, 0 replies; 11+ messages in thread
From: Muni Sekhar @ 2021-08-09 16:19 UTC (permalink / raw)
  To: Oliver Neukum; +Cc: kernelnewbies, linux-usb, linux-kernel

On Mon, Aug 9, 2021 at 1:45 PM Oliver Neukum <oneukum@suse.com> wrote:
>
>
> On 09.08.21 09:58, Muni Sekhar wrote:
> > Hi all,
> >
> > PCIe memory mapped registers can be read via readb(), readw(), readl()
> > kernel API's. Similarly what are the kernel API to read the device
> > registers via USB bus
> >
>
> Hi,
>
> I am afraid this is based on a fundamental misunderstanding on how
> USB works. It is based on passing messages, not reading and writing
> registers.
>
> USB devices are primarily based on endpoints, not registers. A literal
> answer to your question would point you to the clear/set/get_feature
> standard requests of chapter 9 of the specification, but that really
> will not help you, as you are making assumption that fundamentally
> do not apply.
>
> I hope this list stays friendly to newcomers and we will answer
> specific questions, but at this point I must advise you to first
> read an introductory book.
Thank you, I will check it out.
>
>     HTH
>         Oliver
>
>


-- 
Thanks,
Sekhar

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

* Re: read() via USB bus
  2021-08-09  8:15 ` Oliver Neukum
  2021-08-09  8:44   ` Greg KH
  2021-08-09 16:19   ` Muni Sekhar
@ 2021-08-10 14:13   ` Muni Sekhar
  2021-08-10 14:20     ` Oliver Neukum
  2 siblings, 1 reply; 11+ messages in thread
From: Muni Sekhar @ 2021-08-10 14:13 UTC (permalink / raw)
  To: Oliver Neukum; +Cc: kernelnewbies, linux-usb, linux-kernel

On Mon, Aug 9, 2021 at 1:45 PM Oliver Neukum <oneukum@suse.com> wrote:
>
>
> On 09.08.21 09:58, Muni Sekhar wrote:
> > Hi all,
> >
> > PCIe memory mapped registers can be read via readb(), readw(), readl()
> > kernel API's. Similarly what are the kernel API to read the device
> > registers via USB bus
> >
>
> Hi,
>
> I am afraid this is based on a fundamental misunderstanding on how
> USB works. It is based on passing messages, not reading and writing
> registers.

I am referring to the code mentioned in
https://patchwork.kernel.org/project/linux-arm-msm/patch/1534464348-8227-3-git-send-email-pheragu@codeaurora.org/

As per this driver gets access to the Qcomm’s USB h/w device registers
via devm_extcon_dev_allocate(), devm_extcon_dev_register(),
platform_get_resource() and devm_ioremap_resource API’s.

What does the USB external connector EXTCON_USB \ EXTCON_USB_HOST
devices means? Are these different from normal USB devices?


>
> USB devices are primarily based on endpoints, not registers. A literal
> answer to your question would point you to the clear/set/get_feature
> standard requests of chapter 9 of the specification, but that really
> will not help you, as you are making assumption that fundamentally
> do not apply.
>
> I hope this list stays friendly to newcomers and we will answer
> specific questions, but at this point I must advise you to first
> read an introductory book.
>
>     HTH
>         Oliver
>
>


-- 
Thanks,
Sekhar

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

* Re: read() via USB bus
  2021-08-10 14:13   ` Muni Sekhar
@ 2021-08-10 14:20     ` Oliver Neukum
       [not found]       ` <CAHhAz+ioThu3v4VW6LVqFn9MhgNaqv=qDoxh8Orkw2LOEC_JYA@mail.gmail.com>
  0 siblings, 1 reply; 11+ messages in thread
From: Oliver Neukum @ 2021-08-10 14:20 UTC (permalink / raw)
  To: Muni Sekhar, Oliver Neukum; +Cc: kernelnewbies, linux-usb, linux-kernel


On 10.08.21 16:13, Muni Sekhar wrote:
> On Mon, Aug 9, 2021 at 1:45 PM Oliver Neukum <oneukum@suse.com> wrote:
>>
>> On 09.08.21 09:58, Muni Sekhar wrote:
>>> Hi all,
>>>
>>> PCIe memory mapped registers can be read via readb(), readw(), readl()
>>> kernel API's. Similarly what are the kernel API to read the device
>>> registers via USB bus
>>>
>> Hi,
>>
>> I am afraid this is based on a fundamental misunderstanding on how
>> USB works. It is based on passing messages, not reading and writing
>> registers.
> I am referring to the code mentioned in
> https://patchwork.kernel.org/project/linux-arm-msm/patch/1534464348-8227-3-git-send-email-pheragu@codeaurora.org/
>
> As per this driver gets access to the Qcomm’s USB h/w device registers
> via devm_extcon_dev_allocate(), devm_extcon_dev_register(),
> platform_get_resource() and devm_ioremap_resource API’s.
>
> What does the USB external connector EXTCON_USB \ EXTCON_USB_HOST
> devices means? Are these different from normal USB devices?
>
Hi,

those are not USB devices. Those are devices associated with a USB bus
and are to be
found on the host's CPU's bus. This is like a graphics card is from the
driver's view
not a DisplayPort device or a SCSI controller is not a SCSI device for
its driver.

A host controller and associated devices can be on any bus. Such
controllers follow
their separate specifications and how they are to be driven is strictly
speaking
not part of USB:

    Regards
        Oliver



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

* Re: read() via USB bus
       [not found]       ` <CAHhAz+ioThu3v4VW6LVqFn9MhgNaqv=qDoxh8Orkw2LOEC_JYA@mail.gmail.com>
@ 2021-08-11 10:04         ` Oliver Neukum
  0 siblings, 0 replies; 11+ messages in thread
From: Oliver Neukum @ 2021-08-11 10:04 UTC (permalink / raw)
  To: Muni Sekhar, Oliver Neukum; +Cc: kernelnewbies, linux-usb, linux-kernel


On 10.08.21 21:27, Muni Sekhar wrote:
>
> Any other examples of devices associated with the USB bus? Do we have
> any reference driver in the mainline kernel tree?


No, not really. We have the debug serial drivers,
but they are associated with a host controller
as such.

> Does lsusb reports these devices?
No.

    Regards
        Oliver


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

* LDD 3rd ed. - It was: Re: read() via USB bus
  2021-08-09  8:44   ` Greg KH
@ 2021-08-12  9:45     ` Fabio M. De Francesco
  2021-08-12 10:13       ` Valdis Klētnieks
  2021-08-12 10:18       ` Greg KH
  0 siblings, 2 replies; 11+ messages in thread
From: Fabio M. De Francesco @ 2021-08-12  9:45 UTC (permalink / raw)
  To: Greg KH
  Cc: Muni Sekhar, Oliver Neukum, kernelnewbies, linux-usb, linux-kernel

Hi Greg,

On Monday, August 9, 2021 10:44:23 AM CEST Greg KH wrote:
> On Mon, Aug 09, 2021 at 10:15:29AM +0200, Oliver Neukum wrote:
> > On 09.08.21 09:58, Muni Sekhar wrote:
> > > Hi all,
> > > 
> > > PCIe memory mapped registers can be read via readb(), readw(), readl()
> > > kernel API's. Similarly what are the kernel API to read the device
> > > registers via USB bus
> > 
> > [...]
> >
> > I hope this list stays friendly to newcomers and we will answer
> > specific questions, but at this point I must advise you to first
> > read an introductory book.
> 
> Along these lines, take a look at the book, Linux Device Drivers, third
> edition, which is free online, as it has a chapter about USB drivers and
> how they work.  That should help you out to understand the issues
> involved with USB devices.
> 
I've heard that your book, LDD 3rd edition, has become obsolete a long time 
ago and most sample code cannot anymore build. Reading what you wrote above 
seems to contradict what I've been told by others... I must admit that I've 
just had a print copy of it that I have not yet opened for reading, therefore 
maybe that I'm totally wrong in assuming the above.

Do you mind to elaborate a bit more on this subject, please? I mean: can you 
point out which chapters, which content, should be skipped (if there's really 
something which is no more correct/relevant to today's practice of drivers  
development and kernel hacking?

One more question, please... if after carefully studying its content, someone 
wanted to change and update part of the book content to reflect the changes in 
Linux API and in the current best practices, would it be (legally) allowed to 
publish a v4 on GitHub for the convenience of everyone interested in learning 
for free? However, I understand that it would be not so easy to come up with a 
good and error free text if not addressed as a public long term project and 
I'm also not sure of what tools are needed to edit PDF files. (At the moment 
my question is for a hypothetical scenario, just to know whether or not it 
would be technically and legally doable). 

I suppose that the answers to the above questions might be of interest to a 
lot of newcomers like me, so please, if you have time, I'd appreciate to read 
your reply.

Thanks,

Fabio
>
> If you have specific questions after looking at that, and reading the
> basic usb-skeleton.c driver in the kernel source tree, please let us
> know!
> 
> thanks,
> 
> greg k-h





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

* Re: LDD 3rd ed. - It was: Re: read() via USB bus
  2021-08-12  9:45     ` LDD 3rd ed. - It was: " Fabio M. De Francesco
@ 2021-08-12 10:13       ` Valdis Klētnieks
  2021-08-12 10:18       ` Greg KH
  1 sibling, 0 replies; 11+ messages in thread
From: Valdis Klētnieks @ 2021-08-12 10:13 UTC (permalink / raw)
  To: Fabio M. De Francesco
  Cc: Greg KH, Muni Sekhar, Oliver Neukum, kernelnewbies, linux-usb,
	linux-kernel

[-- Attachment #1: Type: text/plain, Size: 794 bytes --]

On Thu, 12 Aug 2021 11:45:45 +0200, "Fabio M. De Francesco" said:

> I've heard that your book, LDD 3rd edition, has become obsolete a long time
> ago and most sample code cannot anymore build. Reading what you wrote above
> seems to contradict what I've been told by others... I must admit that I've
> just had a print copy of it that I have not yet opened for reading, therefore
> maybe that I'm totally wrong in assuming the above.

The APIs have all changed a lot since the 3rd edition.

The concepts haven't changed that much. And given that the in-kernel APIs
have *always* been a moving target, being able to deal with the fact that
a given function now takes a 'struct foo*' rather than a 'struct bar *' is a very
necessary skill for anybody who's planning to do serious kernel work.



[-- Attachment #2: Type: application/pgp-signature, Size: 494 bytes --]

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

* Re: LDD 3rd ed. - It was: Re: read() via USB bus
  2021-08-12  9:45     ` LDD 3rd ed. - It was: " Fabio M. De Francesco
  2021-08-12 10:13       ` Valdis Klētnieks
@ 2021-08-12 10:18       ` Greg KH
  2021-08-12 10:26         ` Robert P. J. Day
  1 sibling, 1 reply; 11+ messages in thread
From: Greg KH @ 2021-08-12 10:18 UTC (permalink / raw)
  To: Fabio M. De Francesco
  Cc: Muni Sekhar, Oliver Neukum, kernelnewbies, linux-usb, linux-kernel

On Thu, Aug 12, 2021 at 11:45:45AM +0200, Fabio M. De Francesco wrote:
> Hi Greg,
> 
> On Monday, August 9, 2021 10:44:23 AM CEST Greg KH wrote:
> > On Mon, Aug 09, 2021 at 10:15:29AM +0200, Oliver Neukum wrote:
> > > On 09.08.21 09:58, Muni Sekhar wrote:
> > > > Hi all,
> > > > 
> > > > PCIe memory mapped registers can be read via readb(), readw(), readl()
> > > > kernel API's. Similarly what are the kernel API to read the device
> > > > registers via USB bus
> > > 
> > > [...]
> > >
> > > I hope this list stays friendly to newcomers and we will answer
> > > specific questions, but at this point I must advise you to first
> > > read an introductory book.
> > 
> > Along these lines, take a look at the book, Linux Device Drivers, third
> > edition, which is free online, as it has a chapter about USB drivers and
> > how they work.  That should help you out to understand the issues
> > involved with USB devices.
> > 
> I've heard that your book, LDD 3rd edition, has become obsolete a long time 
> ago and most sample code cannot anymore build. Reading what you wrote above 
> seems to contradict what I've been told by others... I must admit that I've 
> just had a print copy of it that I have not yet opened for reading, therefore 
> maybe that I'm totally wrong in assuming the above.

Look into it and see the differences, it's not hard to notice.

And the code samples are all up to date online on github somewhere,
there's people keeping them alive if you want to track them down, but
really, just look at the in-kernel drivers for better examples of real
drivers.

> Do you mind to elaborate a bit more on this subject, please? I mean: can you 
> point out which chapters, which content, should be skipped (if there's really 
> something which is no more correct/relevant to today's practice of drivers  
> development and kernel hacking?

I am not going to create a study guide like this, sorry, I've already
given away the book for free to you :)

> One more question, please... if after carefully studying its content, someone 
> wanted to change and update part of the book content to reflect the changes in 
> Linux API and in the current best practices, would it be (legally) allowed to 
> publish a v4 on GitHub for the convenience of everyone interested in learning 
> for free? However, I understand that it would be not so easy to come up with a 
> good and error free text if not addressed as a public long term project and 
> I'm also not sure of what tools are needed to edit PDF files. (At the moment 
> my question is for a hypothetical scenario, just to know whether or not it 
> would be technically and legally doable). 

Please see the license of the book for what you are, and are not,
allowed to do with it to answer this question.

thanks,

greg k-h

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

* Re: LDD 3rd ed. - It was: Re: read() via USB bus
  2021-08-12 10:18       ` Greg KH
@ 2021-08-12 10:26         ` Robert P. J. Day
  0 siblings, 0 replies; 11+ messages in thread
From: Robert P. J. Day @ 2021-08-12 10:26 UTC (permalink / raw)
  To: Greg KH
  Cc: Fabio M. De Francesco, Muni Sekhar, Oliver Neukum, linux-usb,
	linux-kernel, kernelnewbies

On Thu, 12 Aug 2021, Greg KH wrote:

> On Thu, Aug 12, 2021 at 11:45:45AM +0200, Fabio M. De Francesco wrote:
> > Hi Greg,
> >
> > On Monday, August 9, 2021 10:44:23 AM CEST Greg KH wrote:
> > > On Mon, Aug 09, 2021 at 10:15:29AM +0200, Oliver Neukum wrote:
> > > > On 09.08.21 09:58, Muni Sekhar wrote:
> > > > > Hi all,
> > > > >
> > > > > PCIe memory mapped registers can be read via readb(), readw(), readl()
> > > > > kernel API's. Similarly what are the kernel API to read the device
> > > > > registers via USB bus
> > > >
> > > > [...]
> > > >
> > > > I hope this list stays friendly to newcomers and we will answer
> > > > specific questions, but at this point I must advise you to first
> > > > read an introductory book.
> > >
> > > Along these lines, take a look at the book, Linux Device Drivers, third
> > > edition, which is free online, as it has a chapter about USB drivers and
> > > how they work.  That should help you out to understand the issues
> > > involved with USB devices.
> > >
> > I've heard that your book, LDD 3rd edition, has become obsolete a long time
> > ago and most sample code cannot anymore build. Reading what you wrote above
> > seems to contradict what I've been told by others... I must admit that I've
> > just had a print copy of it that I have not yet opened for reading, therefore
> > maybe that I'm totally wrong in assuming the above.
>
> Look into it and see the differences, it's not hard to notice.
>
> And the code samples are all up to date online on github somewhere,
> there's people keeping them alive if you want to track them down,
> but really, just look at the in-kernel drivers for better examples
> of real drivers.

  it's possibly worth mentioning that a chap named javier martinez has
been doing a decent job of upgrading the examples from LDD3 to keep up
with current kernel development:

  https://github.com/martinezjavier/ldd3

of course, those examples won't match the explanations in the book
anymore, but still, worth perusing.

rday

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

end of thread, other threads:[~2021-08-12 10:54 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-09  7:58 read() via USB bus Muni Sekhar
2021-08-09  8:15 ` Oliver Neukum
2021-08-09  8:44   ` Greg KH
2021-08-12  9:45     ` LDD 3rd ed. - It was: " Fabio M. De Francesco
2021-08-12 10:13       ` Valdis Klētnieks
2021-08-12 10:18       ` Greg KH
2021-08-12 10:26         ` Robert P. J. Day
2021-08-09 16:19   ` Muni Sekhar
2021-08-10 14:13   ` Muni Sekhar
2021-08-10 14:20     ` Oliver Neukum
     [not found]       ` <CAHhAz+ioThu3v4VW6LVqFn9MhgNaqv=qDoxh8Orkw2LOEC_JYA@mail.gmail.com>
2021-08-11 10:04         ` Oliver Neukum

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