0001-scsi-hpsa-Add-function-to-check-if-device-is-a-disk-.patch

Signed-off-by: AuxXxilium <info@auxxxilium.tech>
This commit is contained in:
AuxXxilium 2024-08-19 18:13:14 +02:00
parent 79145d760a
commit 2c7e8079c2

View File

@ -793,6 +793,11 @@ static ssize_t sas_address_show(struct device *dev,
return snprintf(buf, PAGE_SIZE, "0x%016llx\n", sas_address); return snprintf(buf, PAGE_SIZE, "0x%016llx\n", sas_address);
} }
static inline bool is_disk_or_zbc(const struct hpsa_scsi_dev_t *hdev)
{
return hdev->devtype == TYPE_DISK || hdev->devtype == TYPE_ZBC;
}
static ssize_t host_show_hp_ssd_smart_path_enabled(struct device *dev, static ssize_t host_show_hp_ssd_smart_path_enabled(struct device *dev,
struct device_attribute *attr, char *buf) struct device_attribute *attr, char *buf)
{ {
@ -813,7 +818,7 @@ static ssize_t host_show_hp_ssd_smart_path_enabled(struct device *dev,
offload_enabled = hdev->offload_enabled; offload_enabled = hdev->offload_enabled;
spin_unlock_irqrestore(&h->lock, flags); spin_unlock_irqrestore(&h->lock, flags);
if (hdev->devtype == TYPE_DISK || hdev->devtype == TYPE_ZBC) if (is_disk_or_zbc(hdev))
return snprintf(buf, 20, "%d\n", offload_enabled); return snprintf(buf, 20, "%d\n", offload_enabled);
else else
return snprintf(buf, 40, "%s\n", return snprintf(buf, 40, "%s\n",
@ -880,8 +885,7 @@ static ssize_t path_info_show(struct device *dev,
PAGE_SIZE - output_len, PAGE_SIZE - output_len,
"PORT: %.2s ", "PORT: %.2s ",
phys_connector); phys_connector);
if ((hdev->devtype == TYPE_DISK || hdev->devtype == TYPE_ZBC) && if (is_disk_or_zbc(hdev) && hdev->expose_device) {
hdev->expose_device) {
if (box == 0 || box == 0xFF) { if (box == 0 || box == 0xFF) {
output_len += scnprintf(buf + output_len, output_len += scnprintf(buf + output_len,
PAGE_SIZE - output_len, PAGE_SIZE - output_len,
@ -1738,8 +1742,7 @@ static void hpsa_figure_phys_disk_ptrs(struct ctlr_info *h,
for (j = 0; j < ndevices; j++) { for (j = 0; j < ndevices; j++) {
if (dev[j] == NULL) if (dev[j] == NULL)
continue; continue;
if (dev[j]->devtype != TYPE_DISK && if (!is_disk_or_zbc(dev[j]))
dev[j]->devtype != TYPE_ZBC)
continue; continue;
if (is_logical_device(dev[j])) if (is_logical_device(dev[j]))
continue; continue;
@ -1792,8 +1795,7 @@ static void hpsa_update_log_drive_phys_drive_ptrs(struct ctlr_info *h,
for (i = 0; i < ndevices; i++) { for (i = 0; i < ndevices; i++) {
if (dev[i] == NULL) if (dev[i] == NULL)
continue; continue;
if (dev[i]->devtype != TYPE_DISK && if (!is_disk_or_zbc(dev[i]))
dev[i]->devtype != TYPE_ZBC)
continue; continue;
if (!is_logical_device(dev[i])) if (!is_logical_device(dev[i]))
continue; continue;
@ -4009,8 +4011,7 @@ static int hpsa_update_device_info(struct ctlr_info *h,
goto bail_out; goto bail_out;
} }
if ((this_device->devtype == TYPE_DISK || if (is_disk_or_zbc(this_device) &&
this_device->devtype == TYPE_ZBC) &&
is_logical_dev_addr_mode(scsi3addr)) { is_logical_dev_addr_mode(scsi3addr)) {
unsigned char volume_offline; unsigned char volume_offline;