當 resume 時, 重新 probe。
結果.. 有些跳過順序: # first boot -- 0.1.2.3 # suspend and resume -- 0.1.3.4 跳過 2
發現 disconect 時,call usb_serial_put( ),
void usb_serial_put(struct usb_serial *serial)
{
kref_put(&serial->kref, destroy_serial);
}
call 的就是 kref_put( ):
/**
* kref_put - decrement refcount for object.
* @kref: object.
* @release: pointer to the function that will clean up the object when the
* last reference to the object is released.
* This pointer is required, and it is not acceptable to pass kfree
* in as this function.
*
* Decrement the refcount, and if 0, call release().
* Return 1 if the object was removed, otherwise return 0. Beware, if this
* function returns 0, you still can not count on the kref from remaining in
* memory. Only use the return value if you want to see if the kref is now
* gone, not present.
*/
int kref_put(struct kref *kref, void (*release)(struct kref *kref))
{
WARN_ON(release == NULL);
WARN_ON(release == (void (*)(struct kref *))kfree);
if (atomic_dec_and_test(&kref->refcount)) {
release(kref);
return 1;
}
return 0;
}
也就是 decrease refcount, 如果是 0, 就 call 傳進來的 function : release()
參考 kref_get( ) , 在 usb-serial port 有人 open 時,就會呼叫。
也就是說,一定要所有 open 的人都 close 了, refcount 才會是 0
沒有留言:
張貼留言