Source
x
* transport_sas_phy_reset - reset a phy and permit libata to manage the link
/*
* Serial Attached SCSI (SAS) Transport Layer initialization
*
* Copyright (C) 2005 Adaptec, Inc. All rights reserved.
* Copyright (C) 2005 Luben Tuikov <luben_tuikov@adaptec.com>
*
* This file is licensed under GPLv2.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA
*
*/
static struct kmem_cache *sas_task_cache;
static struct kmem_cache *sas_event_cache;
struct sas_task *sas_alloc_task(gfp_t flags)
{
struct sas_task *task = kmem_cache_zalloc(sas_task_cache, flags);
if (task) {
spin_lock_init(&task->task_state_lock);
task->task_state_flags = SAS_TASK_STATE_PENDING;
}
return task;
}
EXPORT_SYMBOL_GPL(sas_alloc_task);
struct sas_task *sas_alloc_slow_task(gfp_t flags)
{
struct sas_task *task = sas_alloc_task(flags);
struct sas_task_slow *slow = kmalloc(sizeof(*slow), flags);
if (!task || !slow) {
if (task)
kmem_cache_free(sas_task_cache, task);
kfree(slow);
return NULL;
}
task->slow_task = slow;
slow->task = task;
timer_setup(&slow->timer, NULL, 0);
init_completion(&slow->completion);
return task;
}
EXPORT_SYMBOL_GPL(sas_alloc_slow_task);
void sas_free_task(struct sas_task *task)
{
if (task) {
kfree(task->slow_task);
kmem_cache_free(sas_task_cache, task);
}
}
EXPORT_SYMBOL_GPL(sas_free_task);
/*------------ SAS addr hash -----------*/
void sas_hash_addr(u8 *hashed, const u8 *sas_addr)
{
const u32 poly = 0x00DB2777;
u32 r = 0;
int i;