Source
/*
* driver for Microsemi PQI-based storage controllers
* Copyright (c) 2016-2017 Microsemi Corporation
* Copyright (c) 2016 PMC-Sierra, Inc.
*
* 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; version 2 of the License.
*
* 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, GOOD TITLE or
* NON INFRINGEMENT. See the GNU General Public License for more details.
*
* Questions/Comments/Bugfixes to esc.storagedev@microsemi.com
*
*/
static struct pqi_sas_phy *pqi_alloc_sas_phy(struct pqi_sas_port *pqi_sas_port)
{
struct pqi_sas_phy *pqi_sas_phy;
struct sas_phy *phy;
pqi_sas_phy = kzalloc(sizeof(*pqi_sas_phy), GFP_KERNEL);
if (!pqi_sas_phy)
return NULL;
phy = sas_phy_alloc(pqi_sas_port->parent_node->parent_dev,
pqi_sas_port->next_phy_index);
if (!phy) {
kfree(pqi_sas_phy);
return NULL;
}
pqi_sas_port->next_phy_index++;
pqi_sas_phy->phy = phy;
pqi_sas_phy->parent_port = pqi_sas_port;
return pqi_sas_phy;
}
static void pqi_free_sas_phy(struct pqi_sas_phy *pqi_sas_phy)
{
struct sas_phy *phy = pqi_sas_phy->phy;
sas_port_delete_phy(pqi_sas_phy->parent_port->port, phy);
sas_phy_free(phy);
if (pqi_sas_phy->added_to_port)
list_del(&pqi_sas_phy->phy_list_entry);
kfree(pqi_sas_phy);
}
static int pqi_sas_port_add_phy(struct pqi_sas_phy *pqi_sas_phy)
{
int rc;