From patchwork Wed Aug 31 14:15:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 12960800 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2DBC6C3DA6B for ; Wed, 31 Aug 2022 14:16:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232283AbiHaOQ5 (ORCPT ); Wed, 31 Aug 2022 10:16:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34104 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231917AbiHaOQX (ORCPT ); Wed, 31 Aug 2022 10:16:23 -0400 Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CF37213E39; Wed, 31 Aug 2022 07:16:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1661955370; x=1693491370; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=3z0W0t1tvmSgzUHxrVOKoN4a/HoQR38NwihBSGthIa0=; b=MwIMuZvX8ItROqCyc0vm8Bdi5hah+ircZe4AvTJSS3MI0k1DKirirI6s lemDYW/yi7pZwtdxf5CYnKyGDVJ20dfNDqro8ecXeRjg7U4NvPmTS5n64 LG08n9TAq2cenHUNyH3/D//X97uEiYJb8QRkKPWdQFugrpsdkjjPZs5aR a1Up6G94JiP3ikttr1v9D8eEx9sTQHuU/E/r48JUQjL2e7tpYDqN4vtjJ hWGSEh/fmEZ6Q0de0K3eFFgqB+q8n3tVbiMVrSMelJTM0YCdcV4GldpGx HHO7DxXuZb7ceGYkVQ+oV2MbiTkuhSNu75CV3vjBadzy/19gnB7K+iRdF A==; X-IronPort-AV: E=McAfee;i="6500,9779,10456"; a="275858245" X-IronPort-AV: E=Sophos;i="5.93,278,1654585200"; d="scan'208";a="275858245" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Aug 2022 07:15:19 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,278,1654585200"; d="scan'208";a="614980982" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga007.fm.intel.com with ESMTP; 31 Aug 2022 07:15:17 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id AF371174; Wed, 31 Aug 2022 17:15:32 +0300 (EEST) From: Andy Shevchenko To: Jonathan Cameron , Andy Shevchenko , Linus Walleij , Jakob Hauser , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Jonathan Cameron , Lars-Peter Clausen Subject: [PATCH v2 1/3] iio: magnetometer: yamaha-yas530: Use pointers as driver data Date: Wed, 31 Aug 2022 17:15:28 +0300 Message-Id: <20220831141530.80572-1-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org Unify ID tables to use pointers for driver data. It will allow to simplify the driver later on. Signed-off-by: Andy Shevchenko --- v2: left ID fallback in place (Jonathan) drivers/iio/magnetometer/yamaha-yas530.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/drivers/iio/magnetometer/yamaha-yas530.c b/drivers/iio/magnetometer/yamaha-yas530.c index 026f71e524f3..58f527cfde07 100644 --- a/drivers/iio/magnetometer/yamaha-yas530.c +++ b/drivers/iio/magnetometer/yamaha-yas530.c @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include @@ -1437,8 +1438,10 @@ static int yas5xx_probe(struct i2c_client *i2c, goto assert_reset; } - yas5xx->chip_info = &yas5xx_chip_info_tbl[id->driver_data]; - ci = yas5xx->chip_info; + ci = device_get_match_data(dev); + if (!ci) + ci = (const struct yas5xx_chip_info *)id->driver_data; + yas5xx->chip_info = ci; ret = regmap_read(yas5xx->map, YAS5XX_DEVICE_ID, &id_check); if (ret) @@ -1583,19 +1586,19 @@ static DEFINE_RUNTIME_DEV_PM_OPS(yas5xx_dev_pm_ops, yas5xx_runtime_suspend, yas5xx_runtime_resume, NULL); static const struct i2c_device_id yas5xx_id[] = { - {"yas530", yas530 }, - {"yas532", yas532 }, - {"yas533", yas533 }, - {"yas537", yas537 }, + {"yas530", (kernel_ulong_t)&yas5xx_chip_info_tbl[yas530] }, + {"yas532", (kernel_ulong_t)&yas5xx_chip_info_tbl[yas532] }, + {"yas533", (kernel_ulong_t)&yas5xx_chip_info_tbl[yas533] }, + {"yas537", (kernel_ulong_t)&yas5xx_chip_info_tbl[yas537] }, {} }; MODULE_DEVICE_TABLE(i2c, yas5xx_id); static const struct of_device_id yas5xx_of_match[] = { - { .compatible = "yamaha,yas530", }, - { .compatible = "yamaha,yas532", }, - { .compatible = "yamaha,yas533", }, - { .compatible = "yamaha,yas537", }, + { .compatible = "yamaha,yas530", &yas5xx_chip_info_tbl[yas530] }, + { .compatible = "yamaha,yas532", &yas5xx_chip_info_tbl[yas532] }, + { .compatible = "yamaha,yas533", &yas5xx_chip_info_tbl[yas533] }, + { .compatible = "yamaha,yas537", &yas5xx_chip_info_tbl[yas537] }, {} }; MODULE_DEVICE_TABLE(of, yas5xx_of_match); From patchwork Wed Aug 31 14:15:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 12960799 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 473ECC54EE9 for ; Wed, 31 Aug 2022 14:16:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232148AbiHaOQX (ORCPT ); Wed, 31 Aug 2022 10:16:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59300 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232112AbiHaOP7 (ORCPT ); Wed, 31 Aug 2022 10:15:59 -0400 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 75B405F103; Wed, 31 Aug 2022 07:15:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1661955322; x=1693491322; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=cTT/KqVlDmHBzjaZlDZPkQW4EK0I9w1vtnHk+yiXkv0=; b=Kln22zzwi/xjJgKRu/CDdzY2By3pTFpB6VzOLrSMOo/FzTwAk2xE2zdl cAEmOJ39a5VBWw3noCu1NCzMGSYVoyjB0i4JQRE5jyXqST6x6wABAK0FF m7XHTk/XAsfhQFsgTaSTGdAm7XehGVV4+KypCuNiuwHBYeb6JQCwf1wof ebcRtuSGxn00r5rBc1Syvcsy4TNy0RLlk9KRX4zRmfjO8RDz4GxNvFF2N UlYX1UJgELoa/5iTGgD1VFNksajnRc8LMCtYuSbPJxtQZOHiJjvxPSc7s jhSP2oVlHrxunnFmq7ITcLX173Af5i8cuupMVcG3LBuMtiQGRdXLXrtsD w==; X-IronPort-AV: E=McAfee;i="6500,9779,10456"; a="381752743" X-IronPort-AV: E=Sophos;i="5.93,278,1654585200"; d="scan'208";a="381752743" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Aug 2022 07:15:20 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,278,1654585200"; d="scan'208";a="641885629" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga008.jf.intel.com with ESMTP; 31 Aug 2022 07:15:18 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id B7EDFAD; Wed, 31 Aug 2022 17:15:32 +0300 (EEST) From: Andy Shevchenko To: Jonathan Cameron , Andy Shevchenko , Linus Walleij , Jakob Hauser , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Jonathan Cameron , Lars-Peter Clausen Subject: [PATCH v2 2/3] iio: magnetometer: yamaha-yas530: Make strings const in chip info Date: Wed, 31 Aug 2022 17:15:29 +0300 Message-Id: <20220831141530.80572-2-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220831141530.80572-1-andriy.shevchenko@linux.intel.com> References: <20220831141530.80572-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org For better compiler coverage mark strings consts in the chip info. Signed-off-by: Andy Shevchenko --- v2: no changes drivers/iio/magnetometer/yamaha-yas530.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/iio/magnetometer/yamaha-yas530.c b/drivers/iio/magnetometer/yamaha-yas530.c index 58f527cfde07..a6e34d5f3e85 100644 --- a/drivers/iio/magnetometer/yamaha-yas530.c +++ b/drivers/iio/magnetometer/yamaha-yas530.c @@ -189,8 +189,8 @@ struct yas5xx; */ struct yas5xx_chip_info { unsigned int devid; - char *product_name; - char *version_names[2]; + const char *product_name; + const char *version_names[2]; const int *volatile_reg; int volatile_reg_qty; u32 scaling_val2; From patchwork Wed Aug 31 14:15:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 12960798 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E0603C3DA6B for ; Wed, 31 Aug 2022 14:16:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232115AbiHaOQW (ORCPT ); Wed, 31 Aug 2022 10:16:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59290 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232140AbiHaOP7 (ORCPT ); Wed, 31 Aug 2022 10:15:59 -0400 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 66E5D54C93; Wed, 31 Aug 2022 07:15:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1661955321; x=1693491321; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=L9mlAn2BFWn3JIKG5JcPjAbTHy4uCrPCXYYV2cWUXdk=; b=l/B0P/Gy3eM3cTo/03Vt5WiaclCZK3igVmL/838vIY4qx5eckazw4Eo9 GlfS/f3EdNGyNHV5PKEo3X4fHCYvfXa4ffWEZwHIglUc7KNPLpVDksLTP p1HZDW561mU3bPWnn00crHtwvvvBf6HzCu6NnQA0utpR0Qj4u86Oxhba8 Lyfz3cgLTm8wHBGZslce+PGzp7FCYneRdQatiEhC81jXuyN6bZrYUgHo/ GmAl5ERIAn6BxYnWglX/WLTLpqLUfXU+bxox1MMU5V9aYtYOYTvMK+L7w pqOIsAK3JUEpjB6JnNT6w1AD4LIPptT/DtI4ZC87yf3D9BZPGgXvOJL8d Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10456"; a="321594753" X-IronPort-AV: E=Sophos;i="5.93,278,1654585200"; d="scan'208";a="321594753" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Aug 2022 07:15:20 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,278,1654585200"; d="scan'208";a="787873718" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga005.jf.intel.com with ESMTP; 31 Aug 2022 07:15:17 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id BFF7C1C3; Wed, 31 Aug 2022 17:15:32 +0300 (EEST) From: Andy Shevchenko To: Jonathan Cameron , Andy Shevchenko , Linus Walleij , Jakob Hauser , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Jonathan Cameron , Lars-Peter Clausen Subject: [PATCH v2 3/3] iio: magnetometer: yamaha-yas530: Use dev_err_probe() Date: Wed, 31 Aug 2022 17:15:30 +0300 Message-Id: <20220831141530.80572-3-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220831141530.80572-1-andriy.shevchenko@linux.intel.com> References: <20220831141530.80572-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org Unify error message format by using dev_err_probe(). Signed-off-by: Andy Shevchenko --- v2: no changes drivers/iio/magnetometer/yamaha-yas530.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/drivers/iio/magnetometer/yamaha-yas530.c b/drivers/iio/magnetometer/yamaha-yas530.c index a6e34d5f3e85..801c760feb4d 100644 --- a/drivers/iio/magnetometer/yamaha-yas530.c +++ b/drivers/iio/magnetometer/yamaha-yas530.c @@ -1415,10 +1415,8 @@ static int yas5xx_probe(struct i2c_client *i2c, return dev_err_probe(dev, ret, "cannot get regulators\n"); ret = regulator_bulk_enable(ARRAY_SIZE(yas5xx->regs), yas5xx->regs); - if (ret) { - dev_err(dev, "cannot enable regulators\n"); - return ret; - } + if (ret) + return dev_err_probe(dev, ret, "cannot enable regulators\n"); /* See comment in runtime resume callback */ usleep_range(31000, 40000); @@ -1426,15 +1424,13 @@ static int yas5xx_probe(struct i2c_client *i2c, /* This will take the device out of reset if need be */ yas5xx->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW); if (IS_ERR(yas5xx->reset)) { - ret = dev_err_probe(dev, PTR_ERR(yas5xx->reset), - "failed to get reset line\n"); + ret = dev_err_probe(dev, PTR_ERR(yas5xx->reset), "failed to get reset line\n"); goto reg_off; } yas5xx->map = devm_regmap_init_i2c(i2c, &yas5xx_regmap_config); if (IS_ERR(yas5xx->map)) { - dev_err(dev, "failed to allocate register map\n"); - ret = PTR_ERR(yas5xx->map); + ret = dev_err_probe(dev, PTR_ERR(yas5xx->map), "failed to allocate register map\n"); goto assert_reset; } @@ -1484,13 +1480,13 @@ static int yas5xx_probe(struct i2c_client *i2c, yas5xx_handle_trigger, NULL); if (ret) { - dev_err(dev, "triggered buffer setup failed\n"); + dev_err_probe(dev, ret, "triggered buffer setup failed\n"); goto assert_reset; } ret = iio_device_register(indio_dev); if (ret) { - dev_err(dev, "device register failed\n"); + dev_err_probe(dev, ret, "device register failed\n"); goto cleanup_buffer; }