Skip to content

Commit 949268e

Browse files
committed
Merge tag 'firewire-updates-6.14' of git://git.kernel.org/pub/scm/linux/kernel/git/ieee1394/linux1394
Pull firewire updates from Takashi Sakamoto: "Two changes for the 6.14 kernel. The first change concerns the PCI driver for 1394 OHCI hardware. Previously, it used legacy PCI suspend/resume callbacks, which have now been replaced with callbacks defined in the Linux generic power management framework. This original patch was posted in 2020 and has been adapted with some modifications for the latest kernel. Note that the driver still includes platform-specific operations for PowerPC, and these operations have not been tested in the new implementation yet. It would be helpful to share the results of suspending/resuming on the platform. The other one is a minor fix for the memory allocation in some KUnit tests" * tag 'firewire-updates-6.14' of git://git.kernel.org/pub/scm/linux/kernel/git/ieee1394/linux1394: firewire: test: Fix potential null dereference in firewire kunit test firewire: ohci: use generic power management
2 parents 41bfad5 + 352fafe commit 949268e

File tree

2 files changed

+15
-31
lines changed

2 files changed

+15
-31
lines changed

drivers/firewire/device-attribute-test.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ static void device_attr_simple_avc(struct kunit *test)
9999
struct device *unit0_dev = (struct device *)&unit0.device;
100100
static const int unit0_expected_ids[] = {0x00ffffff, 0x00ffffff, 0x0000a02d, 0x00010001};
101101
char *buf = kunit_kzalloc(test, PAGE_SIZE, GFP_KERNEL);
102+
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, buf);
102103
int ids[4] = {0, 0, 0, 0};
103104

104105
// Ensure associations for node and unit devices.
@@ -180,6 +181,7 @@ static void device_attr_legacy_avc(struct kunit *test)
180181
struct device *unit0_dev = (struct device *)&unit0.device;
181182
static const int unit0_expected_ids[] = {0x00012345, 0x00fedcba, 0x00abcdef, 0x00543210};
182183
char *buf = kunit_kzalloc(test, PAGE_SIZE, GFP_KERNEL);
184+
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, buf);
183185
int ids[4] = {0, 0, 0, 0};
184186

185187
// Ensure associations for node and unit devices.

drivers/firewire/ohci.c

Lines changed: 13 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -3301,8 +3301,7 @@ static int ohci_set_iso_channels(struct fw_iso_context *base, u64 *channels)
33013301
}
33023302
}
33033303

3304-
#ifdef CONFIG_PM
3305-
static void ohci_resume_iso_dma(struct fw_ohci *ohci)
3304+
static void __maybe_unused ohci_resume_iso_dma(struct fw_ohci *ohci)
33063305
{
33073306
int i;
33083307
struct iso_context *ctx;
@@ -3319,7 +3318,6 @@ static void ohci_resume_iso_dma(struct fw_ohci *ohci)
33193318
ohci_start_iso(&ctx->base, 0, ctx->sync, ctx->tags);
33203319
}
33213320
}
3322-
#endif
33233321

33243322
static int queue_iso_transmit(struct iso_context *ctx,
33253323
struct fw_iso_packet *packet,
@@ -3888,39 +3886,25 @@ static void pci_remove(struct pci_dev *dev)
38883886
dev_notice(&dev->dev, "removing fw-ohci device\n");
38893887
}
38903888

3891-
#ifdef CONFIG_PM
3892-
static int pci_suspend(struct pci_dev *dev, pm_message_t state)
3889+
static int __maybe_unused pci_suspend(struct device *dev)
38933890
{
3894-
struct fw_ohci *ohci = pci_get_drvdata(dev);
3895-
int err;
3891+
struct pci_dev *pdev = to_pci_dev(dev);
3892+
struct fw_ohci *ohci = pci_get_drvdata(pdev);
38963893

38973894
software_reset(ohci);
3898-
err = pci_save_state(dev);
3899-
if (err) {
3900-
ohci_err(ohci, "pci_save_state failed\n");
3901-
return err;
3902-
}
3903-
err = pci_set_power_state(dev, pci_choose_state(dev, state));
3904-
if (err)
3905-
ohci_err(ohci, "pci_set_power_state failed with %d\n", err);
3906-
pmac_ohci_off(dev);
3895+
pmac_ohci_off(pdev);
39073896

39083897
return 0;
39093898
}
39103899

3911-
static int pci_resume(struct pci_dev *dev)
3900+
3901+
static int __maybe_unused pci_resume(struct device *dev)
39123902
{
3913-
struct fw_ohci *ohci = pci_get_drvdata(dev);
3903+
struct pci_dev *pdev = to_pci_dev(dev);
3904+
struct fw_ohci *ohci = pci_get_drvdata(pdev);
39143905
int err;
39153906

3916-
pmac_ohci_on(dev);
3917-
pci_set_power_state(dev, PCI_D0);
3918-
pci_restore_state(dev);
3919-
err = pci_enable_device(dev);
3920-
if (err) {
3921-
ohci_err(ohci, "pci_enable_device failed\n");
3922-
return err;
3923-
}
3907+
pmac_ohci_on(pdev);
39243908

39253909
/* Some systems don't setup GUID register on resume from ram */
39263910
if (!reg_read(ohci, OHCI1394_GUIDLo) &&
@@ -3937,7 +3921,6 @@ static int pci_resume(struct pci_dev *dev)
39373921

39383922
return 0;
39393923
}
3940-
#endif
39413924

39423925
static const struct pci_device_id pci_table[] = {
39433926
{ PCI_DEVICE_CLASS(PCI_CLASS_SERIAL_FIREWIRE_OHCI, ~0) },
@@ -3946,15 +3929,14 @@ static const struct pci_device_id pci_table[] = {
39463929

39473930
MODULE_DEVICE_TABLE(pci, pci_table);
39483931

3932+
static SIMPLE_DEV_PM_OPS(pci_pm_ops, pci_suspend, pci_resume);
3933+
39493934
static struct pci_driver fw_ohci_pci_driver = {
39503935
.name = ohci_driver_name,
39513936
.id_table = pci_table,
39523937
.probe = pci_probe,
39533938
.remove = pci_remove,
3954-
#ifdef CONFIG_PM
3955-
.resume = pci_resume,
3956-
.suspend = pci_suspend,
3957-
#endif
3939+
.driver.pm = &pci_pm_ops,
39583940
};
39593941

39603942
static int __init fw_ohci_init(void)

0 commit comments

Comments
 (0)