Skip to content

Commit 1cfc859

Browse files
andy-shevmchehab
authored andcommitted
media: atomisp: Get rid of struct pci_dev in struct atomisp_device
struct atomisp device has struct device and struct pci_dev pointers which are basically duplicates of each other. Drop the latter in favour of the former. While here, unify pdev to be pointer to struct pci_device and reindent some (touched) lines for better readability. Signed-off-by: Andy Shevchenko <[email protected]> Signed-off-by: Mauro Carvalho Chehab <[email protected]>
1 parent 0697fd9 commit 1cfc859

File tree

5 files changed

+43
-38
lines changed

5 files changed

+43
-38
lines changed

drivers/staging/media/atomisp/pci/atomisp_cmd.c

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ int atomisp_freq_scaling(struct atomisp_device *isp,
206206
enum atomisp_dfs_mode mode,
207207
bool force)
208208
{
209+
struct pci_dev *pdev = to_pci_dev(isp->dev);
209210
/* FIXME! Only use subdev[0] status yet */
210211
struct atomisp_sub_device *asd = &isp->asd[0];
211212
const struct atomisp_dfs_config *dfs;
@@ -219,7 +220,7 @@ int atomisp_freq_scaling(struct atomisp_device *isp,
219220
return -EINVAL;
220221
}
221222

222-
if ((isp->pdev->device & ATOMISP_PCI_DEVICE_SOC_MASK) ==
223+
if ((pdev->device & ATOMISP_PCI_DEVICE_SOC_MASK) ==
223224
ATOMISP_PCI_DEVICE_SOC_CHT && ATOMISP_USE_YUVPP(asd))
224225
isp->dfs = &dfs_config_cht_soc;
225226

@@ -357,8 +358,9 @@ static void clear_isp_irq(enum hrt_isp_css_irq irq)
357358
irq_clear_all(IRQ0_ID);
358359
}
359360

360-
void atomisp_msi_irq_init(struct atomisp_device *isp, struct pci_dev *dev)
361+
void atomisp_msi_irq_init(struct atomisp_device *isp)
361362
{
363+
struct pci_dev *dev = to_pci_dev(isp->dev);
362364
u32 msg32;
363365
u16 msg16;
364366

@@ -375,8 +377,9 @@ void atomisp_msi_irq_init(struct atomisp_device *isp, struct pci_dev *dev)
375377
pci_write_config_word(dev, PCI_COMMAND, msg16);
376378
}
377379

378-
void atomisp_msi_irq_uninit(struct atomisp_device *isp, struct pci_dev *dev)
380+
void atomisp_msi_irq_uninit(struct atomisp_device *isp)
379381
{
382+
struct pci_dev *dev = to_pci_dev(isp->dev);
380383
u32 msg32;
381384
u16 msg16;
382385

@@ -480,11 +483,12 @@ static void print_csi_rx_errors(enum mipi_port_id port,
480483
/* Clear irq reg */
481484
static void clear_irq_reg(struct atomisp_device *isp)
482485
{
486+
struct pci_dev *pdev = to_pci_dev(isp->dev);
483487
u32 msg_ret;
484488

485-
pci_read_config_dword(isp->pdev, PCI_INTERRUPT_CTRL, &msg_ret);
489+
pci_read_config_dword(pdev, PCI_INTERRUPT_CTRL, &msg_ret);
486490
msg_ret |= 1 << INTR_IIR;
487-
pci_write_config_dword(isp->pdev, PCI_INTERRUPT_CTRL, msg_ret);
491+
pci_write_config_dword(pdev, PCI_INTERRUPT_CTRL, msg_ret);
488492
}
489493

490494
static struct atomisp_sub_device *
@@ -1289,6 +1293,7 @@ void atomisp_delayed_init_work(struct work_struct *work)
12891293

12901294
static void __atomisp_css_recover(struct atomisp_device *isp, bool isp_timeout)
12911295
{
1296+
struct pci_dev *pdev = to_pci_dev(isp->dev);
12921297
enum ia_css_pipe_id css_pipe_id;
12931298
bool stream_restart[MAX_STREAM_NUM] = {0};
12941299
bool depth_mode = false;
@@ -1372,8 +1377,8 @@ static void __atomisp_css_recover(struct atomisp_device *isp, bool isp_timeout)
13721377
clear_isp_irq(hrt_isp_css_irq_sp);
13731378

13741379
/* Set the SRSE to 3 before resetting */
1375-
pci_write_config_dword(isp->pdev, PCI_I_CONTROL, isp->saved_regs.i_control |
1376-
MRFLD_PCI_I_CONTROL_SRSE_RESET_MASK);
1380+
pci_write_config_dword(pdev, PCI_I_CONTROL,
1381+
isp->saved_regs.i_control | MRFLD_PCI_I_CONTROL_SRSE_RESET_MASK);
13771382

13781383
/* reset ISP and restore its state */
13791384
isp->isp_timeout = true;
@@ -6158,6 +6163,7 @@ int atomisp_set_shading_table(struct atomisp_sub_device *asd,
61586163
/*Turn off ISP dphy */
61596164
int atomisp_ospm_dphy_down(struct atomisp_device *isp)
61606165
{
6166+
struct pci_dev *pdev = to_pci_dev(isp->dev);
61616167
unsigned long flags;
61626168
u32 reg;
61636169

@@ -6179,9 +6185,9 @@ int atomisp_ospm_dphy_down(struct atomisp_device *isp)
61796185
* MRFLD HW design need all CSI ports are disabled before
61806186
* powering down the IUNIT.
61816187
*/
6182-
pci_read_config_dword(isp->pdev, MRFLD_PCI_CSI_CONTROL, &reg);
6188+
pci_read_config_dword(pdev, MRFLD_PCI_CSI_CONTROL, &reg);
61836189
reg |= MRFLD_ALL_CSI_PORTS_OFF_MASK;
6184-
pci_write_config_dword(isp->pdev, MRFLD_PCI_CSI_CONTROL, reg);
6190+
pci_write_config_dword(pdev, MRFLD_PCI_CSI_CONTROL, reg);
61856191
return 0;
61866192
}
61876193

drivers/staging/media/atomisp/pci/atomisp_cmd.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ bool atomisp_buffers_queued_pipe(struct atomisp_video_pipe *pipe);
6868
/*
6969
* Interrupt functions
7070
*/
71-
void atomisp_msi_irq_init(struct atomisp_device *isp, struct pci_dev *dev);
72-
void atomisp_msi_irq_uninit(struct atomisp_device *isp, struct pci_dev *dev);
71+
void atomisp_msi_irq_init(struct atomisp_device *isp);
72+
void atomisp_msi_irq_uninit(struct atomisp_device *isp);
7373
void atomisp_wdt_work(struct work_struct *work);
7474
void atomisp_wdt(struct timer_list *t);
7575
void atomisp_setup_flash(struct atomisp_sub_device *asd);

drivers/staging/media/atomisp/pci/atomisp_internal.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,6 @@ struct atomisp_sw_contex {
216216
* ci device struct
217217
*/
218218
struct atomisp_device {
219-
struct pci_dev *pdev;
220219
struct device *dev;
221220
struct v4l2_device v4l2_dev;
222221
struct media_device media_dev;

drivers/staging/media/atomisp/pci/atomisp_ioctl.c

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -549,8 +549,7 @@ static int atomisp_querycap(struct file *file, void *fh,
549549

550550
strscpy(cap->driver, DRIVER, sizeof(cap->driver));
551551
strscpy(cap->card, CARD, sizeof(cap->card));
552-
snprintf(cap->bus_info, sizeof(cap->bus_info), "PCI:%s",
553-
pci_name(isp->pdev));
552+
snprintf(cap->bus_info, sizeof(cap->bus_info), "PCI:%s", dev_name(isp->dev));
554553

555554
return 0;
556555
}
@@ -1635,6 +1634,7 @@ static int atomisp_streamon(struct file *file, void *fh,
16351634
struct atomisp_video_pipe *pipe = atomisp_to_video_pipe(vdev);
16361635
struct atomisp_sub_device *asd = pipe->asd;
16371636
struct atomisp_device *isp = video_get_drvdata(vdev);
1637+
struct pci_dev *pdev = to_pci_dev(isp->dev);
16381638
enum ia_css_pipe_id css_pipe_id;
16391639
unsigned int sensor_start_stream;
16401640
unsigned int wdt_duration = ATOMISP_ISP_TIMEOUT_DURATION;
@@ -1844,9 +1844,8 @@ static int atomisp_streamon(struct file *file, void *fh,
18441844
/* Enable the CSI interface on ANN B0/K0 */
18451845
if (isp->media_dev.hw_revision >= ((ATOMISP_HW_REVISION_ISP2401 <<
18461846
ATOMISP_HW_REVISION_SHIFT) | ATOMISP_HW_STEPPING_B0)) {
1847-
pci_write_config_word(isp->pdev, MRFLD_PCI_CSI_CONTROL,
1848-
isp->saved_regs.csi_control |
1849-
MRFLD_PCI_CSI_CONTROL_CSI_READY);
1847+
pci_write_config_word(pdev, MRFLD_PCI_CSI_CONTROL,
1848+
isp->saved_regs.csi_control | MRFLD_PCI_CSI_CONTROL_CSI_READY);
18501849
}
18511850

18521851
/* stream on the sensor */
@@ -1891,6 +1890,7 @@ int __atomisp_streamoff(struct file *file, void *fh, enum v4l2_buf_type type)
18911890
{
18921891
struct video_device *vdev = video_devdata(file);
18931892
struct atomisp_device *isp = video_get_drvdata(vdev);
1893+
struct pci_dev *pdev = to_pci_dev(isp->dev);
18941894
struct atomisp_video_pipe *pipe = atomisp_to_video_pipe(vdev);
18951895
struct atomisp_sub_device *asd = pipe->asd;
18961896
struct atomisp_video_pipe *capture_pipe = NULL;
@@ -2076,9 +2076,8 @@ int __atomisp_streamoff(struct file *file, void *fh, enum v4l2_buf_type type)
20762076
/* Disable the CSI interface on ANN B0/K0 */
20772077
if (isp->media_dev.hw_revision >= ((ATOMISP_HW_REVISION_ISP2401 <<
20782078
ATOMISP_HW_REVISION_SHIFT) | ATOMISP_HW_STEPPING_B0)) {
2079-
pci_write_config_word(isp->pdev, MRFLD_PCI_CSI_CONTROL,
2080-
isp->saved_regs.csi_control &
2081-
~MRFLD_PCI_CSI_CONTROL_CSI_READY);
2079+
pci_write_config_word(pdev, MRFLD_PCI_CSI_CONTROL,
2080+
isp->saved_regs.csi_control & ~MRFLD_PCI_CSI_CONTROL_CSI_READY);
20822081
}
20832082

20842083
if (atomisp_freq_scaling(isp, ATOMISP_DFS_MODE_LOW, false))
@@ -2111,8 +2110,8 @@ int __atomisp_streamoff(struct file *file, void *fh, enum v4l2_buf_type type)
21112110
}
21122111

21132112
/* disable PUNIT/ISP acknowlede/handshake - SRSE=3 */
2114-
pci_write_config_dword(isp->pdev, PCI_I_CONTROL, isp->saved_regs.i_control |
2115-
MRFLD_PCI_I_CONTROL_SRSE_RESET_MASK);
2113+
pci_write_config_dword(pdev, PCI_I_CONTROL,
2114+
isp->saved_regs.i_control | MRFLD_PCI_I_CONTROL_SRSE_RESET_MASK);
21162115
dev_err(isp->dev, "atomisp_reset");
21172116
atomisp_reset(isp);
21182117
for (i = 0; i < isp->num_of_streams; i++) {

drivers/staging/media/atomisp/pci/atomisp_v4l2.c

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,7 @@ void atomisp_acc_unregister(struct atomisp_acc_pipe *video)
512512

513513
static int atomisp_save_iunit_reg(struct atomisp_device *isp)
514514
{
515-
struct pci_dev *dev = isp->pdev;
515+
struct pci_dev *dev = to_pci_dev(isp->dev);
516516

517517
dev_dbg(isp->dev, "%s\n", __func__);
518518

@@ -573,7 +573,7 @@ static int atomisp_save_iunit_reg(struct atomisp_device *isp)
573573

574574
static int __maybe_unused atomisp_restore_iunit_reg(struct atomisp_device *isp)
575575
{
576-
struct pci_dev *dev = isp->pdev;
576+
struct pci_dev *dev = to_pci_dev(isp->dev);
577577

578578
dev_dbg(isp->dev, "%s\n", __func__);
579579

@@ -619,7 +619,7 @@ static int __maybe_unused atomisp_restore_iunit_reg(struct atomisp_device *isp)
619619

620620
static int atomisp_mrfld_pre_power_down(struct atomisp_device *isp)
621621
{
622-
struct pci_dev *dev = isp->pdev;
622+
struct pci_dev *dev = to_pci_dev(isp->dev);
623623
u32 irq;
624624
unsigned long flags;
625625

@@ -679,7 +679,7 @@ static int atomisp_mrfld_pre_power_down(struct atomisp_device *isp)
679679
irq &= ~(1 << INTR_IER);
680680
pci_write_config_dword(dev, PCI_INTERRUPT_CTRL, irq);
681681

682-
atomisp_msi_irq_uninit(isp, dev);
682+
atomisp_msi_irq_uninit(isp);
683683
atomisp_freq_scaling(isp, ATOMISP_DFS_MODE_LOW, true);
684684
spin_unlock_irqrestore(&isp->lock, flags);
685685

@@ -904,6 +904,7 @@ static int __maybe_unused atomisp_resume(struct device *dev)
904904

905905
int atomisp_csi_lane_config(struct atomisp_device *isp)
906906
{
907+
struct pci_dev *pdev = to_pci_dev(isp->dev);
907908
static const struct {
908909
u8 code;
909910
u8 lanes[MRFLD_PORT_NUM];
@@ -1005,7 +1006,7 @@ int atomisp_csi_lane_config(struct atomisp_device *isp)
10051006
return -EINVAL;
10061007
}
10071008

1008-
pci_read_config_dword(isp->pdev, MRFLD_PCI_CSI_CONTROL, &csi_control);
1009+
pci_read_config_dword(pdev, MRFLD_PCI_CSI_CONTROL, &csi_control);
10091010
csi_control &= ~port_config_mask;
10101011
csi_control |= (portconfigs[i].code << MRFLD_PORT_CONFIGCODE_SHIFT)
10111012
| (portconfigs[i].lanes[0] ? 0 : (1 << MRFLD_PORT1_ENABLE_SHIFT))
@@ -1015,7 +1016,7 @@ int atomisp_csi_lane_config(struct atomisp_device *isp)
10151016
| (((1 << portconfigs[i].lanes[1]) - 1) << MRFLD_PORT2_LANES_SHIFT)
10161017
| (((1 << portconfigs[i].lanes[2]) - 1) << port3_lanes_shift);
10171018

1018-
pci_write_config_dword(isp->pdev, MRFLD_PCI_CSI_CONTROL, csi_control);
1019+
pci_write_config_dword(pdev, MRFLD_PCI_CSI_CONTROL, csi_control);
10191020

10201021
dev_dbg(isp->dev,
10211022
"%s: the portconfig is %d-%d-%d, CSI_CONTROL is 0x%08X\n",
@@ -1589,7 +1590,7 @@ static int atomisp_pci_probe(struct pci_dev *dev,
15891590
err = -ENOMEM;
15901591
goto atomisp_dev_alloc_fail;
15911592
}
1592-
isp->pdev = dev;
1593+
15931594
isp->dev = &dev->dev;
15941595
isp->sw_contex.power_state = ATOM_ISP_POWER_UP;
15951596
isp->saved_regs.ispmmadr = start;
@@ -1599,7 +1600,7 @@ static int atomisp_pci_probe(struct pci_dev *dev,
15991600
spin_lock_init(&isp->lock);
16001601

16011602
/* This is not a true PCI device on SoC, so the delay is not needed. */
1602-
isp->pdev->d3_delay = 0;
1603+
dev->d3_delay = 0;
16031604

16041605
switch (id->device & ATOMISP_PCI_DEVICE_SOC_MASK) {
16051606
case ATOMISP_PCI_DEVICE_SOC_MRFLD:
@@ -1658,7 +1659,7 @@ static int atomisp_pci_probe(struct pci_dev *dev,
16581659
* in power off. Set d3cold_delay to 0 since default 100ms is not
16591660
* necessary.
16601661
*/
1661-
isp->pdev->d3cold_delay = 0;
1662+
dev->d3cold_delay = 0;
16621663
break;
16631664
case ATOMISP_PCI_DEVICE_SOC_ANN:
16641665
isp->media_dev.hw_revision = (
@@ -1668,7 +1669,7 @@ static int atomisp_pci_probe(struct pci_dev *dev,
16681669
ATOMISP_HW_REVISION_ISP2401_LEGACY
16691670
#endif
16701671
<< ATOMISP_HW_REVISION_SHIFT);
1671-
isp->media_dev.hw_revision |= isp->pdev->revision < 2 ?
1672+
isp->media_dev.hw_revision |= dev->revision < 2 ?
16721673
ATOMISP_HW_STEPPING_A0 : ATOMISP_HW_STEPPING_B0;
16731674
isp->dfs = &dfs_config_merr;
16741675
isp->hpll_freq = HPLL_FREQ_1600MHZ;
@@ -1681,11 +1682,11 @@ static int atomisp_pci_probe(struct pci_dev *dev,
16811682
ATOMISP_HW_REVISION_ISP2401_LEGACY
16821683
#endif
16831684
<< ATOMISP_HW_REVISION_SHIFT);
1684-
isp->media_dev.hw_revision |= isp->pdev->revision < 2 ?
1685+
isp->media_dev.hw_revision |= dev->revision < 2 ?
16851686
ATOMISP_HW_STEPPING_A0 : ATOMISP_HW_STEPPING_B0;
16861687

16871688
isp->dfs = &dfs_config_cht;
1688-
isp->pdev->d3cold_delay = 0;
1689+
dev->d3cold_delay = 0;
16891690

16901691
iosf_mbi_read(BT_MBI_UNIT_CCK, MBI_REG_READ, CCK_FUSE_REG_0, &val);
16911692
switch (val & CCK_FUSE_HPLL_FREQ_MASK) {
@@ -1743,7 +1744,7 @@ static int atomisp_pci_probe(struct pci_dev *dev,
17431744
goto enable_msi_fail;
17441745
}
17451746

1746-
atomisp_msi_irq_init(isp, dev);
1747+
atomisp_msi_irq_init(isp);
17471748

17481749
cpu_latency_qos_add_request(&isp->pm_qos, PM_QOS_DEFAULT_VALUE);
17491750

@@ -1858,7 +1859,7 @@ static int atomisp_pci_probe(struct pci_dev *dev,
18581859
atomisp_uninitialize_modules(isp);
18591860
initialize_modules_fail:
18601861
cpu_latency_qos_remove_request(&isp->pm_qos);
1861-
atomisp_msi_irq_uninit(isp, dev);
1862+
atomisp_msi_irq_uninit(isp);
18621863
pci_disable_msi(dev);
18631864
enable_msi_fail:
18641865
fw_validation_fail:
@@ -1879,7 +1880,7 @@ static int atomisp_pci_probe(struct pci_dev *dev,
18791880
irq &= ~(1 << INTR_IER);
18801881
pci_write_config_dword(dev, PCI_INTERRUPT_CTRL, irq);
18811882

1882-
atomisp_msi_irq_uninit(isp, dev);
1883+
atomisp_msi_irq_uninit(isp);
18831884

18841885
atomisp_ospm_dphy_down(isp);
18851886

@@ -1912,7 +1913,7 @@ static void atomisp_pci_remove(struct pci_dev *dev)
19121913
pm_runtime_get_noresume(&dev->dev);
19131914
cpu_latency_qos_remove_request(&isp->pm_qos);
19141915

1915-
atomisp_msi_irq_uninit(isp, dev);
1916+
atomisp_msi_irq_uninit(isp);
19161917
atomisp_unregister_entities(isp);
19171918

19181919
destroy_workqueue(isp->wdt_work_queue);

0 commit comments

Comments
 (0)