Skip to content

Commit 7038db7

Browse files
Merge patch series "libsas cleanups"
Damien Le Moal <[email protected]> says: 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. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Martin K. Petersen <[email protected]>
2 parents 8e48727 + 75fe230 commit 7038db7

File tree

6 files changed

+101
-99
lines changed

6 files changed

+101
-99
lines changed

drivers/scsi/libsas/sas_ata.c

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ static int sas_get_ata_command_set(struct domain_device *dev)
252252
return ata_dev_classify(&tf);
253253
}
254254

255-
int sas_get_ata_info(struct domain_device *dev, struct ex_phy *phy)
255+
static int sas_get_ata_info(struct domain_device *dev, struct ex_phy *phy)
256256
{
257257
if (phy->attached_tproto & SAS_PROTOCOL_STP)
258258
dev->tproto = phy->attached_tproto;
@@ -927,13 +927,7 @@ EXPORT_SYMBOL_GPL(sas_ata_schedule_reset);
927927

928928
void sas_ata_wait_eh(struct domain_device *dev)
929929
{
930-
struct ata_port *ap;
931-
932-
if (!dev_is_sata(dev))
933-
return;
934-
935-
ap = dev->sata_dev.ap;
936-
ata_port_wait_eh(ap);
930+
ata_port_wait_eh(dev->sata_dev.ap);
937931
}
938932

939933
void sas_ata_device_link_abort(struct domain_device *device, bool force_reset)

drivers/scsi/libsas/sas_discover.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ void sas_unregister_dev(struct asd_sas_port *port, struct domain_device *dev)
406406
}
407407
}
408408

409-
void sas_unregister_domain_devices(struct asd_sas_port *port, int gone)
409+
void sas_unregister_domain_devices(struct asd_sas_port *port, bool gone)
410410
{
411411
struct domain_device *dev, *n;
412412

drivers/scsi/libsas/sas_internal.h

Lines changed: 76 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ void sas_hash_addr(u8 *hashed, const u8 *sas_addr);
4444
int sas_discover_root_expander(struct domain_device *dev);
4545

4646
int sas_ex_revalidate_domain(struct domain_device *dev);
47-
void sas_unregister_domain_devices(struct asd_sas_port *port, int gone);
47+
void sas_unregister_domain_devices(struct asd_sas_port *port, bool gone);
4848
void sas_init_disc(struct sas_discovery *disc, struct asd_sas_port *port);
4949
void sas_discover_event(struct asd_sas_port *port, enum discover_event ev);
5050

@@ -70,7 +70,7 @@ void sas_enable_revalidation(struct sas_ha_struct *ha);
7070
void sas_queue_deferred_work(struct sas_ha_struct *ha);
7171
void __sas_drain_work(struct sas_ha_struct *ha);
7272

73-
void sas_deform_port(struct asd_sas_phy *phy, int gone);
73+
void sas_deform_port(struct asd_sas_phy *phy, bool gone);
7474

7575
void sas_porte_bytes_dmaed(struct work_struct *work);
7676
void sas_porte_broadcast_rcvd(struct work_struct *work);
@@ -222,4 +222,78 @@ static inline void sas_put_device(struct domain_device *dev)
222222
kref_put(&dev->kref, sas_free_device);
223223
}
224224

225+
#ifdef CONFIG_SCSI_SAS_ATA
226+
227+
int sas_ata_init(struct domain_device *dev);
228+
void sas_ata_task_abort(struct sas_task *task);
229+
int sas_discover_sata(struct domain_device *dev);
230+
int sas_ata_add_dev(struct domain_device *parent, struct ex_phy *phy,
231+
struct domain_device *child, int phy_id);
232+
void sas_ata_strategy_handler(struct Scsi_Host *shost);
233+
void sas_ata_eh(struct Scsi_Host *shost, struct list_head *work_q);
234+
void sas_ata_end_eh(struct ata_port *ap);
235+
void sas_ata_wait_eh(struct domain_device *dev);
236+
void sas_probe_sata(struct asd_sas_port *port);
237+
void sas_suspend_sata(struct asd_sas_port *port);
238+
void sas_resume_sata(struct asd_sas_port *port);
239+
240+
#else
241+
242+
static inline int sas_ata_init(struct domain_device *dev)
243+
{
244+
return 0;
245+
}
246+
247+
static inline void sas_ata_task_abort(struct sas_task *task)
248+
{
249+
}
250+
251+
static inline void sas_ata_strategy_handler(struct Scsi_Host *shost)
252+
{
253+
}
254+
255+
static inline void sas_ata_eh(struct Scsi_Host *shost, struct list_head *work_q)
256+
{
257+
}
258+
259+
static inline void sas_ata_end_eh(struct ata_port *ap)
260+
{
261+
}
262+
263+
static inline void sas_ata_wait_eh(struct domain_device *dev)
264+
{
265+
}
266+
267+
static inline void sas_probe_sata(struct asd_sas_port *port)
268+
{
269+
}
270+
271+
static inline void sas_suspend_sata(struct asd_sas_port *port)
272+
{
273+
}
274+
275+
static inline void sas_resume_sata(struct asd_sas_port *port)
276+
{
277+
}
278+
279+
static inline void sas_ata_disabled_notice(void)
280+
{
281+
pr_notice_once("ATA device seen but CONFIG_SCSI_SAS_ATA=N\n");
282+
}
283+
284+
static inline int sas_discover_sata(struct domain_device *dev)
285+
{
286+
sas_ata_disabled_notice();
287+
return -ENXIO;
288+
}
289+
290+
static inline int sas_ata_add_dev(struct domain_device *parent, struct ex_phy *phy,
291+
struct domain_device *child, int phy_id)
292+
{
293+
sas_ata_disabled_notice();
294+
return -ENODEV;
295+
}
296+
297+
#endif
298+
225299
#endif /* _SAS_INTERNAL_H_ */

