* Optimization: keeping pointer all the time, or defining getter?
@ 2011-05-11 16:22 Rafał Miłecki
2011-05-11 16:27 ` Michael Büsch
0 siblings, 1 reply; 4+ messages in thread
From: Rafał Miłecki @ 2011-05-11 16:22 UTC (permalink / raw)
To: b43-dev, linux-wireless
I try to abstract bus in b43 driver. For frequently used fields
solution is obvious:
At init time I get info from bus-specific stuct and put it in generic field.
Example: core revision. We often refer to it, I put it in abstraction struct.
My question: what is the policy for cases with less frequently used fields?
Example: I need to use "struct device" for registering some low lever stuff.
I have two solutions:
1) Realtime:
struct device *get_device(...)
{
if (dev->bus_type = B43_BUS_SSB)
return dev->ssbdev->device;
else if (dev->bus_type = B43_BUS_BCMA)
return dev->bcmadev->device;
}
2) Init time:
void b43_ssb_init(struct ssb_device *ssbdev)
{
dev->struct = ssbdev->device;
}
The first one is slower but we don't keep "struct device" pointer in
abstraction struct. Situation is opposite for the second one.
Does anyone care? ;)
--
Rafał
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Optimization: keeping pointer all the time, or defining getter?
2011-05-11 16:22 Optimization: keeping pointer all the time, or defining getter? Rafał Miłecki
@ 2011-05-11 16:27 ` Michael Büsch
2011-05-11 16:34 ` Rafał Miłecki
0 siblings, 1 reply; 4+ messages in thread
From: Michael Büsch @ 2011-05-11 16:27 UTC (permalink / raw)
To: Rafał Miłecki; +Cc: b43-dev, linux-wireless
On Wed, 2011-05-11 at 18:22 +0200, Rafał Miłecki wrote:
> I try to abstract bus in b43 driver. For frequently used fields
> solution is obvious:
> At init time I get info from bus-specific stuct and put it in generic field.
> Example: core revision. We often refer to it, I put it in abstraction struct.
>
> My question: what is the policy for cases with less frequently used fields?
> Example: I need to use "struct device" for registering some low lever stuff.
>
> I have two solutions:
>
> 1) Realtime:
> struct device *get_device(...)
> {
> if (dev->bus_type = B43_BUS_SSB)
> return dev->ssbdev->device;
> else if (dev->bus_type = B43_BUS_BCMA)
> return dev->bcmadev->device;
> }
>
> 2) Init time:
> void b43_ssb_init(struct ssb_device *ssbdev)
> {
> dev->struct = ssbdev->device;
> }
>
> The first one is slower but we don't keep "struct device" pointer in
> abstraction struct. Situation is opposite for the second one.
>
> Does anyone care? ;)
Put a struct device pointer into b43_wldev.
The pointer is needed on every DMA transaction several times, so this
seems worth it.
--
Greetings Michael.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Optimization: keeping pointer all the time, or defining getter?
2011-05-11 16:27 ` Michael Büsch
@ 2011-05-11 16:34 ` Rafał Miłecki
2011-05-11 16:43 ` Michael Büsch
0 siblings, 1 reply; 4+ messages in thread
From: Rafał Miłecki @ 2011-05-11 16:34 UTC (permalink / raw)
To: Michael Büsch; +Cc: b43-dev, linux-wireless
W dniu 11 maja 2011 18:27 użytkownik Michael Büsch <m@bues.ch> napisał:
> On Wed, 2011-05-11 at 18:22 +0200, Rafał Miłecki wrote:
>> I try to abstract bus in b43 driver. For frequently used fields
>> solution is obvious:
>> At init time I get info from bus-specific stuct and put it in generic field.
>> Example: core revision. We often refer to it, I put it in abstraction struct.
>>
>> My question: what is the policy for cases with less frequently used fields?
>> Example: I need to use "struct device" for registering some low lever stuff.
>>
>> I have two solutions:
>>
>> 1) Realtime:
>> struct device *get_device(...)
>> {
>> if (dev->bus_type = B43_BUS_SSB)
>> return dev->ssbdev->device;
>> else if (dev->bus_type = B43_BUS_BCMA)
>> return dev->bcmadev->device;
>> }
>>
>> 2) Init time:
>> void b43_ssb_init(struct ssb_device *ssbdev)
>> {
>> dev->struct = ssbdev->device;
>> }
>>
>> The first one is slower but we don't keep "struct device" pointer in
>> abstraction struct. Situation is opposite for the second one.
>>
>> Does anyone care? ;)
>
> Put a struct device pointer into b43_wldev.
> The pointer is needed on every DMA transaction several times, so this
> seems worth it.
Oops, OK, that was example. I thought DMA uses "dma_dev" frequently, not "dev".
But if we assume there is some not frequently used struct. What
solution should be used then?
--
Rafał
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Optimization: keeping pointer all the time, or defining getter?
2011-05-11 16:34 ` Rafał Miłecki
@ 2011-05-11 16:43 ` Michael Büsch
0 siblings, 0 replies; 4+ messages in thread
From: Michael Büsch @ 2011-05-11 16:43 UTC (permalink / raw)
To: Rafał Miłecki; +Cc: b43-dev, linux-wireless
On Wed, 2011-05-11 at 18:34 +0200, Rafał Miłecki wrote:
> W dniu 11 maja 2011 18:27 użytkownik Michael Büsch <m@bues.ch> napisał:
> > On Wed, 2011-05-11 at 18:22 +0200, Rafał Miłecki wrote:
> >> I try to abstract bus in b43 driver. For frequently used fields
> >> solution is obvious:
> >> At init time I get info from bus-specific stuct and put it in generic field.
> >> Example: core revision. We often refer to it, I put it in abstraction struct.
> >>
> >> My question: what is the policy for cases with less frequently used fields?
> >> Example: I need to use "struct device" for registering some low lever stuff.
> >>
> >> I have two solutions:
> >>
> >> 1) Realtime:
> >> struct device *get_device(...)
> >> {
> >> if (dev->bus_type = B43_BUS_SSB)
> >> return dev->ssbdev->device;
> >> else if (dev->bus_type = B43_BUS_BCMA)
> >> return dev->bcmadev->device;
> >> }
> >>
> >> 2) Init time:
> >> void b43_ssb_init(struct ssb_device *ssbdev)
> >> {
> >> dev->struct = ssbdev->device;
> >> }
> >>
> >> The first one is slower but we don't keep "struct device" pointer in
> >> abstraction struct. Situation is opposite for the second one.
> >>
> >> Does anyone care? ;)
> >
> > Put a struct device pointer into b43_wldev.
> > The pointer is needed on every DMA transaction several times, so this
> > seems worth it.
>
> Oops, OK, that was example. I thought DMA uses "dma_dev" frequently, not "dev".
Ah well. I don't know. Isn't dma_dev part of some SSB struct?
> But if we assume there is some not frequently used struct. What
> solution should be used then?
Apply common sense. ;)
--
Greetings Michael.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2011-05-11 16:43 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-05-11 16:22 Optimization: keeping pointer all the time, or defining getter? Rafał Miłecki
2011-05-11 16:27 ` Michael Büsch
2011-05-11 16:34 ` Rafał Miłecki
2011-05-11 16:43 ` Michael Büsch
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).