libsas cleanups
Subsystems (2)
v4 cover libsas cleanups
Martin, John,
While debugging an issue with the pm8001 driver, I generated these cleanup patches. No functional changes overall.
These patches are against the 6.17/scsi-staging branch of the scsi tree.
Changes from v3:
- Corrected commit message of patch 2
- Added review tags
Changes from v2:
- Modified patch 2 to remove the unnecessary check using dev_is_ata()
- Added review tags
Changes from v1:
- Added patch 1
- Modified patch 2 to not inline sas_ata_wait_eh()
- Added review tags
Damien Le Moal (5):
scsi: libsas: Refactor dev_is_sata()
scsi: libsas: Simplify sas_ata_wait_eh()
scsi: libsas: Make sas_get_ata_info() static
scsi: libsas: Move declarations of internal functions to sas_internal.h
scsi: libsas: Use a bool for sas_deform_port() second argument
drivers/scsi/libsas/sas_ata.c | 10 +--- drivers/scsi/libsas/sas_discover.c | 2 +- drivers/scsi/libsas/sas_internal.h | 78 ++++++++++++++++++++++++- drivers/scsi/libsas/sas_phy.c | 6 +- drivers/scsi/libsas/sas_port.c | 13 ++--- include/scsi/sas_ata.h | 91 +++++------------------------- 6 files changed, 101 insertions(+), 99 deletions(-)
base-commit: 3ea3a256ed81f95ab0f3281a0e234b01a9cae605
Signature · 1 line
2.50.1
PATCH v4 1/5 scsi: libsas: Refactor dev_is_sata()
Use a switch statement in dev_is_sata() to make the code more readable (and probably slightly better than a series of or conditions). Also have this inline function return a boolean instead of an integer.
No functional changes.
--- include/scsi/sas_ata.h | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-)
include/scsi/sas_ata.h +12 -5
@@ -15,10 +15,17 @@#ifdef CONFIG_SCSI_SAS_ATA -static inline int dev_is_sata (struct domain_device *dev) +static inline bool dev_is_sata (struct domain_device *dev) { -return dev->dev_type ==SAS_SATA_DEV || dev->dev_type ==SAS_SATA_PM || - dev->dev_type ==SAS_SATA_PM_PORT || dev->dev_type ==SAS_SATA_PENDING ; +switch (dev->dev_type) { +case SAS_SATA_DEV : +case SAS_SATA_PENDING : +case SAS_SATA_PM : +case SAS_SATA_PM_PORT : +return true; +default : +return false; + } }int sas_get_ata_info (struct domain_device *dev,struct ex_phy *phy);
@@ -49,9 +56,9 @@ static inline void sas_ata_disabled_notice(void)pr_notice_once ("ATA device seen but CONFIG_SCSI_SAS_ATA=N\n" ); } -static inline int dev_is_sata (struct domain_device *dev) +static inline bool dev_is_sata (struct domain_device *dev) { -return 0 ; +return false; }static inline int sas_ata_init (struct domain_device *dev) {
Signature · 1 line
2.50.1
Re: [PATCH v4 1/5] scsi: libsas: Refactor dev_is_sata()
Quoted 11 lines · Damien Le Moal
Use a switch statement in
dev_is_sata()to make the code more readable (and probably slightly better than a series of or conditions). Also have this inline function return a boolean instead of an integer.No functional changes.
Signed-off-by Damien Le Moal<[email protected]>Reviewed-by John Garry<[email protected]>--- include/scsi/sas_ata.h | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-)
PATCH v4 2/5 scsi: libsas: Simplify sas_ata_wait_eh()
In reply to Damien Le MoalSimplify the code of sas_ata_wait_eh(), removing the local variable ap for the pointer to the device ata_port structure. The test using dev_is_sata() is also removed as all call sites of this function check if the device is a SATA one before calling this function.
--- drivers/scsi/libsas/sas_ata.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)
drivers/scsi/libsas/sas_ata.c +1 -7
@@ -927,13 +927,7 @@ EXPORT_SYMBOL_GPL(sas_ata_schedule_reset);void sas_ata_wait_eh (struct domain_device *dev) { -struct ata_port *ap; - -if (!dev_is_sata (dev)) -return ; - - ap = dev->sata_dev.ap; -ata_port_wait_eh (ap); +ata_port_wait_eh (dev->sata_dev.ap); }void sas_ata_device_link_abort (struct domain_device *device,bool force_reset)
Signature · 1 line
2.50.1
Re: [PATCH v4 2/5] scsi: libsas: Simplify sas_ata_wait_eh()
Quoted 10 lines · Damien Le Moal
Simplify the code of
sas_ata_wait_eh(), removing the local variable ap for the pointer to the deviceata_portstructure. The test usingdev_is_sata()is also removed as all call sites of this function check if the device is a SATA one before calling this function.Signed-off-by Damien Le Moal<[email protected]>Reviewed-by John Garry<[email protected]>--- drivers/scsi/libsas/sas_ata.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)
PATCH v4 3/5 scsi: libsas: Make sas_get_ata_info() static
In reply to Damien Le MoalThe function sas_get_ata_info() is used only in drivers/scsi/libsas/sas_ata.c. Remove its definition from include/scsi/sas_ata.h and make this function static.
No functional changes.
--- drivers/scsi/libsas/sas_ata.c | 2 +- include/scsi/sas_ata.h | 6 ------ 2 files changed, 1 insertion(+), 7 deletions(-)
drivers/scsi/libsas/sas_ata.c +1 -1
@@ -252,7 +252,7 @@ static int sas_get_ata_command_set(struct domain_device *dev)return ata_dev_classify (&tf); } -int sas_get_ata_info (struct domain_device *dev,struct ex_phy *phy) +static int sas_get_ata_info (struct domain_device *dev,struct ex_phy *phy) {if (phy->attached_tproto &SAS_PROTOCOL_STP ) dev->tproto = phy->attached_tproto;
include/scsi/sas_ata.h +0 -6
@@ -28,7 +28,6 @@ static inline bool dev_is_sata(struct domain_device *dev) } } -int sas_get_ata_info (struct domain_device *dev,struct ex_phy *phy);int sas_ata_init (struct domain_device *dev);void sas_ata_task_abort (struct sas_task *task);void sas_ata_strategy_handler (struct Scsi_Host *shost);
@@ -96,11 +95,6 @@ static inline void sas_resume_sata(struct asd_sas_port *port) { } -static inline int sas_get_ata_info (struct domain_device *dev,struct ex_phy *phy) -{ -return 0 ; -} -static inline void sas_ata_end_eh (struct ata_port *ap) { }
Signature · 1 line
2.50.1
Re: [PATCH v4 3/5] scsi: libsas: Make sas_get_ata_info() static
Quoted 6 lines · Damien Le Moal
The function
sas_get_ata_info()is used only indrivers/scsi/libsas/sas_ata.c. Remove its definition frominclude/scsi/sas_ata.hand make this function static.No functional changes.
Quoted 7 lines
Signed-off-by Damien Le Moal<[email protected]>Reviewed-by Johannes Thumshirn<[email protected]>Reviewed-by John Garry<[email protected]>--- drivers/scsi/libsas/sas_ata.c | 2 +- include/scsi/sas_ata.h | 6 ------ 2 files changed, 1 insertion(+), 7 deletions(-)
PATCH v4 4/5 scsi: libsas: Move declarations of internal functions to sas_internal.h
In reply to Damien Le MoalMove the declaration of all functions used only within libsas from include/scsi/sas_ata.h to drivers/scsi/libsas/sas_internal.h.
No functional changes.
--- drivers/scsi/libsas/sas_internal.h | 74 ++++++++++++++++++++++++++++++ include/scsi/sas_ata.h | 68 +-------------------------- 2 files changed, 75 insertions(+), 67 deletions(-)
drivers/scsi/libsas/sas_internal.h +74 -0
@@ -222,4 +222,78 @@ static inline void sas_put_device(struct domain_device *dev)kref_put (&dev->kref, sas_free_device); } +#ifdef CONFIG_SCSI_SAS_ATA + +int sas_ata_init (struct domain_device *dev); +void sas_ata_task_abort (struct sas_task *task); +int sas_discover_sata (struct domain_device *dev); +int sas_ata_add_dev (struct domain_device *parent,struct ex_phy *phy, +struct domain_device *child,int phy_id); +void sas_ata_strategy_handler (struct Scsi_Host *shost); +void sas_ata_eh (struct Scsi_Host *shost,struct list_head *work_q); +void sas_ata_end_eh (struct ata_port *ap); +void sas_ata_wait_eh (struct domain_device *dev); +void sas_probe_sata (struct asd_sas_port *port); +void sas_suspend_sata (struct asd_sas_port *port); +void sas_resume_sata (struct asd_sas_port *port); + +#else + +static inline int sas_ata_init (struct domain_device *dev) +{ +return 0 ; +} + +static inline void sas_ata_task_abort (struct sas_task *task) +{ +} + +static inline void sas_ata_strategy_handler (struct Scsi_Host *shost) +{ +} + +static inline void sas_ata_eh (struct Scsi_Host *shost,struct list_head *work_q) +{ +} + +static inline void sas_ata_end_eh (struct ata_port *ap) +{ +} + +static inline void sas_ata_wait_eh (struct domain_device *dev) +{ +} + +static inline void sas_probe_sata (struct asd_sas_port *port) +{ +} + +static inline void sas_suspend_sata (struct asd_sas_port *port) +{ +} + +static inline void sas_resume_sata (struct asd_sas_port *port) +{ +} + +static inline void sas_ata_disabled_notice (void ) +{ +pr_notice_once ("ATA device seen but CONFIG_SCSI_SAS_ATA=N\n" ); +} + +static inline int sas_discover_sata (struct domain_device *dev) +{ +sas_ata_disabled_notice (); +return -ENXIO ; +} + +static inline int sas_ata_add_dev (struct domain_device *parent,struct ex_phy *phy, +struct domain_device *child,int phy_id) +{ +sas_ata_disabled_notice (); +return -ENODEV ; +} + +#endif +#endif /* _SAS_INTERNAL_H_ */
include/scsi/sas_ata.h +1 -67
97 lines not on this page · raw message
Signature · 1 line
2.50.1
Re: [PATCH v4 4/5] scsi: libsas: Move declarations of internal functions to sas_internal.h
Quoted 5 lines · Damien Le Moal
Move the declaration of all functions used only within libsas from
include/scsi/sas_ata.htodrivers/scsi/libsas/sas_internal.h.No functional changes.
Quoted 7 lines
Signed-off-by Damien Le Moal<[email protected]>Reviewed-by Johannes Thumshirn<[email protected]>Reviewed-by John Garry<[email protected]>--- drivers/scsi/libsas/sas_internal.h | 74 ++++++++++++++++++++++++++++++ include/scsi/sas_ata.h | 68 +-------------------------- 2 files changed, 75 insertions(+), 67 deletions(-)
PATCH v4 5/5 scsi: libsas: Use a bool for sas_deform_port() second argument
In reply to Damien Le MoalChange the type of the "gone" argument of sas_deform_port() from int to bool. Simliarly, to be consistent, do the same change to the function sas_unregister_domain_devices().
No functional changes.
--- drivers/scsi/libsas/sas_discover.c | 2 +- drivers/scsi/libsas/sas_internal.h | 4 ++-- drivers/scsi/libsas/sas_phy.c | 6 +++--- drivers/scsi/libsas/sas_port.c | 13 ++++++------- 4 files changed, 12 insertions(+), 13 deletions(-)
drivers/scsi/libsas/sas_discover.c +1 -1
@@ -406,7 +406,7 @@ void sas_unregister_dev(struct asd_sas_port *port, struct domain_device *dev) } } -void sas_unregister_domain_devices (struct asd_sas_port *port,int gone) +void sas_unregister_domain_devices (struct asd_sas_port *port,bool gone) {struct domain_device *dev, *n;
drivers/scsi/libsas/sas_internal.h +2 -2
@@ -44,7 +44,7 @@ void sas_hash_addr(u8 *hashed, const u8 *sas_addr);int sas_discover_root_expander (struct domain_device *dev);int sas_ex_revalidate_domain (struct domain_device *dev); -void sas_unregister_domain_devices (struct asd_sas_port *port,int gone); +void sas_unregister_domain_devices (struct asd_sas_port *port,bool gone);void sas_init_disc (struct sas_discovery *disc,struct asd_sas_port *port);void sas_discover_event (struct asd_sas_port *port,enum discover_event ev);
@@ -70,7 +70,7 @@ void sas_enable_revalidation(struct sas_ha_struct *ha);void sas_queue_deferred_work (struct sas_ha_struct *ha);void __sas_drain_work (struct sas_ha_struct *ha); -void sas_deform_port (struct asd_sas_phy *phy,int gone); +void sas_deform_port (struct asd_sas_phy *phy,bool gone);void sas_porte_bytes_dmaed (struct work_struct *work);void sas_porte_broadcast_rcvd (struct work_struct *work);
drivers/scsi/libsas/sas_phy.c +3 -3
@@ -20,7 +20,7 @@ static void sas_phye_loss_of_signal(struct work_struct *work)struct asd_sas_phy *phy = ev->phy; phy->error =0 ; -sas_deform_port (phy,1 ); +sas_deform_port (phy, true); }static void sas_phye_oob_done (struct work_struct *work)
@@ -40,7 +40,7 @@ static void sas_phye_oob_error(struct work_struct *work)struct sas_internal *i =to_sas_internal (sas_ha->shost->transportt); -sas_deform_port (phy,1 ); +sas_deform_port (phy, true);if (!port && phy->enabled && i->dft->lldd_control_phy) { phy->error++;
@@ -85,7 +85,7 @@ static void sas_phye_resume_timeout(struct work_struct *work) phy->error =0 ; phy->suspended =0 ; -sas_deform_port (phy,1 ); +sas_deform_port (phy, true); }
drivers/scsi/libsas/sas_port.c +6 -7
@@ -113,7 +113,7 @@ static void sas_form_port(struct asd_sas_phy *phy)if (port) {if (!phy_is_wideport_member (port, phy)) -sas_deform_port (phy,0 ); +sas_deform_port (phy, false);else if (phy->suspended) { phy->suspended =0 ;sas_resume_port (phy);
@@ -206,7 +206,7 @@ static void sas_form_port(struct asd_sas_phy *phy)* This is called when the physical link to the other phy has been * lost (on this phy), in Event thread context. We cannot delay here. */ -void sas_deform_port (struct asd_sas_phy *phy,int gone) +void sas_deform_port (struct asd_sas_phy *phy,bool gone) {struct sas_ha_struct *sas_ha = phy->ha;struct asd_sas_port *port = phy->port;
@@ -301,7 +301,7 @@ void sas_porte_link_reset_err(struct work_struct *work)struct asd_sas_event *ev =to_asd_sas_event (work);struct asd_sas_phy *phy = ev->phy; -sas_deform_port (phy,1 ); +sas_deform_port (phy, true); }void sas_porte_timer_event (struct work_struct *work)
@@ -309,7 +309,7 @@ void sas_porte_timer_event(struct work_struct *work)struct asd_sas_event *ev =to_asd_sas_event (work);struct asd_sas_phy *phy = ev->phy; -sas_deform_port (phy,1 ); +sas_deform_port (phy, true); }void sas_porte_hard_reset (struct work_struct *work)
@@ -317,7 +317,7 @@ void sas_porte_hard_reset(struct work_struct *work)struct asd_sas_event *ev =to_asd_sas_event (work);struct asd_sas_phy *phy = ev->phy; -sas_deform_port (phy,1 ); +sas_deform_port (phy, true); }/* ---------- SAS port registration ---------- */
@@ -358,8 +358,7 @@ void sas_unregister_ports(struct sas_ha_struct *sas_ha)for (i =0 ; i < sas_ha->num_phys; i++)if (sas_ha->sas_phy[i]->port) -sas_deform_port (sas_ha->sas_phy[i],0 ); - +sas_deform_port (sas_ha->sas_phy[i], false); }const work_func_t sas_port_event_fns[PORT_NUM_EVENTS ] = {
Signature · 1 line
2.50.1
Re: [PATCH v4 5/5] scsi: libsas: Use a bool for sas_deform_port() second argument
Quoted 9 lines · Damien Le Moal
Change the type of the "gone" argument of
sas_deform_port()from int to bool. Simliarly, to be consistent, do the same change to the functionsas_unregister_domain_devices().No functional changes.
Signed-off-by Damien Le Moal<[email protected]>Reviewed-by Johannes Thumshirn<[email protected]>Reviewed-by John Garry<[email protected]>
Quoted 6 lines
--- drivers/scsi/libsas/sas_discover.c | 2 +- drivers/scsi/libsas/sas_internal.h | 4 ++-- drivers/scsi/libsas/sas_phy.c | 6 +++--- drivers/scsi/libsas/sas_port.c | 13 ++++++------- 4 files changed, 12 insertions(+), 13 deletions(-)
Martin K. Petersen
AppliedDamien,
Quoted 2 lines
While debugging an issue with the pm8001 driver, I generated these cleanup patches. No functional changes overall.
Applied to 6.17/scsi-staging, thanks!
Signature · 1 line
Martin K. Petersen
Martin K. Petersen
AppliedQuoted 8 lines · Damien Le Moal
Martin, John,
While debugging an issue with the pm8001 driver, I generated these cleanup patches. No functional changes overall.
These patches are against the 6.17/scsi-staging branch of the scsi tree.
[...]
Applied to 6.17/scsi-queue, thanks!
[1/5] scsi: libsas: Refactor dev_is_sata()
https://git.kernel.org/mkp/scsi/c/54091eee08ac [2/5] scsi: libsas: Simplify sas_ata_wait_eh() https://git.kernel.org/mkp/scsi/c/0dd03570512a [3/5] scsi: libsas: Make sas_get_ata_info() static https://git.kernel.org/mkp/scsi/c/bd31394aabf3 [4/5] scsi: libsas: Move declarations of internal functions to sas_internal.h https://git.kernel.org/mkp/scsi/c/704ed03abf6b [5/5] scsi: libsas: Use a bool for sas_deform_port() second argument https://git.kernel.org/mkp/scsi/c/75fe230b9bed
Signature · 1 line
Martin K. Petersen Oracle Linux Engineering
Martin K. Petersen
AppliedQuoted 8 lines · Damien Le Moal
Martin, John,
While debugging an issue with the pm8001 driver, I generated these cleanup patches. No functional changes overall.
These patches are against the 6.17/scsi-staging branch of the scsi tree.
[...]
Applied to 6.17/scsi-queue, thanks!
[1/5] scsi: libsas: Refactor dev_is_sata()
https://git.kernel.org/mkp/scsi/c/54091eee08ac [2/5] scsi: libsas: Simplify sas_ata_wait_eh() https://git.kernel.org/mkp/scsi/c/0dd03570512a [3/5] scsi: libsas: Make sas_get_ata_info() static https://git.kernel.org/mkp/scsi/c/bd31394aabf3 [4/5] scsi: libsas: Move declarations of internal functions to sas_internal.h https://git.kernel.org/mkp/scsi/c/704ed03abf6b [5/5] scsi: libsas: Use a bool for sas_deform_port() second argument https://git.kernel.org/mkp/scsi/c/75fe230b9bed
Signature · 1 line
Martin K. Petersen Oracle Linux Engineering