mirror of
https://github.com/SCST-project/scst.git
synced 2026-05-21 12:41:26 +00:00
scst/include/backport.h: Add a kref_read() backport
This patch does not change any functionality. git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@7178 d57e44dd-8a1f-0410-8b47-8ef2f437770f
This commit is contained in:
@@ -482,11 +482,7 @@ static void ft_sess_free(struct kref *kref)
|
||||
static void ft_sess_put(struct ft_sess *sess)
|
||||
{
|
||||
BUG_ON(!sess);
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)
|
||||
BUG_ON(kref_read(&sess->kref) <= 0);
|
||||
#else
|
||||
BUG_ON(atomic_read(&sess->kref.refcount) <= 0);
|
||||
#endif
|
||||
kref_put(&sess->kref, ft_sess_free);
|
||||
}
|
||||
|
||||
|
||||
@@ -1402,11 +1402,7 @@ static void isert_kref_free(struct kref *kref)
|
||||
|
||||
void isert_conn_free(struct isert_connection *isert_conn)
|
||||
{
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)
|
||||
sBUG_ON(kref_read(&isert_conn->kref) == 0);
|
||||
#else
|
||||
sBUG_ON(atomic_read(&isert_conn->kref.refcount) == 0);
|
||||
#endif
|
||||
kref_put(&isert_conn->kref, isert_kref_free);
|
||||
}
|
||||
|
||||
|
||||
@@ -113,11 +113,7 @@ static void isert_kref_release_dev(struct kref *kref)
|
||||
|
||||
static void isert_dev_release(struct isert_conn_dev *dev)
|
||||
{
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)
|
||||
sBUG_ON(kref_read(&dev->kref) == 0);
|
||||
#else
|
||||
sBUG_ON(atomic_read(&dev->kref.refcount) == 0);
|
||||
#endif
|
||||
mutex_lock(&isert_listen_dev.conn_lock);
|
||||
kref_put(&dev->kref, isert_kref_release_dev);
|
||||
mutex_unlock(&isert_listen_dev.conn_lock);
|
||||
|
||||
@@ -361,6 +361,11 @@ static inline int __must_check kref_get_unless_zero(struct kref *kref)
|
||||
}
|
||||
#endif
|
||||
|
||||
/* See also commit 2c935bc57221 */
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 11, 0)
|
||||
#define kref_read(kref) (atomic_read(&(kref)->refcount))
|
||||
#endif
|
||||
|
||||
/* <linux/kthread.h> */
|
||||
|
||||
/* See also commit 207205a2ba26 */
|
||||
|
||||
@@ -1203,13 +1203,7 @@ void scst_kobject_put_and_wait(struct kobject *kobj, const char *category,
|
||||
goto out_free;
|
||||
|
||||
PRINT_INFO("Waiting for release of sysfs entry for %s %s (%d refs)",
|
||||
category, name ? : "(?)",
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)
|
||||
kref_read(&kobj->kref)
|
||||
#else
|
||||
atomic_read(&kobj->kref.refcount)
|
||||
#endif
|
||||
);
|
||||
category, name ? : "(?)", kref_read(&kobj->kref));
|
||||
wait_for_completion(c);
|
||||
PRINT_INFO("Finished waiting for release of %s %s sysfs entry",
|
||||
category, name ? : "(?)");
|
||||
|
||||
Reference in New Issue
Block a user