From patchwork Fri Jun 26 12:19:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 209272 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B6254C433E0 for ; Fri, 26 Jun 2020 12:19:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A1A3C208C9 for ; Fri, 26 Jun 2020 12:19:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728274AbgFZMTc (ORCPT ); Fri, 26 Jun 2020 08:19:32 -0400 Received: from mga18.intel.com ([134.134.136.126]:32972 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726667AbgFZMTb (ORCPT ); Fri, 26 Jun 2020 08:19:31 -0400 IronPort-SDR: y5Je2Z071M+DEbflhPGnr1CW9sFzifedL2hNJhGhLLj19h+H/PHnb22MnhYqLdb4bR+yi7M1du wVbQpZajWbPA== X-IronPort-AV: E=McAfee;i="6000,8403,9663"; a="132725896" X-IronPort-AV: E=Sophos;i="5.75,283,1589266800"; d="scan'208";a="132725896" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Jun 2020 05:19:30 -0700 IronPort-SDR: wk2gnt7mYmMtRP+jCpILVBVnQYa/7erRxG9X49TGSLG9pjylDHpEOGkKrHbzsaUY4UdN0qjTQq aWc43XXXb8+w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,283,1589266800"; d="scan'208";a="265606528" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga008.fm.intel.com with ESMTP; 26 Jun 2020 05:19:29 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 3C63532E; Fri, 26 Jun 2020 15:19:28 +0300 (EEST) From: Andy Shevchenko To: Mauro Carvalho Chehab , linux-media@vger.kernel.org, Sakari Ailus Cc: Andy Shevchenko Subject: [PATCH v2 04/15] media: atomisp: don't pass struct device_driver as parameter Date: Fri, 26 Jun 2020 15:19:14 +0300 Message-Id: <20200626121925.14365-5-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200626121925.14365-1-andriy.shevchenko@linux.intel.com> References: <20200626121925.14365-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org There is no need to pass a pointer to struct device_driver when we have an access to struct device already. Signed-off-by: Andy Shevchenko --- drivers/staging/media/atomisp/pci/atomisp_drvfs.c | 3 ++- drivers/staging/media/atomisp/pci/atomisp_drvfs.h | 2 +- drivers/staging/media/atomisp/pci/atomisp_v4l2.c | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/staging/media/atomisp/pci/atomisp_drvfs.c b/drivers/staging/media/atomisp/pci/atomisp_drvfs.c index fe0e2bfde27f..3711df111fbf 100644 --- a/drivers/staging/media/atomisp/pci/atomisp_drvfs.c +++ b/drivers/staging/media/atomisp/pci/atomisp_drvfs.c @@ -185,8 +185,9 @@ static void iunit_drvfs_remove_files(struct device_driver *drv) driver_remove_file(drv, &iunit_drvfs_attrs[i]); } -int atomisp_drvfs_init(struct device_driver *drv, struct atomisp_device *isp) +int atomisp_drvfs_init(struct atomisp_device *isp) { + struct device_driver *drv = isp->dev->driver; int ret; iunit_debug.isp = isp; diff --git a/drivers/staging/media/atomisp/pci/atomisp_drvfs.h b/drivers/staging/media/atomisp/pci/atomisp_drvfs.h index 4911037231fb..8f4cc722b881 100644 --- a/drivers/staging/media/atomisp/pci/atomisp_drvfs.h +++ b/drivers/staging/media/atomisp/pci/atomisp_drvfs.h @@ -19,7 +19,7 @@ #ifndef __ATOMISP_DRVFS_H__ #define __ATOMISP_DRVFS_H__ -int atomisp_drvfs_init(struct device_driver *drv, struct atomisp_device *isp); +int atomisp_drvfs_init(struct atomisp_device *isp); void atomisp_drvfs_exit(void); #endif /* __ATOMISP_DRVFS_H__ */ diff --git a/drivers/staging/media/atomisp/pci/atomisp_v4l2.c b/drivers/staging/media/atomisp/pci/atomisp_v4l2.c index fa07cbaf0422..c6996b1f228b 100644 --- a/drivers/staging/media/atomisp/pci/atomisp_v4l2.c +++ b/drivers/staging/media/atomisp/pci/atomisp_v4l2.c @@ -1838,7 +1838,7 @@ static int atomisp_pci_probe(struct pci_dev *dev, isp->firmware = NULL; isp->css_env.isp_css_fw.data = NULL; - atomisp_drvfs_init(&dev->driver->driver, isp); + atomisp_drvfs_init(isp); return 0; From patchwork Fri Jun 26 12:19:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 209265 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2E366C433DF for ; Fri, 26 Jun 2020 12:21:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0EE442081A for ; Fri, 26 Jun 2020 12:21:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728257AbgFZMVh (ORCPT ); Fri, 26 Jun 2020 08:21:37 -0400 Received: from mga11.intel.com ([192.55.52.93]:29757 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728318AbgFZMVh (ORCPT ); Fri, 26 Jun 2020 08:21:37 -0400 IronPort-SDR: L4n/2vk7gf3LKJKwmFNTWLS3WT+KmZZVW3yJjPMXiwIhMSoxfS4aJdl22hmqbD/Jd8/jQAYfjZ Aks30eI6545A== X-IronPort-AV: E=McAfee;i="6000,8403,9663"; a="143544878" X-IronPort-AV: E=Sophos;i="5.75,283,1589266800"; d="scan'208";a="143544878" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Jun 2020 05:19:32 -0700 IronPort-SDR: e1ghNnd6CDrDzq3FAgwN5ARdN1ZEMbLHST/aXv052egiztNdckj0BZvpkMisF450lfXfF6DAqb ZQ0ODyzOtZGw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,283,1589266800"; d="scan'208";a="312306788" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga002.fm.intel.com with ESMTP; 26 Jun 2020 05:19:31 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 443FA426; Fri, 26 Jun 2020 15:19:28 +0300 (EEST) From: Andy Shevchenko To: Mauro Carvalho Chehab , linux-media@vger.kernel.org, Sakari Ailus Cc: Andy Shevchenko Subject: [PATCH v2 05/15] media: atomisp: Get rid of struct pci_dev in struct atomisp_device Date: Fri, 26 Jun 2020 15:19:15 +0300 Message-Id: <20200626121925.14365-6-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200626121925.14365-1-andriy.shevchenko@linux.intel.com> References: <20200626121925.14365-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org 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 --- .../staging/media/atomisp/pci/atomisp_cmd.c | 24 +++++++++----- .../staging/media/atomisp/pci/atomisp_cmd.h | 4 +-- .../media/atomisp/pci/atomisp_internal.h | 1 - .../staging/media/atomisp/pci/atomisp_ioctl.c | 19 +++++------ .../staging/media/atomisp/pci/atomisp_v4l2.c | 33 ++++++++++--------- 5 files changed, 43 insertions(+), 38 deletions(-) diff --git a/drivers/staging/media/atomisp/pci/atomisp_cmd.c b/drivers/staging/media/atomisp/pci/atomisp_cmd.c index 7b936e5a5f03..0735df75841f 100644 --- a/drivers/staging/media/atomisp/pci/atomisp_cmd.c +++ b/drivers/staging/media/atomisp/pci/atomisp_cmd.c @@ -206,6 +206,7 @@ int atomisp_freq_scaling(struct atomisp_device *isp, enum atomisp_dfs_mode mode, bool force) { + struct pci_dev *pdev = to_pci_dev(isp->dev); /* FIXME! Only use subdev[0] status yet */ struct atomisp_sub_device *asd = &isp->asd[0]; const struct atomisp_dfs_config *dfs; @@ -219,7 +220,7 @@ int atomisp_freq_scaling(struct atomisp_device *isp, return -EINVAL; } - if ((isp->pdev->device & ATOMISP_PCI_DEVICE_SOC_MASK) == + if ((pdev->device & ATOMISP_PCI_DEVICE_SOC_MASK) == ATOMISP_PCI_DEVICE_SOC_CHT && ATOMISP_USE_YUVPP(asd)) isp->dfs = &dfs_config_cht_soc; @@ -357,8 +358,9 @@ static void clear_isp_irq(enum hrt_isp_css_irq irq) irq_clear_all(IRQ0_ID); } -void atomisp_msi_irq_init(struct atomisp_device *isp, struct pci_dev *dev) +void atomisp_msi_irq_init(struct atomisp_device *isp) { + struct pci_dev *dev = to_pci_dev(isp->dev); u32 msg32; u16 msg16; @@ -375,8 +377,9 @@ void atomisp_msi_irq_init(struct atomisp_device *isp, struct pci_dev *dev) pci_write_config_word(dev, PCI_COMMAND, msg16); } -void atomisp_msi_irq_uninit(struct atomisp_device *isp, struct pci_dev *dev) +void atomisp_msi_irq_uninit(struct atomisp_device *isp) { + struct pci_dev *dev = to_pci_dev(isp->dev); u32 msg32; u16 msg16; @@ -480,11 +483,12 @@ static void print_csi_rx_errors(enum mipi_port_id port, /* Clear irq reg */ static void clear_irq_reg(struct atomisp_device *isp) { + struct pci_dev *pdev = to_pci_dev(isp->dev); u32 msg_ret; - pci_read_config_dword(isp->pdev, PCI_INTERRUPT_CTRL, &msg_ret); + pci_read_config_dword(pdev, PCI_INTERRUPT_CTRL, &msg_ret); msg_ret |= 1 << INTR_IIR; - pci_write_config_dword(isp->pdev, PCI_INTERRUPT_CTRL, msg_ret); + pci_write_config_dword(pdev, PCI_INTERRUPT_CTRL, msg_ret); } static struct atomisp_sub_device * @@ -1289,6 +1293,7 @@ void atomisp_delayed_init_work(struct work_struct *work) static void __atomisp_css_recover(struct atomisp_device *isp, bool isp_timeout) { + struct pci_dev *pdev = to_pci_dev(isp->dev); enum ia_css_pipe_id css_pipe_id; bool stream_restart[MAX_STREAM_NUM] = {0}; bool depth_mode = false; @@ -1372,8 +1377,8 @@ static void __atomisp_css_recover(struct atomisp_device *isp, bool isp_timeout) clear_isp_irq(hrt_isp_css_irq_sp); /* Set the SRSE to 3 before resetting */ - pci_write_config_dword(isp->pdev, PCI_I_CONTROL, isp->saved_regs.i_control | - MRFLD_PCI_I_CONTROL_SRSE_RESET_MASK); + pci_write_config_dword(pdev, PCI_I_CONTROL, + isp->saved_regs.i_control | MRFLD_PCI_I_CONTROL_SRSE_RESET_MASK); /* reset ISP and restore its state */ isp->isp_timeout = true; @@ -6158,6 +6163,7 @@ int atomisp_set_shading_table(struct atomisp_sub_device *asd, /*Turn off ISP dphy */ int atomisp_ospm_dphy_down(struct atomisp_device *isp) { + struct pci_dev *pdev = to_pci_dev(isp->dev); unsigned long flags; u32 reg; @@ -6179,9 +6185,9 @@ int atomisp_ospm_dphy_down(struct atomisp_device *isp) * MRFLD HW design need all CSI ports are disabled before * powering down the IUNIT. */ - pci_read_config_dword(isp->pdev, MRFLD_PCI_CSI_CONTROL, ®); + pci_read_config_dword(pdev, MRFLD_PCI_CSI_CONTROL, ®); reg |= MRFLD_ALL_CSI_PORTS_OFF_MASK; - pci_write_config_dword(isp->pdev, MRFLD_PCI_CSI_CONTROL, reg); + pci_write_config_dword(pdev, MRFLD_PCI_CSI_CONTROL, reg); return 0; } diff --git a/drivers/staging/media/atomisp/pci/atomisp_cmd.h b/drivers/staging/media/atomisp/pci/atomisp_cmd.h index 0bde995f1a8d..1c0d464c2ac1 100644 --- a/drivers/staging/media/atomisp/pci/atomisp_cmd.h +++ b/drivers/staging/media/atomisp/pci/atomisp_cmd.h @@ -68,8 +68,8 @@ bool atomisp_buffers_queued_pipe(struct atomisp_video_pipe *pipe); /* * Interrupt functions */ -void atomisp_msi_irq_init(struct atomisp_device *isp, struct pci_dev *dev); -void atomisp_msi_irq_uninit(struct atomisp_device *isp, struct pci_dev *dev); +void atomisp_msi_irq_init(struct atomisp_device *isp); +void atomisp_msi_irq_uninit(struct atomisp_device *isp); void atomisp_wdt_work(struct work_struct *work); void atomisp_wdt(struct timer_list *t); void atomisp_setup_flash(struct atomisp_sub_device *asd); diff --git a/drivers/staging/media/atomisp/pci/atomisp_internal.h b/drivers/staging/media/atomisp/pci/atomisp_internal.h index ff3becd41110..5af9bbce6284 100644 --- a/drivers/staging/media/atomisp/pci/atomisp_internal.h +++ b/drivers/staging/media/atomisp/pci/atomisp_internal.h @@ -216,7 +216,6 @@ struct atomisp_sw_contex { * ci device struct */ struct atomisp_device { - struct pci_dev *pdev; struct device *dev; struct v4l2_device v4l2_dev; struct media_device media_dev; diff --git a/drivers/staging/media/atomisp/pci/atomisp_ioctl.c b/drivers/staging/media/atomisp/pci/atomisp_ioctl.c index 9404a678fa6f..f8d616f08b51 100644 --- a/drivers/staging/media/atomisp/pci/atomisp_ioctl.c +++ b/drivers/staging/media/atomisp/pci/atomisp_ioctl.c @@ -549,8 +549,7 @@ static int atomisp_querycap(struct file *file, void *fh, strscpy(cap->driver, DRIVER, sizeof(cap->driver)); strscpy(cap->card, CARD, sizeof(cap->card)); - snprintf(cap->bus_info, sizeof(cap->bus_info), "PCI:%s", - pci_name(isp->pdev)); + snprintf(cap->bus_info, sizeof(cap->bus_info), "PCI:%s", dev_name(isp->dev)); return 0; } @@ -1635,6 +1634,7 @@ static int atomisp_streamon(struct file *file, void *fh, struct atomisp_video_pipe *pipe = atomisp_to_video_pipe(vdev); struct atomisp_sub_device *asd = pipe->asd; struct atomisp_device *isp = video_get_drvdata(vdev); + struct pci_dev *pdev = to_pci_dev(isp->dev); enum ia_css_pipe_id css_pipe_id; unsigned int sensor_start_stream; unsigned int wdt_duration = ATOMISP_ISP_TIMEOUT_DURATION; @@ -1844,9 +1844,8 @@ static int atomisp_streamon(struct file *file, void *fh, /* Enable the CSI interface on ANN B0/K0 */ if (isp->media_dev.hw_revision >= ((ATOMISP_HW_REVISION_ISP2401 << ATOMISP_HW_REVISION_SHIFT) | ATOMISP_HW_STEPPING_B0)) { - pci_write_config_word(isp->pdev, MRFLD_PCI_CSI_CONTROL, - isp->saved_regs.csi_control | - MRFLD_PCI_CSI_CONTROL_CSI_READY); + pci_write_config_word(pdev, MRFLD_PCI_CSI_CONTROL, + isp->saved_regs.csi_control | MRFLD_PCI_CSI_CONTROL_CSI_READY); } /* stream on the sensor */ @@ -1891,6 +1890,7 @@ int __atomisp_streamoff(struct file *file, void *fh, enum v4l2_buf_type type) { struct video_device *vdev = video_devdata(file); struct atomisp_device *isp = video_get_drvdata(vdev); + struct pci_dev *pdev = to_pci_dev(isp->dev); struct atomisp_video_pipe *pipe = atomisp_to_video_pipe(vdev); struct atomisp_sub_device *asd = pipe->asd; struct atomisp_video_pipe *capture_pipe = NULL; @@ -2076,9 +2076,8 @@ int __atomisp_streamoff(struct file *file, void *fh, enum v4l2_buf_type type) /* Disable the CSI interface on ANN B0/K0 */ if (isp->media_dev.hw_revision >= ((ATOMISP_HW_REVISION_ISP2401 << ATOMISP_HW_REVISION_SHIFT) | ATOMISP_HW_STEPPING_B0)) { - pci_write_config_word(isp->pdev, MRFLD_PCI_CSI_CONTROL, - isp->saved_regs.csi_control & - ~MRFLD_PCI_CSI_CONTROL_CSI_READY); + pci_write_config_word(pdev, MRFLD_PCI_CSI_CONTROL, + isp->saved_regs.csi_control & ~MRFLD_PCI_CSI_CONTROL_CSI_READY); } 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) } /* disable PUNIT/ISP acknowlede/handshake - SRSE=3 */ - pci_write_config_dword(isp->pdev, PCI_I_CONTROL, isp->saved_regs.i_control | - MRFLD_PCI_I_CONTROL_SRSE_RESET_MASK); + pci_write_config_dword(pdev, PCI_I_CONTROL, + isp->saved_regs.i_control | MRFLD_PCI_I_CONTROL_SRSE_RESET_MASK); dev_err(isp->dev, "atomisp_reset"); atomisp_reset(isp); for (i = 0; i < isp->num_of_streams; i++) { diff --git a/drivers/staging/media/atomisp/pci/atomisp_v4l2.c b/drivers/staging/media/atomisp/pci/atomisp_v4l2.c index c6996b1f228b..3ae9058b32ec 100644 --- a/drivers/staging/media/atomisp/pci/atomisp_v4l2.c +++ b/drivers/staging/media/atomisp/pci/atomisp_v4l2.c @@ -512,7 +512,7 @@ void atomisp_acc_unregister(struct atomisp_acc_pipe *video) static int atomisp_save_iunit_reg(struct atomisp_device *isp) { - struct pci_dev *dev = isp->pdev; + struct pci_dev *dev = to_pci_dev(isp->dev); dev_dbg(isp->dev, "%s\n", __func__); @@ -573,7 +573,7 @@ static int atomisp_save_iunit_reg(struct atomisp_device *isp) static int __maybe_unused atomisp_restore_iunit_reg(struct atomisp_device *isp) { - struct pci_dev *dev = isp->pdev; + struct pci_dev *dev = to_pci_dev(isp->dev); dev_dbg(isp->dev, "%s\n", __func__); @@ -619,7 +619,7 @@ static int __maybe_unused atomisp_restore_iunit_reg(struct atomisp_device *isp) static int atomisp_mrfld_pre_power_down(struct atomisp_device *isp) { - struct pci_dev *dev = isp->pdev; + struct pci_dev *dev = to_pci_dev(isp->dev); u32 irq; unsigned long flags; @@ -679,7 +679,7 @@ static int atomisp_mrfld_pre_power_down(struct atomisp_device *isp) irq &= ~(1 << INTR_IER); pci_write_config_dword(dev, PCI_INTERRUPT_CTRL, irq); - atomisp_msi_irq_uninit(isp, dev); + atomisp_msi_irq_uninit(isp); atomisp_freq_scaling(isp, ATOMISP_DFS_MODE_LOW, true); spin_unlock_irqrestore(&isp->lock, flags); @@ -902,6 +902,7 @@ static int __maybe_unused atomisp_resume(struct device *dev) int atomisp_csi_lane_config(struct atomisp_device *isp) { + struct pci_dev *pdev = to_pci_dev(isp->dev); static const struct { u8 code; u8 lanes[MRFLD_PORT_NUM]; @@ -1003,7 +1004,7 @@ int atomisp_csi_lane_config(struct atomisp_device *isp) return -EINVAL; } - pci_read_config_dword(isp->pdev, MRFLD_PCI_CSI_CONTROL, &csi_control); + pci_read_config_dword(pdev, MRFLD_PCI_CSI_CONTROL, &csi_control); csi_control &= ~port_config_mask; csi_control |= (portconfigs[i].code << MRFLD_PORT_CONFIGCODE_SHIFT) | (portconfigs[i].lanes[0] ? 0 : (1 << MRFLD_PORT1_ENABLE_SHIFT)) @@ -1013,7 +1014,7 @@ int atomisp_csi_lane_config(struct atomisp_device *isp) | (((1 << portconfigs[i].lanes[1]) - 1) << MRFLD_PORT2_LANES_SHIFT) | (((1 << portconfigs[i].lanes[2]) - 1) << port3_lanes_shift); - pci_write_config_dword(isp->pdev, MRFLD_PCI_CSI_CONTROL, csi_control); + pci_write_config_dword(pdev, MRFLD_PCI_CSI_CONTROL, csi_control); dev_dbg(isp->dev, "%s: the portconfig is %d-%d-%d, CSI_CONTROL is 0x%08X\n", @@ -1587,7 +1588,7 @@ static int atomisp_pci_probe(struct pci_dev *dev, err = -ENOMEM; goto atomisp_dev_alloc_fail; } - isp->pdev = dev; + isp->dev = &dev->dev; isp->sw_contex.power_state = ATOM_ISP_POWER_UP; isp->saved_regs.ispmmadr = start; @@ -1597,7 +1598,7 @@ static int atomisp_pci_probe(struct pci_dev *dev, spin_lock_init(&isp->lock); /* This is not a true PCI device on SoC, so the delay is not needed. */ - isp->pdev->d3_delay = 0; + dev->d3_delay = 0; switch (id->device & ATOMISP_PCI_DEVICE_SOC_MASK) { case ATOMISP_PCI_DEVICE_SOC_MRFLD: @@ -1656,7 +1657,7 @@ static int atomisp_pci_probe(struct pci_dev *dev, * in power off. Set d3cold_delay to 0 since default 100ms is not * necessary. */ - isp->pdev->d3cold_delay = 0; + dev->d3cold_delay = 0; break; case ATOMISP_PCI_DEVICE_SOC_ANN: isp->media_dev.hw_revision = ( @@ -1666,7 +1667,7 @@ static int atomisp_pci_probe(struct pci_dev *dev, ATOMISP_HW_REVISION_ISP2401_LEGACY #endif << ATOMISP_HW_REVISION_SHIFT); - isp->media_dev.hw_revision |= isp->pdev->revision < 2 ? + isp->media_dev.hw_revision |= dev->revision < 2 ? ATOMISP_HW_STEPPING_A0 : ATOMISP_HW_STEPPING_B0; isp->dfs = &dfs_config_merr; isp->hpll_freq = HPLL_FREQ_1600MHZ; @@ -1679,11 +1680,11 @@ static int atomisp_pci_probe(struct pci_dev *dev, ATOMISP_HW_REVISION_ISP2401_LEGACY #endif << ATOMISP_HW_REVISION_SHIFT); - isp->media_dev.hw_revision |= isp->pdev->revision < 2 ? + isp->media_dev.hw_revision |= dev->revision < 2 ? ATOMISP_HW_STEPPING_A0 : ATOMISP_HW_STEPPING_B0; isp->dfs = &dfs_config_cht; - isp->pdev->d3cold_delay = 0; + dev->d3cold_delay = 0; iosf_mbi_read(BT_MBI_UNIT_CCK, MBI_REG_READ, CCK_FUSE_REG_0, &val); switch (val & CCK_FUSE_HPLL_FREQ_MASK) { @@ -1741,7 +1742,7 @@ static int atomisp_pci_probe(struct pci_dev *dev, goto enable_msi_fail; } - atomisp_msi_irq_init(isp, dev); + atomisp_msi_irq_init(isp); cpu_latency_qos_add_request(&isp->pm_qos, PM_QOS_DEFAULT_VALUE); @@ -1856,7 +1857,7 @@ static int atomisp_pci_probe(struct pci_dev *dev, atomisp_uninitialize_modules(isp); initialize_modules_fail: cpu_latency_qos_remove_request(&isp->pm_qos); - atomisp_msi_irq_uninit(isp, dev); + atomisp_msi_irq_uninit(isp); pci_disable_msi(dev); enable_msi_fail: fw_validation_fail: @@ -1877,7 +1878,7 @@ static int atomisp_pci_probe(struct pci_dev *dev, irq &= ~(1 << INTR_IER); pci_write_config_dword(dev, PCI_INTERRUPT_CTRL, irq); - atomisp_msi_irq_uninit(isp, dev); + atomisp_msi_irq_uninit(isp); atomisp_ospm_dphy_down(isp); @@ -1910,7 +1911,7 @@ static void atomisp_pci_remove(struct pci_dev *dev) pm_runtime_get_noresume(&dev->dev); cpu_latency_qos_remove_request(&isp->pm_qos); - atomisp_msi_irq_uninit(isp, dev); + atomisp_msi_irq_uninit(isp); atomisp_unregister_entities(isp); destroy_workqueue(isp->wdt_work_queue); From patchwork Fri Jun 26 12:19:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 209270 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 55206C433E1 for ; Fri, 26 Jun 2020 12:19:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2F0B52088E for ; Fri, 26 Jun 2020 12:19:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728314AbgFZMTf (ORCPT ); Fri, 26 Jun 2020 08:19:35 -0400 Received: from mga06.intel.com ([134.134.136.31]:61058 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728290AbgFZMTd (ORCPT ); Fri, 26 Jun 2020 08:19:33 -0400 IronPort-SDR: Y1MBOzHGzP8Or3oaxC85Wu/KzzqGn+oC6IlEWyIbnVvahJn6EGQM1d/MErrI8bV1M0Ef2ylb6R 2258STlxRrtw== X-IronPort-AV: E=McAfee;i="6000,8403,9663"; a="206818993" X-IronPort-AV: E=Sophos;i="5.75,283,1589266800"; d="scan'208";a="206818993" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Jun 2020 05:19:32 -0700 IronPort-SDR: BXoa+NGYslo2E62TJY+ShinQxyxyR6VBGprGjCTXulkAXx855BltH//mR1EU1W7VXalNkxc2c4 96dUtREGgSmQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,283,1589266800"; d="scan'208";a="280130796" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga006.jf.intel.com with ESMTP; 26 Jun 2020 05:19:31 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 69B3B66E; Fri, 26 Jun 2020 15:19:28 +0300 (EEST) From: Andy Shevchenko To: Mauro Carvalho Chehab , linux-media@vger.kernel.org, Sakari Ailus Cc: Andy Shevchenko Subject: [PATCH v2 10/15] media: atomisp: Don't try to parse unexpected ACPI object type Date: Fri, 26 Jun 2020 15:19:20 +0300 Message-Id: <20200626121925.14365-11-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200626121925.14365-1-andriy.shevchenko@linux.intel.com> References: <20200626121925.14365-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org There are devices with completely different _DSM() format, and accessing object as a package leads to crashes. Bail out in the case of unexpected object type. Signed-off-by: Andy Shevchenko --- drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c b/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c index fb61274af7e5..f06c0eb6d288 100644 --- a/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c +++ b/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c @@ -959,6 +959,10 @@ static int gmin_get_config_dsm_var(struct device *dev, return -EINVAL; } + /* Return on unexpected object type */ + if (obj->type != ACPI_TYPE_PACKAGE) + return -EINVAL; + #if 0 /* Just for debugging purposes */ for (i = 0; i < obj->package.count; i++) { union acpi_object *cur = &obj->package.elements[i]; From patchwork Fri Jun 26 12:19:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 209267 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EA59BC433DF for ; Fri, 26 Jun 2020 12:19:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CFF7E2080C for ; Fri, 26 Jun 2020 12:19:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728363AbgFZMTt (ORCPT ); Fri, 26 Jun 2020 08:19:49 -0400 Received: from mga01.intel.com ([192.55.52.88]:27852 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728286AbgFZMTi (ORCPT ); Fri, 26 Jun 2020 08:19:38 -0400 IronPort-SDR: 0+TqU2V0xgdnng6W2CxbaKFX3YL3a5o3FZTKkk8UrcwoYK7B4Ce4TYCB3zlQMl+kQJLbjrVe// RaOxnUEeK0eg== X-IronPort-AV: E=McAfee;i="6000,8403,9663"; a="163348543" X-IronPort-AV: E=Sophos;i="5.75,283,1589266800"; d="scan'208";a="163348543" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Jun 2020 05:19:32 -0700 IronPort-SDR: a+MpeqzzMWa8jC9dofplje9un30PEFV7VlOcQqW6/4U1m4dPMf5IE+oojaMAIQinNpArXkJgAG YWoU0JQsyBYA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,283,1589266800"; d="scan'208";a="479985589" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga005.fm.intel.com with ESMTP; 26 Jun 2020 05:19:31 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 70F896A8; Fri, 26 Jun 2020 15:19:28 +0300 (EEST) From: Andy Shevchenko To: Mauro Carvalho Chehab , linux-media@vger.kernel.org, Sakari Ailus Cc: Andy Shevchenko Subject: [PATCH v2 11/15] media: atomisp: Make pointer to PMIC client global Date: Fri, 26 Jun 2020 15:19:21 +0300 Message-Id: <20200626121925.14365-12-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200626121925.14365-1-andriy.shevchenko@linux.intel.com> References: <20200626121925.14365-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org When we enumerate second device when PMIC has been successfully detected to AXP, we got into troubles dereferencing NULL pointer. It seems we have to detect PMIC only once because pmic_id is a global variable and code doesn't expect the change of it: Two PMICs on one platform? It's impossible. Crash excerpt: [ 34.335237] BUG: kernel NULL pointer dereference, address: 0000000000000002 ... [ 35.652036] RIP: 0010:gmin_subdev_add.cold+0x32f/0x33e [atomisp_gmin_platform] So, as a quick fix make power a global variable. In next patches we move PMIC detection to be more independent from subdevices. Signed-off-by: Andy Shevchenko --- drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c b/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c index f06c0eb6d288..84e9bf1825fa 100644 --- a/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c +++ b/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c @@ -437,9 +437,11 @@ static int gmin_i2c_write(struct device *dev, u16 i2c_addr, u8 reg, return ret; } +static struct i2c_client *power; + static struct gmin_subdev *gmin_subdev_add(struct v4l2_subdev *subdev) { - struct i2c_client *power = NULL, *client = v4l2_get_subdevdata(subdev); + struct i2c_client *client = v4l2_get_subdevdata(subdev); struct acpi_device *adev; acpi_handle handle; struct device *dev; @@ -570,7 +572,6 @@ static struct gmin_subdev *gmin_subdev_add(struct v4l2_subdev *subdev) gmin_subdevs[i].eldo2_ctrl_shift = gmin_get_var_int(dev, false, "eldo2_ctrl_shift", ELDO2_CTRL_SHIFT); - gmin_subdevs[i].pwm_i2c_addr = power->addr; break; default: From patchwork Fri Jun 26 12:19:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 209269 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9C8F2C433E0 for ; Fri, 26 Jun 2020 12:19:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8774B21531 for ; Fri, 26 Jun 2020 12:19:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728332AbgFZMTh (ORCPT ); Fri, 26 Jun 2020 08:19:37 -0400 Received: from mga04.intel.com ([192.55.52.120]:5321 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728286AbgFZMTf (ORCPT ); Fri, 26 Jun 2020 08:19:35 -0400 IronPort-SDR: luEhe9tSXnl2M9cr15qoNVvjQOxYx8chLtdpz5lpdgRNFYqhxFSGzyUuGbOuQQvz4WFGG844AM iuxrWEu6LtPA== X-IronPort-AV: E=McAfee;i="6000,8403,9663"; a="142816236" X-IronPort-AV: E=Sophos;i="5.75,283,1589266800"; d="scan'208";a="142816236" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Jun 2020 05:19:32 -0700 IronPort-SDR: mDqiNU+W9JSyolTx0VzKUu5ZVmo43aDx4oD58Mhfyz7PKz2erpcfU5TbwYMp0lyfnfJpMMEw+a CKkYqdP0Sv1w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,283,1589266800"; d="scan'208";a="302324056" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga004.fm.intel.com with ESMTP; 26 Jun 2020 05:19:31 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 8A64F6C3; Fri, 26 Jun 2020 15:19:28 +0300 (EEST) From: Andy Shevchenko To: Mauro Carvalho Chehab , linux-media@vger.kernel.org, Sakari Ailus Cc: Andy Shevchenko Subject: [PATCH v2 13/15] media: atomisp: Provide Gmin subdev as parameter to gmin_subdev_add() Date: Fri, 26 Jun 2020 15:19:23 +0300 Message-Id: <20200626121925.14365-14-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200626121925.14365-1-andriy.shevchenko@linux.intel.com> References: <20200626121925.14365-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Provide Gmin subdev as parameter to gmin_subdev_add() to avoid direct global variable usage. Signed-off-by: Andy Shevchenko --- .../media/atomisp/pci/atomisp_gmin_platform.c | 104 ++++++++---------- 1 file changed, 46 insertions(+), 58 deletions(-) diff --git a/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c b/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c index 26f200b1ed6d..d0b9d906a563 100644 --- a/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c +++ b/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c @@ -459,13 +459,13 @@ static int gmin_pmic_detect(struct v4l2_subdev *subdev) return pmic_id; } -static struct gmin_subdev *gmin_subdev_add(struct v4l2_subdev *subdev) +static struct gmin_subdev *gmin_subdev_add(struct v4l2_subdev *subdev, struct gmin_subdev *gdev) { struct i2c_client *client = v4l2_get_subdevdata(subdev); struct device *dev = &client->dev; struct acpi_device *adev; acpi_handle handle; - int i, ret; + int ret; handle = ACPI_HANDLE(dev); @@ -478,13 +478,8 @@ static struct gmin_subdev *gmin_subdev_add(struct v4l2_subdev *subdev) dev_info(&client->dev, "%s: ACPI detected it on bus ID=%s, HID=%s\n", __func__, acpi_device_bid(adev), acpi_device_hid(adev)); - for (i = 0; i < MAX_SUBDEVS && gmin_subdevs[i].subdev; i++) - ; - if (i >= MAX_SUBDEVS) - return NULL; - if (power) { - gmin_subdevs[i].pwm_i2c_addr = power->addr; + gdev->pwm_i2c_addr = power->addr; dev_info(dev, "gmin: power management provided via %s (i2c addr 0x%02x)\n", pmic_name[pmic_id], power->addr); @@ -493,28 +488,21 @@ static struct gmin_subdev *gmin_subdev_add(struct v4l2_subdev *subdev) pmic_name[pmic_id]); } - gmin_subdevs[i].subdev = subdev; - gmin_subdevs[i].clock_num = gmin_get_var_int(dev, false, "CamClk", 0); + gdev->subdev = subdev; + gdev->clock_num = gmin_get_var_int(dev, false, "CamClk", 0); /*WA:CHT requires XTAL clock as PLL is not stable.*/ - gmin_subdevs[i].clock_src = gmin_get_var_int(dev, false, "ClkSrc", - VLV2_CLK_PLL_19P2MHZ); - gmin_subdevs[i].csi_port = gmin_get_var_int(dev, false, "CsiPort", 0); - gmin_subdevs[i].csi_lanes = gmin_get_var_int(dev, false, "CsiLanes", 1); + gdev->clock_src = gmin_get_var_int(dev, false, "ClkSrc", VLV2_CLK_PLL_19P2MHZ); + gdev->csi_port = gmin_get_var_int(dev, false, "CsiPort", 0); + gdev->csi_lanes = gmin_get_var_int(dev, false, "CsiLanes", 1); /* get PMC clock with clock framework */ - snprintf(gmin_pmc_clk_name, - sizeof(gmin_pmc_clk_name), - "%s_%d", "pmc_plt_clk", gmin_subdevs[i].clock_num); - - gmin_subdevs[i].pmc_clk = devm_clk_get(dev, gmin_pmc_clk_name); - if (IS_ERR(gmin_subdevs[i].pmc_clk)) { - ret = PTR_ERR(gmin_subdevs[i].pmc_clk); - - dev_err(dev, - "Failed to get clk from %s : %d\n", - gmin_pmc_clk_name, - ret); + snprintf(gmin_pmc_clk_name, sizeof(gmin_pmc_clk_name), + "pmc_plt_clk_%d", gdev->clock_num); + gdev->pmc_clk = devm_clk_get(dev, gmin_pmc_clk_name); + if (IS_ERR(gdev->pmc_clk)) { + ret = PTR_ERR(gdev->pmc_clk); + dev_err(dev, "Failed to get clk from %s: %d\n", gmin_pmc_clk_name, ret); return NULL; } @@ -528,25 +516,25 @@ static struct gmin_subdev *gmin_subdev_add(struct v4l2_subdev *subdev) * to disable a clock that has not been enabled, * we need to enable the clock first. */ - ret = clk_prepare_enable(gmin_subdevs[i].pmc_clk); + ret = clk_prepare_enable(gdev->pmc_clk); if (!ret) - clk_disable_unprepare(gmin_subdevs[i].pmc_clk); + clk_disable_unprepare(gdev->pmc_clk); - gmin_subdevs[i].gpio0 = gpiod_get_index(dev, NULL, 0, GPIOD_OUT_LOW); - if (IS_ERR(gmin_subdevs[i].gpio0)) - gmin_subdevs[i].gpio0 = NULL; + gdev->gpio0 = gpiod_get_index(dev, NULL, 0, GPIOD_OUT_LOW); + if (IS_ERR(gdev->gpio0)) + gdev->gpio0 = NULL; - gmin_subdevs[i].gpio1 = gpiod_get_index(dev, NULL, 1, GPIOD_OUT_LOW); - if (IS_ERR(gmin_subdevs[i].gpio1)) - gmin_subdevs[i].gpio1 = NULL; + gdev->gpio1 = gpiod_get_index(dev, NULL, 1, GPIOD_OUT_LOW); + if (IS_ERR(gdev->gpio1)) + gdev->gpio1 = NULL; switch (pmic_id) { case PMIC_REGULATOR: - gmin_subdevs[i].v1p8_reg = regulator_get(dev, "V1P8SX"); - gmin_subdevs[i].v2p8_reg = regulator_get(dev, "V2P8SX"); + gdev->v1p8_reg = regulator_get(dev, "V1P8SX"); + gdev->v2p8_reg = regulator_get(dev, "V2P8SX"); - gmin_subdevs[i].v1p2_reg = regulator_get(dev, "V1P2A"); - gmin_subdevs[i].v2p8_vcm_reg = regulator_get(dev, "VPROG4B"); + gdev->v1p2_reg = regulator_get(dev, "V1P2A"); + gdev->v2p8_vcm_reg = regulator_get(dev, "VPROG4B"); /* Note: ideally we would initialize v[12]p8_on to the * output of regulator_is_enabled(), but sadly that @@ -558,31 +546,25 @@ static struct gmin_subdev *gmin_subdev_add(struct v4l2_subdev *subdev) break; case PMIC_AXP: - gmin_subdevs[i].eldo1_1p8v = gmin_get_var_int(dev, false, - "eldo1_1p8v", - ELDO1_1P8V); - gmin_subdevs[i].eldo1_sel_reg = gmin_get_var_int(dev, false, - "eldo1_sel_reg", - ELDO1_SEL_REG); - gmin_subdevs[i].eldo1_ctrl_shift = gmin_get_var_int(dev, false, - "eldo1_ctrl_shift", - ELDO1_CTRL_SHIFT); - gmin_subdevs[i].eldo2_1p8v = gmin_get_var_int(dev, false, - "eldo2_1p8v", - ELDO2_1P8V); - gmin_subdevs[i].eldo2_sel_reg = gmin_get_var_int(dev, false, - "eldo2_sel_reg", - ELDO2_SEL_REG); - gmin_subdevs[i].eldo2_ctrl_shift = gmin_get_var_int(dev, false, - "eldo2_ctrl_shift", - ELDO2_CTRL_SHIFT); + gdev->eldo1_1p8v = gmin_get_var_int(dev, false, "eldo1_1p8v", + ELDO1_1P8V); + gdev->eldo1_sel_reg = gmin_get_var_int(dev, false, "eldo1_sel_reg", + ELDO1_SEL_REG); + gdev->eldo1_ctrl_shift = gmin_get_var_int(dev, false, "eldo1_ctrl_shift", + ELDO1_CTRL_SHIFT); + gdev->eldo2_1p8v = gmin_get_var_int(dev, false, "eldo2_1p8v", + ELDO2_1P8V); + gdev->eldo2_sel_reg = gmin_get_var_int(dev, false, "eldo2_sel_reg", + ELDO2_SEL_REG); + gdev->eldo2_ctrl_shift = gmin_get_var_int(dev, false, "eldo2_ctrl_shift", + ELDO2_CTRL_SHIFT); break; default: break; } - return &gmin_subdevs[i]; + return gdev; } static struct gmin_subdev *find_gmin_subdev(struct v4l2_subdev *subdev) @@ -593,8 +575,14 @@ static struct gmin_subdev *find_gmin_subdev(struct v4l2_subdev *subdev) if (gmin_subdevs[i].subdev == subdev) return &gmin_subdevs[i]; + for (i = 0; i < MAX_SUBDEVS; i++) + if (gmin_subdevs[i].subdev == NULL) + break; + if (i == MAX_SUBDEVS) + return NULL; + gmin_pmic_detect(subdev); - return gmin_subdev_add(subdev); + return gmin_subdev_add(subdev, &gmin_subdevs[i]); } static int axp_regulator_set(struct device *dev, struct gmin_subdev *gs, From patchwork Fri Jun 26 12:19:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 209268 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B40B9C433E2 for ; Fri, 26 Jun 2020 12:19:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9DA2F214D8 for ; Fri, 26 Jun 2020 12:19:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728328AbgFZMTg (ORCPT ); Fri, 26 Jun 2020 08:19:36 -0400 Received: from mga11.intel.com ([192.55.52.93]:29757 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728278AbgFZMTe (ORCPT ); Fri, 26 Jun 2020 08:19:34 -0400 IronPort-SDR: hafgQrP4kzrJwaU02V/1Yb4FyCZFduWVHxvGl+mVAKvBgQ6Aredz0+bgyyU/WBqsvOs6DbvJx3 f3qug9oeFXaA== X-IronPort-AV: E=McAfee;i="6000,8403,9663"; a="143544877" X-IronPort-AV: E=Sophos;i="5.75,283,1589266800"; d="scan'208";a="143544877" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Jun 2020 05:19:32 -0700 IronPort-SDR: 4uUnVZCa7B1kT2xvja5xo+9lPWEPB19TW2j3xKQX3Q7a+7KC2wO9oY38Avmsqlpg9TKOUADI2t Cisr1/3nW3bg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,283,1589266800"; d="scan'208";a="312306792" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga002.fm.intel.com with ESMTP; 26 Jun 2020 05:19:31 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 8FCB86B9; Fri, 26 Jun 2020 15:19:28 +0300 (EEST) From: Andy Shevchenko To: Mauro Carvalho Chehab , linux-media@vger.kernel.org, Sakari Ailus Cc: Andy Shevchenko Subject: [PATCH v2 14/15] media: atomisp: Get rid of ugly and leaky ACPI handling in gmin_subdev_add() Date: Fri, 26 Jun 2020 15:19:24 +0300 Message-Id: <20200626121925.14365-15-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200626121925.14365-1-andriy.shevchenko@linux.intel.com> References: <20200626121925.14365-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org First of all ACPI HID is a part of the device name which is printed as a part of the dev_info(dev, ...); line. Second, since the only BID is left, it's a part of ACPI path, which can be printed via %pfw. Get rid of ugly and leaky ACPI handling in gmin_subdev_add() by replacing it with %pfw. Signed-off-by: Andy Shevchenko --- .../media/atomisp/pci/atomisp_gmin_platform.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c b/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c index d0b9d906a563..7f9e93a9a4b1 100644 --- a/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c +++ b/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c @@ -463,20 +463,9 @@ static struct gmin_subdev *gmin_subdev_add(struct v4l2_subdev *subdev, struct gm { struct i2c_client *client = v4l2_get_subdevdata(subdev); struct device *dev = &client->dev; - struct acpi_device *adev; - acpi_handle handle; int ret; - handle = ACPI_HANDLE(dev); - - // FIXME: may need to release resources allocated by acpi_bus_get_device() - if (!handle || acpi_bus_get_device(handle, &adev)) { - dev_err(dev, "Error could not get ACPI device\n"); - return NULL; - } - - dev_info(&client->dev, "%s: ACPI detected it on bus ID=%s, HID=%s\n", - __func__, acpi_device_bid(adev), acpi_device_hid(adev)); + dev_info(&client->dev, "%s: ACPI path is %pfw\n", __func__, dev_fwnode(dev)); if (power) { gdev->pwm_i2c_addr = power->addr; From patchwork Fri Jun 26 12:19:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 209266 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9639CC433E0 for ; Fri, 26 Jun 2020 12:19:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 81218207D8 for ; Fri, 26 Jun 2020 12:19:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728367AbgFZMTt (ORCPT ); Fri, 26 Jun 2020 08:19:49 -0400 Received: from mga11.intel.com ([192.55.52.93]:29764 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728354AbgFZMTt (ORCPT ); Fri, 26 Jun 2020 08:19:49 -0400 IronPort-SDR: +jKEjxHBRXleA+op/a9FZl2BoPnHJCAQSDNnBW5vjvdeFcnTej5mbqhDD0fvhRsdbkGjcmsNnF 5j8FKrxUWuag== X-IronPort-AV: E=McAfee;i="6000,8403,9663"; a="143544892" X-IronPort-AV: E=Sophos;i="5.75,283,1589266800"; d="scan'208";a="143544892" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Jun 2020 05:19:34 -0700 IronPort-SDR: NOud4+RQuRtxPTdBCGDmx+V9evZ3iB8328AgJIHOWMLypYSsnKPfXsDSy2JBK9478mm9IOv5vM UPzV0st1OkTA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,283,1589266800"; d="scan'208";a="312306796" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga002.fm.intel.com with ESMTP; 26 Jun 2020 05:19:33 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 9EB81710; Fri, 26 Jun 2020 15:19:28 +0300 (EEST) From: Andy Shevchenko To: Mauro Carvalho Chehab , linux-media@vger.kernel.org, Sakari Ailus Cc: Andy Shevchenko Subject: [PATCH v2 15/15] media: atomisp: Deduplicate return ret in gmin_i2c_write() Date: Fri, 26 Jun 2020 15:19:25 +0300 Message-Id: <20200626121925.14365-16-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200626121925.14365-1-andriy.shevchenko@linux.intel.com> References: <20200626121925.14365-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Deduplicate return ret in gmin_i2c_write(). While here, replace 'Kernel' by 'kernel' in the message and reduce amount of LOCs. Signed-off-by: Andy Shevchenko --- .../staging/media/atomisp/pci/atomisp_gmin_platform.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c b/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c index 7f9e93a9a4b1..11437161ef20 100644 --- a/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c +++ b/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c @@ -423,16 +423,12 @@ static int gmin_i2c_write(struct device *dev, u16 i2c_addr, u8 reg, "I2C write, addr: 0x%02x, reg: 0x%02x, value: 0x%02x, mask: 0x%02x\n", i2c_addr, reg, value, mask); - ret = intel_soc_pmic_exec_mipi_pmic_seq_element(i2c_addr, reg, - value, mask); - - if (ret == -EOPNOTSUPP) { + ret = intel_soc_pmic_exec_mipi_pmic_seq_element(i2c_addr, reg, value, mask); + if (ret == -EOPNOTSUPP) dev_err(dev, "ACPI didn't mapped the OpRegion needed to access I2C address 0x%02x.\n" - "Need to compile the Kernel using CONFIG_*_PMIC_OPREGION settings\n", + "Need to compile the kernel using CONFIG_*_PMIC_OPREGION settings\n", i2c_addr); - return ret; - } return ret; }