[PATCH] scsi: lpfc: Switch to using the new API kobj_to_dev()

From: Yang Li
Date: Mon Feb 22 2021 - 02:40:06 EST


fixed the following coccicheck:
./drivers/scsi/lpfc/lpfc_attr.c:4389:6-7: WARNING opportunity for
kobj_to_dev()
./drivers/scsi/lpfc/lpfc_attr.c:6326:60-61: WARNING opportunity for
kobj_to_dev()
./drivers/scsi/lpfc/lpfc_attr.c:6386:60-61: WARNING opportunity for
kobj_to_dev()

Reported-by: Abaci Robot <abaci@xxxxxxxxxxxxxxxxx>
Signed-off-by: Yang Li <yang.lee@xxxxxxxxxxxxxxxxx>
---
drivers/scsi/lpfc/lpfc_attr.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/scsi/lpfc/lpfc_attr.c b/drivers/scsi/lpfc/lpfc_attr.c
index 4528166..a3bde0e 100644
--- a/drivers/scsi/lpfc/lpfc_attr.c
+++ b/drivers/scsi/lpfc/lpfc_attr.c
@@ -4385,8 +4385,7 @@ static DEVICE_ATTR(txcmplq_hw, S_IRUGO,
struct bin_attribute *bin_attr,
char *buf, loff_t off, size_t count)
{
- struct device *dev = container_of(kobj, struct device,
- kobj);
+ struct device *dev = kobj_to_dev(kobj);
struct Scsi_Host *shost = class_to_shost(dev);
struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
struct lpfc_hba *phba = vport->phba;
@@ -6323,7 +6322,7 @@ struct device_attribute *lpfc_vport_attrs[] = {
char *buf, loff_t off, size_t count)
{
size_t buf_off;
- struct device *dev = container_of(kobj, struct device, kobj);
+ struct device *dev = kobj_to_dev(kobj);
struct Scsi_Host *shost = class_to_shost(dev);
struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
struct lpfc_hba *phba = vport->phba;
@@ -6383,7 +6382,7 @@ struct device_attribute *lpfc_vport_attrs[] = {
{
size_t buf_off;
uint32_t * tmp_ptr;
- struct device *dev = container_of(kobj, struct device, kobj);
+ struct device *dev = kobj_to_dev(kobj);
struct Scsi_Host *shost = class_to_shost(dev);
struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
struct lpfc_hba *phba = vport->phba;
--
1.8.3.1