public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Hans de Goede <hdegoede@redhat.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v3 0/1] dm: usb: Copy over usb_device values from usb_scan_device() to final usb_device
Date: Mon, 04 May 2015 21:12:53 +0200	[thread overview]
Message-ID: <5547C4B5.8050406@redhat.com> (raw)
In-Reply-To: <CAPnjgZ3zxLRJ-j2WuyTaSdes2J8BoYyFxSs6zc5fKzeqpMRd=w@mail.gmail.com>

Hi,

On 04-05-15 19:22, Simon Glass wrote:
> Hi Hans,
>
> On 4 May 2015 at 11:19, Hans de Goede <hdegoede@redhat.com> wrote:
>> Hi Simon,
>>
>> Here is v3 of my patch to fix the maxpacketsize0 not being set issue I
>> found and related issues.
>>
>> I've added a big fat comment to explain that the usb_device pointer is a
>> hack and should not be used outside of usb-uclass.c as requested.
>>
>> I hope this version is to your liking and you can ack it.
>>
>> Assuming that you do ack it, then my entire dm-usb fixes + ehci set is
>> all acked, and the question becomes how to take uit upstream, I can take
>> the entire set upstream through the sunxi tree, or you can take it
>> upstream through the dm tree. Let me know which way you prefer to move
>> forward with this.
>
> I should probably take it through DM. I'll do a pull request once the
> x86 pull request goes in.

Ack.

> But I'm still not sure how it is safe to pass a pointer to a local
> stack variable out through another function. Can you please explain
> that?

A function 'a' can safely pass a pointer to an on stack variable to
a function 'b' which it calls, since it is the caller of function 'b',
and as long as code from 'b' is execution we are still within the
lifetime of function 'a' (function 'a' will only end after b has
returned) and as long as execution is within the lifetime of function
'a' any on stack variables of function 'a' are valid.

AFAICT usb_child_pre_probe() gets called from the device_probe()
call inside usb_scan_device() so using a pointer to an on stack
variable of usb_scan_device() is valid since we are still executing
within the lifetime of usb_scan_device().

Hope this helps to follow my reasoning.

Regards,

Hans





>
> Regards,
> Simon
>

  reply	other threads:[~2015-05-04 19:12 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-04 17:19 [U-Boot] [PATCH v3 0/1] dm: usb: Copy over usb_device values from usb_scan_device() to final usb_device Hans de Goede
2015-05-04 17:19 ` [U-Boot] [PATCH v3] " Hans de Goede
2015-05-04 20:28   ` Simon Glass
2015-05-04 21:35     ` Simon Glass
2015-05-04 21:35       ` Simon Glass
2015-05-05  9:49         ` Hans de Goede
2015-05-04 17:22 ` [U-Boot] [PATCH v3 0/1] " Simon Glass
2015-05-04 19:12   ` Hans de Goede [this message]
2015-05-04 19:24     ` Simon Glass

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=5547C4B5.8050406@redhat.com \
    --to=hdegoede@redhat.com \
    --cc=u-boot@lists.denx.de \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox