All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Kiszka <jan.kiszka@domain.hid>
To: Johan Borkhuis <j.borkhuis@domain.hid>
Cc: Xenomai-help@domain.hid
Subject: Re: [Xenomai-help] Passing data from device init to open function
Date: Thu, 11 Oct 2007 15:51:43 +0200	[thread overview]
Message-ID: <470E2A6F.2020406@domain.hid> (raw)
In-Reply-To: <470DCFD2.1000908@domain.hid>

Johan Borkhuis wrote:
> This is something I try to avoid (replying to my own messages), but I'll
> do it this time.
> 
> Johan Borkhuis wrote:
>> Hello,
>>
>> I am facing the following problem. During device initialization I am
>> filling a structure with device specific data. This structure is
>> provided to the Linux driver using pci_set_drvdata. Now I want my
>> Xenomai driver to have access to this data as well.
>>   
> 
> I made a fix for the problem I described, but I would also like to
> propose a change to the rtdm_device structure.
> 
> What I did to solve this problem is add the following statement to my
> device initialization function (the PCI probe function) after the
> pci_set_drvdata:
> 
>    MyDevice *unit;
>    ....
>    pci_set_drvdata(dev, unit);
>    my_rtdm_device.device_id = (int)dev;
> 
> In my ops-functions I can now use the following statement to access the
> device data:
> 
> int myrtdm_open_nrt(struct rtdm_dev_context    *context,
>                 rtdm_user_info_t              *user_info,
>                 int                            oflags)
> {
>    MyDevice *unit = pci_get_drvdata((struct pci_dev
> *)context->device->device_id);
> 
> This does work, but only as long as sizeof(int) == sizeof(<pointer>),
> which is true on 32 bit systems, but not on 64 bit systems. So I would
> like to add an extra pointer field to the rtdm_device structure,
> pointing to some device-data to allow this to work on both 32 and 64 bit
> systems.
> 
> I attached a diff-file containing a patch to rtdm_driver.h that makes
> this change.

Hmm, that's what we had in an early RTDM version, but the more common
use-case turned out to be

per_device_data = my_per_device_data[device->device_id];

where my_per_device_data is a global variable, typical a data structure
containing all the required per-device information.

Anyway, as you are adding this field, not replacing the ID with it, I
think I'm going to merge this.

Thanks,
Jan

-- 
Siemens AG, Corporate Technology, CT SE 2
Corporate Competence Center Embedded Linux


  reply	other threads:[~2007-10-11 13:51 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-10 11:37 [Xenomai-help] Passing data from device init to open function Johan Borkhuis
2007-10-11  7:25 ` Johan Borkhuis
2007-10-11 13:51   ` Jan Kiszka [this message]
2007-10-12  7:38     ` Johan Borkhuis

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=470E2A6F.2020406@domain.hid \
    --to=jan.kiszka@domain.hid \
    --cc=Xenomai-help@domain.hid \
    --cc=j.borkhuis@domain.hid \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.