Message ID | 20220730154844.89556-1-andriy.shevchenko@linux.intel.com (mailing list archive) |
---|---|
State | Superseded |
Headers |
Received: from vger.kernel.org ([23.128.96.18]) by www.linuxtv.org with esmtp (Exim 4.92) (envelope-from <linux-media-owner@vger.kernel.org>) id 1oHohr-00EW0c-2D; Sat, 30 Jul 2022 15:48:47 +0000 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234991AbiG3Psl (ORCPT <rfc822;mkrufky@linuxtv.org> + 1 other); Sat, 30 Jul 2022 11:48:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60848 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232125AbiG3Psk (ORCPT <rfc822;linux-media@vger.kernel.org>); Sat, 30 Jul 2022 11:48:40 -0400 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7A43915836; Sat, 30 Jul 2022 08:48:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1659196119; x=1690732119; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=/lkRKIKf5NUPYe0Arklh0YQ8Fp95nZE0357TMlZXoCw=; b=D0YmyrevmNFfNisdSPANV9FT8GbkmVVhaAQYhRBBtEgRxF8ViBQM/DXk nHDrK1p6VTrp+XNjuNy8rG4MqLFuB7J3mpTqt0eDeiY6/bB7Q524oBB8F wuCLxVlVhXyJgr1nAwfCF78YccaPzoNjrHCnCuCObgtDv6ghZQJ61pARl 0vwfm9CuB/+opiX5SC14zaS64T4jCvPRZt7jagQf74HS1uTNfMrptPQhO g+v//YTuzxMKBJUAXOlp9N6a8XAoK3RXso0848uJzDQjR2RSfH0hli3KQ NH8+8YUYj8mJPXM07lnD0yymNwhUv96/d7Z+pSvNm8jf57r1RefzqMYOJ w==; X-IronPort-AV: E=McAfee;i="6400,9594,10424"; a="289695187" X-IronPort-AV: E=Sophos;i="5.93,204,1654585200"; d="scan'208";a="289695187" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Jul 2022 08:48:39 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,204,1654585200"; d="scan'208";a="660611414" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga008.fm.intel.com with ESMTP; 30 Jul 2022 08:48:36 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id E3A03F1; Sat, 30 Jul 2022 18:48:46 +0300 (EEST) From: Andy Shevchenko <andriy.shevchenko@linux.intel.com> To: Sakari Ailus <sakari.ailus@linux.intel.com>, Mauro Carvalho Chehab <mchehab@kernel.org>, linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Yong Zhi <yong.zhi@intel.com>, Bingbu Cao <bingbu.cao@intel.com>, Dan Scally <djrscally@gmail.com>, Tianshu Qiu <tian.shu.qiu@intel.com>, Andy Shevchenko <andriy.shevchenko@linux.intel.com> Subject: [PATCH v1 1/1] media: ipu3-cio2: Don't dereference fwnode handle Date: Sat, 30 Jul 2022 18:48:44 +0300 Message-Id: <20220730154844.89556-1-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.9 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-media.vger.kernel.org> X-Mailing-List: linux-media@vger.kernel.org X-LSpam-Score: -2.4 (--) X-LSpam-Report: No, score=-2.4 required=5.0 tests=BAYES_00=-1.9,DKIMWL_WL_HIGH=0.001,DKIM_SIGNED=0.1,DKIM_VALID=-0.1,HEADER_FROM_DIFFERENT_DOMAINS=0.5,MAILING_LIST_MULTI=-1 autolearn=ham autolearn_force=no |
Series |
[v1,1/1] media: ipu3-cio2: Don't dereference fwnode handle
|
|
Commit Message
Andy Shevchenko
July 30, 2022, 3:48 p.m. UTC
Use acpi_fwnode_handle() instead of dereferencing an fwnode handle directly,
which is a better coding practice.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/media/pci/intel/ipu3/cio2-bridge.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
Comments
Hi Andy, I love your patch! Yet something to improve: [auto build test ERROR on media-tree/master] [also build test ERROR on linus/master v5.19-rc8 next-20220728] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/Andy-Shevchenko/media-ipu3-cio2-Don-t-dereference-fwnode-handle/20220730-235023 base: git://linuxtv.org/media_tree.git master config: x86_64-randconfig-a012 (https://download.01.org/0day-ci/archive/20220731/202207310216.JtYAKodB-lkp@intel.com/config) compiler: clang version 16.0.0 (https://github.com/llvm/llvm-project 52cd00cabf479aa7eb6dbb063b7ba41ea57bce9e) reproduce (this is a W=1 build): wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # https://github.com/intel-lab-lkp/linux/commit/a78ba0da9d77a8fa412604492f931b188e1114d5 git remote add linux-review https://github.com/intel-lab-lkp/linux git fetch --no-tags linux-review Andy-Shevchenko/media-ipu3-cio2-Don-t-dereference-fwnode-handle/20220730-235023 git checkout a78ba0da9d77a8fa412604492f931b188e1114d5 # save the config file mkdir build_dir && cp config build_dir/.config COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bash drivers/media/pci/intel/ipu3/ If you fix the issue, kindly add following tag where applicable Reported-by: kernel test robot <lkp@intel.com> All errors (new ones prefixed by >>): >> drivers/media/pci/intel/ipu3/cio2-bridge.c:266:33: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes] struct fwnode_handle *fwnode, *current; ^ arch/x86/include/asm/current.h:18:28: note: expanded from macro 'current' #define current get_current() ^ >> drivers/media/pci/intel/ipu3/cio2-bridge.c:266:33: error: conflicting types for 'get_current' arch/x86/include/asm/current.h:18:17: note: expanded from macro 'current' #define current get_current() ^ arch/x86/include/asm/current.h:13:44: note: previous definition is here static __always_inline struct task_struct *get_current(void) ^ 2 errors generated. vim +266 drivers/media/pci/intel/ipu3/cio2-bridge.c 261 262 static int cio2_bridge_connect_sensor(const struct cio2_sensor_config *cfg, 263 struct cio2_bridge *bridge, 264 struct pci_dev *cio2) 265 { > 266 struct fwnode_handle *fwnode, *current; 267 struct cio2_sensor *sensor; 268 struct acpi_device *adev; 269 acpi_status status; 270 int ret; 271 272 for_each_acpi_dev_match(adev, cfg->hid, NULL, -1) { 273 if (!adev->status.enabled) 274 continue; 275 276 if (bridge->n_sensors >= CIO2_NUM_PORTS) { 277 acpi_dev_put(adev); 278 dev_err(&cio2->dev, "Exceeded available CIO2 ports\n"); 279 return -EINVAL; 280 } 281 282 sensor = &bridge->sensors[bridge->n_sensors]; 283 strscpy(sensor->name, cfg->hid, sizeof(sensor->name)); 284 285 ret = cio2_bridge_read_acpi_buffer(adev, "SSDB", 286 &sensor->ssdb, 287 sizeof(sensor->ssdb)); 288 if (ret) 289 goto err_put_adev; 290 291 if (sensor->ssdb.vcmtype > ARRAY_SIZE(cio2_vcm_types)) { 292 dev_warn(&adev->dev, "Unknown VCM type %d\n", 293 sensor->ssdb.vcmtype); 294 sensor->ssdb.vcmtype = 0; 295 } 296 297 status = acpi_get_physical_device_location(adev->handle, &sensor->pld); 298 if (ACPI_FAILURE(status)) { 299 ret = -ENODEV; 300 goto err_put_adev; 301 } 302 303 if (sensor->ssdb.lanes > CIO2_MAX_LANES) { 304 dev_err(&adev->dev, 305 "Number of lanes in SSDB is invalid\n"); 306 ret = -EINVAL; 307 goto err_free_pld; 308 } 309 310 cio2_bridge_create_fwnode_properties(sensor, bridge, cfg); 311 cio2_bridge_create_connection_swnodes(bridge, sensor); 312 313 ret = software_node_register_nodes(sensor->swnodes); 314 if (ret) 315 goto err_free_pld; 316 317 fwnode = software_node_fwnode(&sensor->swnodes[ 318 SWNODE_SENSOR_HID]); 319 if (!fwnode) { 320 ret = -ENODEV; 321 goto err_free_swnodes; 322 } 323 324 sensor->adev = acpi_dev_get(adev); 325 326 current = acpi_fwnode_handle(adev); 327 current->secondary = fwnode; 328 329 cio2_bridge_instantiate_vcm_i2c_client(sensor); 330 331 dev_info(&cio2->dev, "Found supported sensor %s\n", 332 acpi_dev_name(adev)); 333 334 bridge->n_sensors++; 335 } 336 337 return 0; 338 339 err_free_swnodes: 340 software_node_unregister_nodes(sensor->swnodes); 341 err_free_pld: 342 ACPI_FREE(sensor->pld); 343 err_put_adev: 344 acpi_dev_put(adev); 345 return ret; 346 } 347
Hi Andy, I love your patch! Yet something to improve: [auto build test ERROR on media-tree/master] [also build test ERROR on linus/master v5.19-rc8 next-20220728] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/Andy-Shevchenko/media-ipu3-cio2-Don-t-dereference-fwnode-handle/20220730-235023 base: git://linuxtv.org/media_tree.git master config: i386-allyesconfig (https://download.01.org/0day-ci/archive/20220731/202207310535.kgjPgg86-lkp@intel.com/config) compiler: gcc-11 (Debian 11.3.0-3) 11.3.0 reproduce (this is a W=1 build): # https://github.com/intel-lab-lkp/linux/commit/a78ba0da9d77a8fa412604492f931b188e1114d5 git remote add linux-review https://github.com/intel-lab-lkp/linux git fetch --no-tags linux-review Andy-Shevchenko/media-ipu3-cio2-Don-t-dereference-fwnode-handle/20220730-235023 git checkout a78ba0da9d77a8fa412604492f931b188e1114d5 # save the config file mkdir build_dir && cp config build_dir/.config make W=1 O=build_dir ARCH=i386 SHELL=/bin/bash If you fix the issue, kindly add following tag where applicable Reported-by: kernel test robot <lkp@intel.com> All errors (new ones prefixed by >>): drivers/media/pci/intel/ipu3/cio2-bridge.c: In function 'cio2_bridge_connect_sensor': >> drivers/media/pci/intel/ipu3/cio2-bridge.c:266:16: error: function declaration isn't a prototype [-Werror=strict-prototypes] 266 | struct fwnode_handle *fwnode, *current; | ^~~~~~~~~~~~~ In file included from include/linux/mutex.h:14, from include/linux/kernfs.h:11, from include/linux/sysfs.h:16, from include/linux/kobject.h:20, from include/linux/of.h:17, from include/linux/irqdomain.h:35, from include/linux/acpi.h:13, from drivers/media/pci/intel/ipu3/cio2-bridge.c:4: >> arch/x86/include/asm/current.h:18:17: error: conflicting types for 'get_current'; have 'struct fwnode_handle *()' 18 | #define current get_current() | ^~~~~~~~~~~ drivers/media/pci/intel/ipu3/cio2-bridge.c:266:40: note: in expansion of macro 'current' 266 | struct fwnode_handle *fwnode, *current; | ^~~~~~~ arch/x86/include/asm/current.h:13:44: note: previous definition of 'get_current' with type 'struct task_struct *(void)' 13 | static __always_inline struct task_struct *get_current(void) | ^~~~~~~~~~~ >> drivers/media/pci/intel/ipu3/cio2-bridge.c:326:25: error: lvalue required as left operand of assignment 326 | current = acpi_fwnode_handle(adev); | ^ cc1: some warnings being treated as errors vim +266 drivers/media/pci/intel/ipu3/cio2-bridge.c 261 262 static int cio2_bridge_connect_sensor(const struct cio2_sensor_config *cfg, 263 struct cio2_bridge *bridge, 264 struct pci_dev *cio2) 265 { > 266 struct fwnode_handle *fwnode, *current; 267 struct cio2_sensor *sensor; 268 struct acpi_device *adev; 269 acpi_status status; 270 int ret; 271 272 for_each_acpi_dev_match(adev, cfg->hid, NULL, -1) { 273 if (!adev->status.enabled) 274 continue; 275 276 if (bridge->n_sensors >= CIO2_NUM_PORTS) { 277 acpi_dev_put(adev); 278 dev_err(&cio2->dev, "Exceeded available CIO2 ports\n"); 279 return -EINVAL; 280 } 281 282 sensor = &bridge->sensors[bridge->n_sensors]; 283 strscpy(sensor->name, cfg->hid, sizeof(sensor->name)); 284 285 ret = cio2_bridge_read_acpi_buffer(adev, "SSDB", 286 &sensor->ssdb, 287 sizeof(sensor->ssdb)); 288 if (ret) 289 goto err_put_adev; 290 291 if (sensor->ssdb.vcmtype > ARRAY_SIZE(cio2_vcm_types)) { 292 dev_warn(&adev->dev, "Unknown VCM type %d\n", 293 sensor->ssdb.vcmtype); 294 sensor->ssdb.vcmtype = 0; 295 } 296 297 status = acpi_get_physical_device_location(adev->handle, &sensor->pld); 298 if (ACPI_FAILURE(status)) { 299 ret = -ENODEV; 300 goto err_put_adev; 301 } 302 303 if (sensor->ssdb.lanes > CIO2_MAX_LANES) { 304 dev_err(&adev->dev, 305 "Number of lanes in SSDB is invalid\n"); 306 ret = -EINVAL; 307 goto err_free_pld; 308 } 309 310 cio2_bridge_create_fwnode_properties(sensor, bridge, cfg); 311 cio2_bridge_create_connection_swnodes(bridge, sensor); 312 313 ret = software_node_register_nodes(sensor->swnodes); 314 if (ret) 315 goto err_free_pld; 316 317 fwnode = software_node_fwnode(&sensor->swnodes[ 318 SWNODE_SENSOR_HID]); 319 if (!fwnode) { 320 ret = -ENODEV; 321 goto err_free_swnodes; 322 } 323 324 sensor->adev = acpi_dev_get(adev); 325 > 326 current = acpi_fwnode_handle(adev); 327 current->secondary = fwnode; 328 329 cio2_bridge_instantiate_vcm_i2c_client(sensor); 330 331 dev_info(&cio2->dev, "Found supported sensor %s\n", 332 acpi_dev_name(adev)); 333 334 bridge->n_sensors++; 335 } 336 337 return 0; 338 339 err_free_swnodes: 340 software_node_unregister_nodes(sensor->swnodes); 341 err_free_pld: 342 ACPI_FREE(sensor->pld); 343 err_put_adev: 344 acpi_dev_put(adev); 345 return ret; 346 } 347
diff --git a/drivers/media/pci/intel/ipu3/cio2-bridge.c b/drivers/media/pci/intel/ipu3/cio2-bridge.c index df6c94da2f6a..5998541d331c 100644 --- a/drivers/media/pci/intel/ipu3/cio2-bridge.c +++ b/drivers/media/pci/intel/ipu3/cio2-bridge.c @@ -263,7 +263,7 @@ static int cio2_bridge_connect_sensor(const struct cio2_sensor_config *cfg, struct cio2_bridge *bridge, struct pci_dev *cio2) { - struct fwnode_handle *fwnode; + struct fwnode_handle *fwnode, *current; struct cio2_sensor *sensor; struct acpi_device *adev; acpi_status status; @@ -322,7 +322,9 @@ static int cio2_bridge_connect_sensor(const struct cio2_sensor_config *cfg, } sensor->adev = acpi_dev_get(adev); - adev->fwnode.secondary = fwnode; + + current = acpi_fwnode_handle(adev); + current->secondary = fwnode; cio2_bridge_instantiate_vcm_i2c_client(sensor);