drivers/scsi/libsas/sas_phy.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ static void sas_phye_loss_of_signal(struct work_struct *work)
2020
struct asd_sas_phy *phy = ev->phy;
2121

2222
phy->error = 0;
23-
sas_deform_port(phy, 1);
23+
sas_deform_port(phy, true);
2424
}
2525

2626
static void sas_phye_oob_done(struct work_struct *work)
@@ -40,7 +40,7 @@ static void sas_phye_oob_error(struct work_struct *work)
4040
struct sas_internal *i =
4141
to_sas_internal(sas_ha->shost->transportt);
4242

43-
sas_deform_port(phy, 1);
43+
sas_deform_port(phy, true);
4444

4545
if (!port && phy->enabled && i->dft->lldd_control_phy) {
4646
phy->error++;
@@ -85,7 +85,7 @@ static void sas_phye_resume_timeout(struct work_struct *work)
8585

8686
phy->error = 0;
8787
phy->suspended = 0;
88-
sas_deform_port(phy, 1);
88+
sas_deform_port(phy, true);
8989
}
9090

9191

drivers/scsi/libsas/sas_port.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ static void sas_form_port(struct asd_sas_phy *phy)
113113

114114
if (port) {
115115
if (!phy_is_wideport_member(port, phy))
116-
sas_deform_port(phy, 0);
116+
sas_deform_port(phy, false);
117117
else if (phy->suspended) {
118118
phy->suspended = 0;
119119
sas_resume_port(phy);
@@ -206,7 +206,7 @@ static void sas_form_port(struct asd_sas_phy *phy)
206206
* This is called when the physical link to the other phy has been
207207
* lost (on this phy), in Event thread context. We cannot delay here.
208208
*/
209-
void sas_deform_port(struct asd_sas_phy *phy, int gone)
209+
void sas_deform_port(struct asd_sas_phy *phy, bool gone)
210210
{
211211
struct sas_ha_struct *sas_ha = phy->ha;
212212
struct asd_sas_port *port = phy->port;
@@ -301,23 +301,23 @@ void sas_porte_link_reset_err(struct work_struct *work)
301301
struct asd_sas_event *ev = to_asd_sas_event(work);
302302
struct asd_sas_phy *phy = ev->phy;
303303

304-
sas_deform_port(phy, 1);
304+
sas_deform_port(phy, true);
305305
}
306306

307307
void sas_porte_timer_event(struct work_struct *work)
308308
{
309309
struct asd_sas_event *ev = to_asd_sas_event(work);
310310
struct asd_sas_phy *phy = ev->phy;
311311

312-
sas_deform_port(phy, 1);
312+
sas_deform_port(phy, true);
313313
}
314314

315315
void sas_porte_hard_reset(struct work_struct *work)
316316
{
317317
struct asd_sas_event *ev = to_asd_sas_event(work);
318318
struct asd_sas_phy *phy = ev->phy;
319319

320-
sas_deform_port(phy, 1);
320+
sas_deform_port(phy, true);
321321
}
322322

323323
/* ---------- SAS port registration ---------- */
@@ -358,8 +358,7 @@ void sas_unregister_ports(struct sas_ha_struct *sas_ha)
358358

359359
for (i = 0; i < sas_ha->num_phys; i++)
360360
if (sas_ha->sas_phy[i]->port)
361-
sas_deform_port(sas_ha->sas_phy[i], 0);
362-
361+
sas_deform_port(sas_ha->sas_phy[i], false);
363362
}
364363

365364
const work_func_t sas_port_event_fns[PORT_NUM_EVENTS] = {

include/scsi/sas_ata.h

Lines changed: 13 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -15,89 +15,37 @@
1515

1616
#ifdef CONFIG_SCSI_SAS_ATA
1717

18-
static inline int dev_is_sata(struct domain_device *dev)
18+
static inline bool dev_is_sata(struct domain_device *dev)
1919
{
20-
return dev->dev_type == SAS_SATA_DEV || dev->dev_type == SAS_SATA_PM ||
21-
dev->dev_type == SAS_SATA_PM_PORT || dev->dev_type == SAS_SATA_PENDING;
20+
switch (dev->dev_type) {
21+
case SAS_SATA_DEV:
22+
case SAS_SATA_PENDING:
23+
case SAS_SATA_PM:
24+
case SAS_SATA_PM_PORT:
25+
return true;
26+
default:
27+
return false;
28+
}
2229
}
2330

24-
int sas_get_ata_info(struct domain_device *dev, struct ex_phy *phy);
25-
int sas_ata_init(struct domain_device *dev);
26-
void sas_ata_task_abort(struct sas_task *task);
27-
void sas_ata_strategy_handler(struct Scsi_Host *shost);
28-
void sas_ata_eh(struct Scsi_Host *shost, struct list_head *work_q);
2931
void sas_ata_schedule_reset(struct domain_device *dev);
30-
void sas_ata_wait_eh(struct domain_device *dev);
31-
void sas_probe_sata(struct asd_sas_port *port);
32-
void sas_suspend_sata(struct asd_sas_port *port);
33-
void sas_resume_sata(struct asd_sas_port *port);
34-
void sas_ata_end_eh(struct ata_port *ap);
3532
void sas_ata_device_link_abort(struct domain_device *dev, bool force_reset);
36-
int sas_execute_ata_cmd(struct domain_device *device, u8 *fis,
37-
int force_phy_id);
33+
int sas_execute_ata_cmd(struct domain_device *device, u8 *fis, int force_phy_id);
3834
int smp_ata_check_ready_type(struct ata_link *link);
39-
int sas_discover_sata(struct domain_device *dev);
40-
int sas_ata_add_dev(struct domain_device *parent, struct ex_phy *phy,
41-
struct domain_device *child, int phy_id);
4235

4336
extern const struct attribute_group sas_ata_sdev_attr_group;
4437

4538
#else
4639

47-
static inline void sas_ata_disabled_notice(void)
48-
{
49-
pr_notice_once("ATA device seen but CONFIG_SCSI_SAS_ATA=N\n");
50-
}
51-
52-
static inline int dev_is_sata(struct domain_device *dev)
53-
{
54-
return 0;
55-
}
56-
static inline int sas_ata_init(struct domain_device *dev)
57-
{
58-
return 0;
59-
}
60-
static inline void sas_ata_task_abort(struct sas_task *task)
61-
{
62-
}
63-
64-
static inline void sas_ata_strategy_handler(struct Scsi_Host *shost)
65-
{
66-
}
67-
68-
static inline void sas_ata_eh(struct Scsi_Host *shost, struct list_head *work_q)
40+
static inline bool dev_is_sata(struct domain_device *dev)
6941
{
42+
return false;
7043
}
7144

7245
static inline void sas_ata_schedule_reset(struct domain_device *dev)
7346
{
7447
}
7548

76-
static inline void sas_ata_wait_eh(struct domain_device *dev)
77-
{
78-
}
79-
80-
static inline void sas_probe_sata(struct asd_sas_port *port)
81-
{
82-
}
83-
84-
static inline void sas_suspend_sata(struct asd_sas_port *port)
85-
{
86-
}
87-
88-
static inline void sas_resume_sata(struct asd_sas_port *port)
89-
{
90-
}
91-
92-
static inline int sas_get_ata_info(struct domain_device *dev, struct ex_phy *phy)
93-
{
94-
return 0;
95-
}
96-
97-
static inline void sas_ata_end_eh(struct ata_port *ap)
98-
{
99-
}
100-
10149
static inline void sas_ata_device_link_abort(struct domain_device *dev,
10250
bool force_reset)
10351
{
@@ -114,19 +62,6 @@ static inline int smp_ata_check_ready_type(struct ata_link *link)
11462
return 0;
11563
}
11664

117-
static inline int sas_discover_sata(struct domain_device *dev)
118-
{
119-
sas_ata_disabled_notice();
120-
return -ENXIO;
121-
}
122-
123-
static inline int sas_ata_add_dev(struct domain_device *parent, struct ex_phy *phy,
124-
struct domain_device *child, int phy_id)
125-
{
126-
sas_ata_disabled_notice();
127-
return -ENODEV;
128-
}
129-
13065
#define sas_ata_sdev_attr_group ((struct attribute_group) {})
13166

13267
#endif

0 commit comments

Comments
 (0)