* finding pci_dev from scsi_device
@ 2006-06-26 13:55 Herbert Rosmanith
2006-06-26 14:13 ` Arjan van de Ven
0 siblings, 1 reply; 10+ messages in thread
From: Herbert Rosmanith @ 2006-06-26 13:55 UTC (permalink / raw)
To: linux-kernel; +Cc: Herbert Rosmanith
good day,
Could someone please tell me how to find the corresponding
"struct pci_dev *" from a given "struct scsi_device *"?
I've been searching through structures/header files now for
quite some time, but cannot find anything.
thanks in advance,
h.rosmanith
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: finding pci_dev from scsi_device
2006-06-26 13:55 finding pci_dev from scsi_device Herbert Rosmanith
@ 2006-06-26 14:13 ` Arjan van de Ven
2006-06-26 14:15 ` Herbert Rosmanith
0 siblings, 1 reply; 10+ messages in thread
From: Arjan van de Ven @ 2006-06-26 14:13 UTC (permalink / raw)
To: Herbert Rosmanith; +Cc: linux-kernel
On Mon, 2006-06-26 at 15:55 +0200, Herbert Rosmanith wrote:
> good day,
>
> Could someone please tell me how to find the corresponding
> "struct pci_dev *" from a given "struct scsi_device *"?
>
> I've been searching through structures/header files now for
> quite some time, but cannot find anything.
looking at my isa bus scsi controller... I'd say that that is a really
hard question that doesn't even always have an answer ;)
can you share with us what you want to do with this?
Greetings,
Arjan van de Ven
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: finding pci_dev from scsi_device
2006-06-26 14:13 ` Arjan van de Ven
@ 2006-06-26 14:15 ` Herbert Rosmanith
2006-06-26 14:29 ` Arjan van de Ven
0 siblings, 1 reply; 10+ messages in thread
From: Herbert Rosmanith @ 2006-06-26 14:15 UTC (permalink / raw)
To: Arjan van de Ven; +Cc: linux-kernel
> > Could someone please tell me how to find the corresponding
> > "struct pci_dev *" from a given "struct scsi_device *"?
> >
> > I've been searching through structures/header files now for
> > quite some time, but cannot find anything.
>
> looking at my isa bus scsi controller... I'd say that that is a really
> hard question that doesn't even always have an answer ;)
umh, yes, but in this case, I'm sure I always have a pci_dev.
> can you share with us what you want to do with this?
I need the pci_dev to reconfigure ahci-controllers so that they look like
having been initialised by BIOS at reboot time.
kind regards,
h.rosmanith
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: finding pci_dev from scsi_device
2006-06-26 14:29 ` Arjan van de Ven
@ 2006-06-26 14:24 ` Herbert Rosmanith
2006-06-26 14:41 ` Arjan van de Ven
2006-06-26 14:37 ` Herbert Rosmanith
1 sibling, 1 reply; 10+ messages in thread
From: Herbert Rosmanith @ 2006-06-26 14:24 UTC (permalink / raw)
To: Arjan van de Ven; +Cc: linux-kernel
>
> > > can you share with us what you want to do with this?
> >
> > I need the pci_dev to reconfigure ahci-controllers so that they look like
> > having been initialised by BIOS at reboot time.
>
> isn't it better to do this in the ahci driver itself instead?
guess what I'm doing.
> it for sure will be orders of magnitude easier....
yes?
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: finding pci_dev from scsi_device
2006-06-26 14:15 ` Herbert Rosmanith
@ 2006-06-26 14:29 ` Arjan van de Ven
2006-06-26 14:24 ` Herbert Rosmanith
2006-06-26 14:37 ` Herbert Rosmanith
0 siblings, 2 replies; 10+ messages in thread
From: Arjan van de Ven @ 2006-06-26 14:29 UTC (permalink / raw)
To: Herbert Rosmanith; +Cc: linux-kernel
> > can you share with us what you want to do with this?
>
> I need the pci_dev to reconfigure ahci-controllers so that they look like
> having been initialised by BIOS at reboot time.
isn't it better to do this in the ahci driver itself instead? it for
sure will be orders of magnitude easier....
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: finding pci_dev from scsi_device
2006-06-26 14:29 ` Arjan van de Ven
2006-06-26 14:24 ` Herbert Rosmanith
@ 2006-06-26 14:37 ` Herbert Rosmanith
2006-06-26 14:42 ` Herbert Rosmanith
1 sibling, 1 reply; 10+ messages in thread
From: Herbert Rosmanith @ 2006-06-26 14:37 UTC (permalink / raw)
To: Arjan van de Ven; +Cc: linux-kernel
> isn't it better to do this in the ahci driver itself instead? it for
> sure will be orders of magnitude easier....
drivers/scsi/ahci.c:
// XXX added herp
static int ahci_ioctl(struct scsi_device *scsidev, int cmd, void __user *arg) {
...
For some reason, I have to use an ioctl to reconfigure the controller.
This means that I don't have the "struct pci_dev *pdev" from ahci_init_one
and ahci_remove_one.
I could store a pointer to pci_dev by extending "struct ahci_host_priv",
but before doing this, I'm trying to figure out if there's a "correct"
way of finding a pci_dev from a scsi_device.
>From the scsi_device, I know I can get a "struct ata_port", from there
a "struct Scsi_Host", a "struct ata_host_set" and even a generic
"struct device *".
Now all that's missing is a pointer to "struct pci_dev". Is there a function
to enumerate all "struct device", in that case I could compare
"struct pci_dev -> dev", if the pointers match, I've found it.
kind regards,
h.rosmanith
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: finding pci_dev from scsi_device
2006-06-26 14:24 ` Herbert Rosmanith
@ 2006-06-26 14:41 ` Arjan van de Ven
2006-06-26 14:47 ` Herbert Rosmanith
2006-06-26 14:54 ` Herbert Rosmanith
0 siblings, 2 replies; 10+ messages in thread
From: Arjan van de Ven @ 2006-06-26 14:41 UTC (permalink / raw)
To: Herbert Rosmanith; +Cc: linux-kernel
On Mon, 2006-06-26 at 16:24 +0200, Herbert Rosmanith wrote:
> >
> > > > can you share with us what you want to do with this?
> > >
> > > I need the pci_dev to reconfigure ahci-controllers so that they look like
> > > having been initialised by BIOS at reboot time.
> >
> > isn't it better to do this in the ahci driver itself instead?
>
> guess what I'm doing.
>
> > it for sure will be orders of magnitude easier....
>
> yes?
static int ahci_host_init(struct ata_probe_ent *probe_ent)
{
struct ahci_host_priv *hpriv = probe_ent->private_data;
struct pci_dev *pdev = to_pci_dev(probe_ent->dev);
as you can see, you can easily go from an ata_probe_ent to a pci
device...
also.. you could just put your code into the remove hook... :)
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: finding pci_dev from scsi_device
2006-06-26 14:37 ` Herbert Rosmanith
@ 2006-06-26 14:42 ` Herbert Rosmanith
0 siblings, 0 replies; 10+ messages in thread
From: Herbert Rosmanith @ 2006-06-26 14:42 UTC (permalink / raw)
To: Herbert Rosmanith; +Cc: Arjan van de Ven, linux-kernel
> >From the scsi_device, I know I can get a "struct ata_port", from there
> a "struct Scsi_Host", a "struct ata_host_set" and even a generic
> "struct device *".
Arjan> static int ahci_host_init(struct ata_probe_ent *probe_ent)
Arjan> {
Arjan> struct ahci_host_priv *hpriv = probe_ent->private_data;
Arjan> struct pci_dev *pdev = to_pci_dev(probe_ent->dev);
Arjan>
Arjan> as you can see, you can easily go from an ata_probe_ent to a pci
Arjan> device...
ah! that looks promising. looks like "to_pci_dev" is what I've been
searching.
thanks, I'll try immediately :)
kind regards,
h.rosmanith
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: finding pci_dev from scsi_device
2006-06-26 14:41 ` Arjan van de Ven
@ 2006-06-26 14:47 ` Herbert Rosmanith
2006-06-26 14:54 ` Herbert Rosmanith
1 sibling, 0 replies; 10+ messages in thread
From: Herbert Rosmanith @ 2006-06-26 14:47 UTC (permalink / raw)
To: Arjan van de Ven; +Cc: linux-kernel
>
> also.. you could just put your code into the remove hook... :)
oh by the way, that's the reason why I need to find the pci-pointer myself.
in our environment, the remove hook is never called.
kind regards,
h.rosmanith
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: finding pci_dev from scsi_device
2006-06-26 14:41 ` Arjan van de Ven
2006-06-26 14:47 ` Herbert Rosmanith
@ 2006-06-26 14:54 ` Herbert Rosmanith
1 sibling, 0 replies; 10+ messages in thread
From: Herbert Rosmanith @ 2006-06-26 14:54 UTC (permalink / raw)
To: Arjan van de Ven; +Cc: linux-kernel
> struct pci_dev *pdev = to_pci_dev(probe_ent->dev);
>
> as you can see, you can easily go from an ata_probe_ent to a pci
> device...
just for the sake of completeness:
static int ahci_ioctl(struct scsi_device *scsidev, int cmd, void __user *arg) {
struct pci_dev *pdev;
pdev=to_pci_dev(((struct ata_port *)&scsidev->host->hostdata[0])->host_set->dev);
kind regards,
h.rosmanith
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2006-06-26 15:00 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-06-26 13:55 finding pci_dev from scsi_device Herbert Rosmanith
2006-06-26 14:13 ` Arjan van de Ven
2006-06-26 14:15 ` Herbert Rosmanith
2006-06-26 14:29 ` Arjan van de Ven
2006-06-26 14:24 ` Herbert Rosmanith
2006-06-26 14:41 ` Arjan van de Ven
2006-06-26 14:47 ` Herbert Rosmanith
2006-06-26 14:54 ` Herbert Rosmanith
2006-06-26 14:37 ` Herbert Rosmanith
2006-06-26 14:42 ` Herbert Rosmanith
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®