From patchwork Mon Jul 24 11:02:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 124823 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9010:0:b0:3e4:2afc:c1 with SMTP id l16csp1725134vqg; Mon, 24 Jul 2023 04:15:30 -0700 (PDT) X-Google-Smtp-Source: APBJJlG1A+e5eHRoW3QQ26iOl1Q5Jfb/aSgikPrBtO3uQ29Xf3a4+FPM/aVUaHWhPt6LotPZ7gis X-Received: by 2002:aa7:d282:0:b0:522:29b2:e048 with SMTP id w2-20020aa7d282000000b0052229b2e048mr3583108edq.13.1690197329845; Mon, 24 Jul 2023 04:15:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690197329; cv=none; d=google.com; s=arc-20160816; b=q5WmFuDJRJiaTN35wLp/GzadGQOojKLqsVqH6Sgn5Ts3i+jRr7It1nuEuL3TPc4Xz+ sJXQdRWbeV/NfSrMP6yRgIBdwYE5+T2KyAHwn4CwzTdHF4YJvp5bShYyX5EjZP+U2h8m aswVUcZ1V8+jxA+6LJKj0Vvuwi55xougWAr+ueu8JO3YlbRXqeVoM3KAIL3Pz00jnWO9 6NKLVK9/C12zgT8YUrKdHtzO/pcts/PAx8NeRMKJdAvi6pM2b+2GRFFISTxzMEbolTVl /LLLwxPoK5qYwLrbgbngUUw0EDaAs3jKfRWI7Gxemk5ZsAx43LJSsxHnBHk2RtCkHXR6 2zww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=e1ln7djYlVqPQ3bC5f8dBxsQhYM5GsMzayjDV+cOsBg=; fh=zI/sCjjpFZFpRWFbJrpu9GJ6xSZKd2JacIs4UkYeF5Q=; b=GXQSCauldZNyYo5hVhXySFdvSS/tOEFI9qS67XIqzlC24nPkhpo05ODIAOnORV5erV LwPwAZ3vs0yoiFGgKHEBWCOjvLGY4o5saz9uZ7ZHRKMlbJHG8NX3h0ugNfqN31ACeHHy PhwPG7vYxpaxk4M+JF+VW1u1nWdP5Igc/DeeLjdJk7EMbS+Fe1LqdrANLbxGAQPDEZH/ Kn4RlvxobBFXPc+EIdtCf11heZ9PKED1npfgTerNgwBJ3pPQdqKQMyhGRUGE/e3GNKiw Rb2PowosfpDahSqgjRpm0vwvpdsFEDxxnUvJK5nfV2oQeqM7ukursfDSM3CYF3hMJYoF wkYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=mlGSB5U1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v12-20020aa7d64c000000b0051e0c84ecc8si6583706edr.317.2023.07.24.04.15.04; Mon, 24 Jul 2023 04:15:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=mlGSB5U1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233337AbjGXLCR (ORCPT + 99 others); Mon, 24 Jul 2023 07:02:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55980 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233314AbjGXLCM (ORCPT ); Mon, 24 Jul 2023 07:02:12 -0400 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 57FC3188; Mon, 24 Jul 2023 04:02:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1690196528; x=1721732528; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=IctMq3br23eXnIOPxaHEk5MUrLAMEQPmIQZh4PnfpIo=; b=mlGSB5U1X+slgG+DdR5jLJBl4bFi7cZRdP2uwZRvCNTbcfBZxF8aWW1m L+trTPS0m3z/VgXrvGWFYv3HOaYCjk/Je1BlEhexYDWoY6pjVPHOdX+PC vbU+rBV2m0sAvMstF0LZCpMDREKlxdIEc5HDxsG4vF0icbjj9wymm04YF znvRHCaTFJh6vZxRUIL1nJARBwRmK+0JzOet0mzn/oBRDKMifqXo057OS OZKXcv4r5RtF+chN8Kk7bEwucNS2MokkBuUQSWUSGuh4FjUPQEKHZWTI0 ZZJ2Pv2NO/7IGKogr0zQpmPDarlm+AyWAWDq5ngPKigfNXV2EWAECOMGW g==; X-IronPort-AV: E=McAfee;i="6600,9927,10780"; a="347012823" X-IronPort-AV: E=Sophos;i="6.01,228,1684825200"; d="scan'208";a="347012823" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Jul 2023 04:02:00 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10780"; a="815775353" X-IronPort-AV: E=Sophos;i="6.01,228,1684825200"; d="scan'208";a="815775353" Received: from black.fi.intel.com ([10.237.72.28]) by FMSMGA003.fm.intel.com with ESMTP; 24 Jul 2023 04:01:58 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id BD4FD195; Mon, 24 Jul 2023 14:02:06 +0300 (EEST) From: Andy Shevchenko To: Andy Shevchenko , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Jonathan Cameron , Lars-Peter Clausen , Nuno Sa Subject: [PATCH v3 1/4] iio: core: Use sysfs_match_string() helper Date: Mon, 24 Jul 2023 14:02:01 +0300 Message-Id: <20230724110204.46285-2-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.40.0.1.gaa8946217a0b In-Reply-To: <20230724110204.46285-1-andriy.shevchenko@linux.intel.com> References: <20230724110204.46285-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_PASS, SPF_NONE,T_SCC_BODY_TEXT_LINE 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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1772300355043061838 X-GMAIL-MSGID: 1772300355043061838 Use sysfs_match_string() helper instead of open coded variant. Signed-off-by: Andy Shevchenko Reviewed-by: Nuno Sa --- drivers/iio/industrialio-core.c | 71 +++++++++++++++------------------ 1 file changed, 32 insertions(+), 39 deletions(-) diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c index 5f337f59330c..b153adc5bc84 100644 --- a/drivers/iio/industrialio-core.c +++ b/drivers/iio/industrialio-core.c @@ -1397,50 +1397,42 @@ static ssize_t label_show(struct device *dev, struct device_attribute *attr, static DEVICE_ATTR_RO(label); +static const char * const clock_names[] = { + [CLOCK_REALTIME] = "realtime", + [CLOCK_MONOTONIC] = "monotonic", + [CLOCK_PROCESS_CPUTIME_ID] = "process_cputime_id", + [CLOCK_THREAD_CPUTIME_ID] = "thread_cputime_id", + [CLOCK_MONOTONIC_RAW] = "monotonic_raw", + [CLOCK_REALTIME_COARSE] = "realtime_coarse", + [CLOCK_MONOTONIC_COARSE] = "monotonic_coarse", + [CLOCK_BOOTTIME] = "boottime", + [CLOCK_REALTIME_ALARM] = "realtime_alarm", + [CLOCK_BOOTTIME_ALARM] = "boottime_alarm", + [CLOCK_SGI_CYCLE] = "sgi_cycle", + [CLOCK_TAI] = "tai", +}; + static ssize_t current_timestamp_clock_show(struct device *dev, struct device_attribute *attr, char *buf) { const struct iio_dev *indio_dev = dev_to_iio_dev(dev); const clockid_t clk = iio_device_get_clock(indio_dev); - const char *name; - ssize_t sz; switch (clk) { case CLOCK_REALTIME: - name = "realtime\n"; - sz = sizeof("realtime\n"); - break; case CLOCK_MONOTONIC: - name = "monotonic\n"; - sz = sizeof("monotonic\n"); - break; case CLOCK_MONOTONIC_RAW: - name = "monotonic_raw\n"; - sz = sizeof("monotonic_raw\n"); - break; case CLOCK_REALTIME_COARSE: - name = "realtime_coarse\n"; - sz = sizeof("realtime_coarse\n"); - break; case CLOCK_MONOTONIC_COARSE: - name = "monotonic_coarse\n"; - sz = sizeof("monotonic_coarse\n"); - break; case CLOCK_BOOTTIME: - name = "boottime\n"; - sz = sizeof("boottime\n"); - break; case CLOCK_TAI: - name = "tai\n"; - sz = sizeof("tai\n"); break; default: BUG(); } - memcpy(buf, name, sz); - return sz; + return sysfs_emit(buf, "%s\n", clock_names[clk]); } static ssize_t current_timestamp_clock_store(struct device *dev, @@ -1450,22 +1442,23 @@ static ssize_t current_timestamp_clock_store(struct device *dev, clockid_t clk; int ret; - if (sysfs_streq(buf, "realtime")) - clk = CLOCK_REALTIME; - else if (sysfs_streq(buf, "monotonic")) - clk = CLOCK_MONOTONIC; - else if (sysfs_streq(buf, "monotonic_raw")) - clk = CLOCK_MONOTONIC_RAW; - else if (sysfs_streq(buf, "realtime_coarse")) - clk = CLOCK_REALTIME_COARSE; - else if (sysfs_streq(buf, "monotonic_coarse")) - clk = CLOCK_MONOTONIC_COARSE; - else if (sysfs_streq(buf, "boottime")) - clk = CLOCK_BOOTTIME; - else if (sysfs_streq(buf, "tai")) - clk = CLOCK_TAI; - else + ret = sysfs_match_string(clock_names, buf); + if (ret < 0) + return ret; + clk = ret; + + switch (clk) { + case CLOCK_REALTIME: + case CLOCK_MONOTONIC: + case CLOCK_MONOTONIC_RAW: + case CLOCK_REALTIME_COARSE: + case CLOCK_MONOTONIC_COARSE: + case CLOCK_BOOTTIME: + case CLOCK_TAI: + break; + default: return -EINVAL; + } ret = iio_device_set_clock(dev_to_iio_dev(dev), clk); if (ret) From patchwork Mon Jul 24 11:02:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 124868 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9010:0:b0:3e4:2afc:c1 with SMTP id l16csp1735159vqg; Mon, 24 Jul 2023 04:34:28 -0700 (PDT) X-Google-Smtp-Source: APBJJlFr1PfpCeDdWrUlguOlvI3EqKiU7WP8fvUJ0amsYfhcHCKf19R9Eej4rtYlH0Z9Q1iEwN4I X-Received: by 2002:a05:6a00:18aa:b0:686:290b:91f7 with SMTP id x42-20020a056a0018aa00b00686290b91f7mr6523132pfh.22.1690198467889; Mon, 24 Jul 2023 04:34:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690198467; cv=none; d=google.com; s=arc-20160816; b=a+NgS0HyfBMOQgvFcBgLhApdwydRMnT3QIGEfO2KKFJUeoqSSOFk3ZlWvj102lmHFX FZ6quGhZ7YwRMNxfb+kXoYNEyqCBTbdVeE4YyBuVOLulD8e17gdiQ4JCtnK562LnV+t6 j9Szyed6BTWbt2omjRAKoI6S9/Ln+fMjIjNzp1zmz+bsjsAE0/iUVURFywGnpfz+y7uX ZcmCeKGl68jJKMj9DmDsM9iuuGApz8WBCTVBcL9zyxpgqe/gkLg5mPSpUIojKuZ2q/7P dLiLISGAZnakX0b6TS3wDqL+Z1iuCq9Dio4JOHX3zbpdP1bS+1z6IAY0KpVXEHLmZEmT ivFw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=k4RR+ylOCB+AvcU+B9azRUjCf1/Luik4O9JhP/J6RzE=; fh=5utW/9xXK/HhFENJnNjAglXdo9AjnwLkfcYM2Wwa7jE=; b=sxHvUrlWIabP/wz72bA+nriAfHWFr/fQY9FTvMz57mEnsO4a6LOg18eLDiWzpwM7NE uUfQsZ40fXThO0DLlZ4/qZ2kJ1zBw2hEM1LfU5MnjUPkKTVZd9NNkGmHLAI5HbQ5KS90 kTmFswoIR7UAqsGt2FPx+73YAPUOtxIlKGiszBP78fosHAgJgq4kbhPW01hXSBS0kyyE FxsFzISaQQywwgXcx69y7wVDOnWKm1zOH9ykz4IzJE6dU9XYqqaJ5/x9myQkbe6E/rFI 4EEwyfL/c3SyM/ZHkbjIb+v5dYdXipW6YNz7Z6eAH67nv0pm/r6PrrLn9iYIrF4oqWBj LXwQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="GP9Ylxq/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u27-20020a056a00099b00b00666eacb9002si9408030pfg.371.2023.07.24.04.34.14; Mon, 24 Jul 2023 04:34:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="GP9Ylxq/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233265AbjGXLCX (ORCPT + 99 others); Mon, 24 Jul 2023 07:02:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55976 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233298AbjGXLCN (ORCPT ); Mon, 24 Jul 2023 07:02:13 -0400 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EBBE21A2; Mon, 24 Jul 2023 04:02:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1690196528; x=1721732528; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=knWfonp+Irc22tGc7fH1YtzHMLxiJcg4IV2GgKYEb+M=; b=GP9Ylxq/NvmyQE2GuXW+1tGgB0qaiCmdh8TLE763E2QvgvksijVXdwhy 3u6KA9TiiJuO9VkZWhMfUcz6463n6QlwaefFvFV41hfi57X49SizOJ3Or pEtK0x0sLPNsJ4hdj7d7Cf8lAM7uE3kOGGJ8cp441nmgvBrDr4fdPQFvo XKk4ZzBf/WogasZODq4Ei3rkUXNHyKJ7VBMrwAjHJt3LXjHdLYgllbyeO 5uiJnphbTxYmqV9uV98MazY5ji9sT8cl7jzGM4IjsVAKhZniSPc1CNrsG 2riy9MPhsEgK0RizjHBY9lmGagN0R4jT2A5npYZPR2XWhnCvgugE/D3hf w==; X-IronPort-AV: E=McAfee;i="6600,9927,10780"; a="347012828" X-IronPort-AV: E=Sophos;i="6.01,228,1684825200"; d="scan'208";a="347012828" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Jul 2023 04:02:00 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10780"; a="815775355" X-IronPort-AV: E=Sophos;i="6.01,228,1684825200"; d="scan'208";a="815775355" Received: from black.fi.intel.com ([10.237.72.28]) by FMSMGA003.fm.intel.com with ESMTP; 24 Jul 2023 04:01:58 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id C2CF31FC; Mon, 24 Jul 2023 14:02:06 +0300 (EEST) From: Andy Shevchenko To: Andy Shevchenko , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Jonathan Cameron , Lars-Peter Clausen , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Kees Cook , Nuno Sa Subject: [PATCH v3 2/4] iio: core: Add opaque_struct_size() helper and use it Date: Mon, 24 Jul 2023 14:02:02 +0300 Message-Id: <20230724110204.46285-3-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.40.0.1.gaa8946217a0b In-Reply-To: <20230724110204.46285-1-andriy.shevchenko@linux.intel.com> References: <20230724110204.46285-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_PASS, SPF_NONE,T_SCC_BODY_TEXT_LINE 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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1772301548432266628 X-GMAIL-MSGID: 1772301548432266628 Introduce opaque_struct_size() helper, which may be moved to overflow.h in the future, and use it in the IIO core. Potential users could be (among possible others): __spi_alloc_controller() in drivers/spi/spi.c alloc_netdev_mqs in net/core/dev.c Signed-off-by: Andy Shevchenko Cc: Uwe Kleine-König Cc: Kees Cook Reviewed-by: Nuno Sa --- drivers/iio/industrialio-core.c | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c index b153adc5bc84..118ca6b59504 100644 --- a/drivers/iio/industrialio-core.c +++ b/drivers/iio/industrialio-core.c @@ -1607,6 +1607,24 @@ const struct device_type iio_device_type = { .release = iio_dev_release, }; +/** + * opaque_struct_size() - Calculate size of opaque structure with trailing aligned data. + * @p: Pointer to the opaque structure. + * @a: Alignment in bytes before trailing data. + * @s: Data size in bytes (preferred not to be 0). + * + * Calculates size of memory needed for structure of @p followed by + * the aligned data of size @s. + * + * Note, when @s is 0, the alignment @a is added to the sizeof(*(@p)) + * and the result, depending on the @a, may be way off the initial size. + * + * Returns: Number of bytes needed or SIZE_MAX on overflow. + */ +#define opaque_struct_size(p, a, s) size_add(ALIGN(sizeof(*(p)), (a)), (s)) + +#define opaque_struct_data(p, a) PTR_ALIGN((void *)((p) + 1), (a)) + /** * iio_device_alloc() - allocate an iio_dev from a driver * @parent: Parent device. @@ -1618,19 +1636,13 @@ struct iio_dev *iio_device_alloc(struct device *parent, int sizeof_priv) struct iio_dev *indio_dev; size_t alloc_size; - alloc_size = sizeof(struct iio_dev_opaque); - if (sizeof_priv) { - alloc_size = ALIGN(alloc_size, IIO_DMA_MINALIGN); - alloc_size += sizeof_priv; - } - + alloc_size = opaque_struct_size(iio_dev_opaque, IIO_DMA_MINALIGN, sizeof_priv); iio_dev_opaque = kzalloc(alloc_size, GFP_KERNEL); if (!iio_dev_opaque) return NULL; indio_dev = &iio_dev_opaque->indio_dev; - indio_dev->priv = (char *)iio_dev_opaque + - ALIGN(sizeof(struct iio_dev_opaque), IIO_DMA_MINALIGN); + indio_dev->priv = opaque_struct_data(iio_dev_opaque, IIO_DMA_MINALIGN); indio_dev->dev.parent = parent; indio_dev->dev.type = &iio_device_type; From patchwork Mon Jul 24 11:02:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 124866 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9010:0:b0:3e4:2afc:c1 with SMTP id l16csp1734869vqg; Mon, 24 Jul 2023 04:33:58 -0700 (PDT) X-Google-Smtp-Source: APBJJlGjSFDY96u5IT0Hxz3J5i+rcrSsuFMlLvyHlP7pa1Q0C/UabqU7wZdJxvKS6M3yleLUqPjk X-Received: by 2002:a05:6870:e0ca:b0:1b5:688b:5c24 with SMTP id a10-20020a056870e0ca00b001b5688b5c24mr8677214oab.32.1690198437850; Mon, 24 Jul 2023 04:33:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690198437; cv=none; d=google.com; s=arc-20160816; b=ZX3d9EsNilopxQL2bGuaoUbBRkhlsOEKtRz/X4YbubdgfsWghtYQS7TBZavYqwAfSD 6y+2WRAGI+bwhrhdNFh5DdxkvS7ud2+QGaMSj+4QCfqzuqD+p5/EREUxl5lz0WaPP9A9 v83DcKlfY2z5Q05cUrog9U69svpTy/N3tRApHC/fvuRwMzuPDAbxYlCShO2hD4XCV3fJ 3seg/1MOHQUMUfqn+zPsLumCHhXtl9JxOi+DQnTLchnXvzyy0gWMuRr4AOqa/FQOJOrT VtwxMQ1FCTCtC4cEkx9ZGCKHb+ioVBPHolfUlcHHeFQJ47s/wyTukIY//wULjKnAyOJU j9aQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=KQ0ttq+qx69G014ECKg9SJrL43RLk26FYuRflvmuZP0=; fh=zI/sCjjpFZFpRWFbJrpu9GJ6xSZKd2JacIs4UkYeF5Q=; b=PWYwBU/C341LWjOmKPPOFoIlZ9NPO5TM+JVoZ4XMqi0LjbAobIPw0CQdFKpDmfR8dE MHy29L6/XGv9txRS6Y0X20GFqQlqLAuvA94LcMa8is0bhzOmxyyGsWcbJTlvGpROhOS5 ycgVuqdSYf/wvlYnkVt89XKN5oLk6EZ9NXGRfAVJCXUr69FNZtqlv8ztFsKuuCOrc2F3 eBmCwTWZLSXbagzkFK2RaYRagt85Zn6JfPN9ayUn+an11s+U7KlCHfwu/pZIGyxD4h2x r9KV6sAJwDyzR9bf4YBRl7axcPlKjtpJrHVoo3ngMrZA5Qkob59zlLelj2FqyY9z4wjo /yeA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=ncRQdXmn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j7-20020a63ec07000000b0054fdfd26dfesi8954430pgh.308.2023.07.24.04.33.44; Mon, 24 Jul 2023 04:33:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=ncRQdXmn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233349AbjGXLCU (ORCPT + 99 others); Mon, 24 Jul 2023 07:02:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55982 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233315AbjGXLCM (ORCPT ); Mon, 24 Jul 2023 07:02:12 -0400 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B5C3E19B; Mon, 24 Jul 2023 04:02:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1690196528; x=1721732528; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=G3EfKhulqiVD/k8ML7lvWomq7mPN98qxK02WVuePlyA=; b=ncRQdXmnjjJzc0LXweNOENf03qXfGfZL2rSYESTOY1pPDgB33wAVCv30 pbaxEntp2iTQfqZkiDhzNRa8hHZhoJVnpB8sdnATGy7tjaqLHTK1XuyVo pBV7E+11MDLOIlWXMmAfpIR3LkbRCoKFIteDNxDcMSYwR1GkULw3jnckt nl82Em75LOEGCz+MduzDWWgnGZBafNAGp34YGyWUT96CR5AS82g7/Vd7R Y3wkWt4jiiqFAf/WXfsatA3nyAX53WtoUcgmPpw1jLMPC2oTYbr9ZR6Ww vRUdUWclG0bKQS/EfklZFUoWWCEHpkiBZcYjwjZIdE349zDc4FGNkMter w==; X-IronPort-AV: E=McAfee;i="6600,9927,10780"; a="347012825" X-IronPort-AV: E=Sophos;i="6.01,228,1684825200"; d="scan'208";a="347012825" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Jul 2023 04:02:00 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10780"; a="815775356" X-IronPort-AV: E=Sophos;i="6.01,228,1684825200"; d="scan'208";a="815775356" Received: from black.fi.intel.com ([10.237.72.28]) by FMSMGA003.fm.intel.com with ESMTP; 24 Jul 2023 04:01:58 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id D1E6F2E9; Mon, 24 Jul 2023 14:02:06 +0300 (EEST) From: Andy Shevchenko To: Andy Shevchenko , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Jonathan Cameron , Lars-Peter Clausen , Nuno Sa Subject: [PATCH v3 3/4] iio: core: Switch to krealloc_array() Date: Mon, 24 Jul 2023 14:02:03 +0300 Message-Id: <20230724110204.46285-4-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.40.0.1.gaa8946217a0b In-Reply-To: <20230724110204.46285-1-andriy.shevchenko@linux.intel.com> References: <20230724110204.46285-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_PASS, SPF_NONE,T_SCC_BODY_TEXT_LINE 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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1772301517019108915 X-GMAIL-MSGID: 1772301517019108915 Let the krealloc_array() copy the original data and check for a multiplication overflow. Signed-off-by: Andy Shevchenko Reviewed-by: Nuno Sa --- drivers/iio/industrialio-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c index 118ca6b59504..13d6b6ac5ccf 100644 --- a/drivers/iio/industrialio-core.c +++ b/drivers/iio/industrialio-core.c @@ -1474,7 +1474,7 @@ int iio_device_register_sysfs_group(struct iio_dev *indio_dev, const struct attribute_group **new, **old = iio_dev_opaque->groups; unsigned int cnt = iio_dev_opaque->groupcounter; - new = krealloc(old, sizeof(*new) * (cnt + 2), GFP_KERNEL); + new = krealloc_array(old, cnt + 2, sizeof(*new), GFP_KERNEL); if (!new) return -ENOMEM; From patchwork Mon Jul 24 11:02:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 124872 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9010:0:b0:3e4:2afc:c1 with SMTP id l16csp1735424vqg; Mon, 24 Jul 2023 04:35:02 -0700 (PDT) X-Google-Smtp-Source: APBJJlELvPH/WAAhxytZFHC+JpBmgh9fq6bMsUM2+FvXPFsZPf3g9/O/nLNAwCCSlQoMYBCaScS4 X-Received: by 2002:a17:902:b18b:b0:1b6:a972:4414 with SMTP id s11-20020a170902b18b00b001b6a9724414mr7158575plr.3.1690198502056; Mon, 24 Jul 2023 04:35:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690198502; cv=none; d=google.com; s=arc-20160816; b=luEjp6oTvlPGVI9CJIpk1A5DnAsMfGxakshhHCus775APIjhRSDejdFI8ugNqyPEs+ 4nKvayj0boQcDRpLlc3U4BEgxhynzYuMk7a92UozUY9wsevDMVqd8Ado9HcLwm5rcCGH SmkAtSEODZSV9hYi8oJcijR5lJ4k38AjA3JiAb/oPCtqWVF6R6fdCxbB6FQE/632S6fa 8o/AZyOtS0FbouwLa2d+d+S9ovNM9vzFFUbpB6hIU28+029rzF2qN0mx/l3kva0as9T0 h7EdvN5wvwcQARXvGDIMI6Qi1Xd7ZH/rC1CLKqdFXPZIvZ8AC6soOiF+JaBC6Q9y0L0E JIoA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=4QAGjTlEHnU3JwskeGOpY4NobESkOKV//zQIseFwBco=; fh=n2X0wLhgSQGAgzQP3Ep6z0Azp4itndJGfT8apt3DP68=; b=cH/02bzLTjC9eBF2IFjgBpDa/wungPW1HiXeQz0lfUDsBkPjaFGMbAA2vSZewLn3Cy 1LWaEx8JqCdTBp626CV3j/KqJR5Gct/oc7YOAlpm/uF7HbvTPezXqwGdeQsl3DVWi/q8 uECBwu5VTkfqRtpot71WGdxrraj9JtagJzo/A5mO9YWaLQaCxYwZlPh2RH6vX0Fua2vo UaeJ7juzkj1UAQ453exFXQrGMcOwEQAKt815rTPF8SNTs3ZibNgsAGxHfWtch087yg1R vLjfC1AIWHKl68twN7xJUK1K24WxA+J562a8tJcxX1EOlVqQP0P+y91um4CITU+h8ObP qkZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="E3/mImZd"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u6-20020a170902e80600b001b9d9b01303si9819068plg.628.2023.07.24.04.34.48; Mon, 24 Jul 2023 04:35:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="E3/mImZd"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233330AbjGXLCO (ORCPT + 99 others); Mon, 24 Jul 2023 07:02:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55950 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233311AbjGXLCL (ORCPT ); Mon, 24 Jul 2023 07:02:11 -0400 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6F5E7187; Mon, 24 Jul 2023 04:02:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1690196524; x=1721732524; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=wWRqT8vpJKT05tICl5ocqYcd9Og4iXGsP7bje/RHewk=; b=E3/mImZdNT27yQkPXslSFksdujZU0bzTij0oeB7hAU1wx62+JJDQbJnC tt4n+WmsZQ7TiEjJvvpx95h0fdKaqW8inKsC9zgDmFTCFrKJZaoFMD4gC +W6wLDHwQ0BGG3gOHqOWkF+PHkWU+sxlLpS2ZsbDj/lgGk/wcgBrWFCBP svOzOZ+0TSl0KPa1iW2GzcH+g6V0bMUIlgThwCgwcwyB82xleaskLbAVg Y4FXiCVsm77BnOg+lKrI4OHrNRvtIF2OLYIspB0DBXwLSkNcS6E2DUdNu 4f6rt07YWnmZusyR+jZTHzdWg/t1NYFD22nFrs/97VQOiBqB0GeDwnB6n w==; X-IronPort-AV: E=McAfee;i="6600,9927,10780"; a="371009921" X-IronPort-AV: E=Sophos;i="6.01,228,1684825200"; d="scan'208";a="371009921" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Jul 2023 04:02:00 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.01,202,1684825200"; d="scan'208";a="869036288" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 24 Jul 2023 04:01:59 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id D770D2BC; Mon, 24 Jul 2023 14:02:06 +0300 (EEST) From: Andy Shevchenko To: Andy Shevchenko , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Jonathan Cameron , Lars-Peter Clausen , Nuno Sa , Randy Dunlap Subject: [PATCH v3 4/4] iio: core: Fix issues and style of the comments Date: Mon, 24 Jul 2023 14:02:04 +0300 Message-Id: <20230724110204.46285-5-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.40.0.1.gaa8946217a0b In-Reply-To: <20230724110204.46285-1-andriy.shevchenko@linux.intel.com> References: <20230724110204.46285-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE 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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1772301584837652500 X-GMAIL-MSGID: 1772301584837652500 The `scripts/kernel-doc -v -none -Wall` reports several issues with the kernel doc in IIO core C file. Update the comments accordingly. Signed-off-by: Andy Shevchenko Reviewed-by: Nuno Sa Reviewed-by: Randy Dunlap --- drivers/iio/industrialio-core.c | 57 +++++++++++++++++++++------------ 1 file changed, 37 insertions(+), 20 deletions(-) diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c index 13d6b6ac5ccf..7302a342dd48 100644 --- a/drivers/iio/industrialio-core.c +++ b/drivers/iio/industrialio-core.c @@ -1,5 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-only -/* The industrial I/O core +/* + * The industrial I/O core * * Copyright (c) 2008 Jonathan Cameron * @@ -183,7 +184,9 @@ static const char * const iio_chan_info_postfix[] = { * @indio_dev: Device structure whose ID is being queried * * The IIO device ID is a unique index used for example for the naming - * of the character device /dev/iio\:device[ID] + * of the character device /dev/iio\:device[ID]. + * + * Returns: Unique ID for the device. */ int iio_device_id(struct iio_dev *indio_dev) { @@ -196,6 +199,8 @@ EXPORT_SYMBOL_GPL(iio_device_id); /** * iio_buffer_enabled() - helper function to test if the buffer is enabled * @indio_dev: IIO device structure for device + * + * Returns: True, if the buffer is enabled. */ bool iio_buffer_enabled(struct iio_dev *indio_dev) { @@ -225,6 +230,9 @@ EXPORT_SYMBOL_GPL(iio_get_debugfs_dentry); * iio_find_channel_from_si() - get channel from its scan index * @indio_dev: device * @si: scan index to match + * + * Returns: + * Constant pointer to iio_chan_spec, if scan index matches, NULL on failure. */ const struct iio_chan_spec *iio_find_channel_from_si(struct iio_dev *indio_dev, int si) @@ -249,7 +257,9 @@ EXPORT_SYMBOL(iio_read_const_attr); /** * iio_device_set_clock() - Set current timestamping clock for the device * @indio_dev: IIO device structure containing the device - * @clock_id: timestamping clock posix identifier to set. + * @clock_id: timestamping clock POSIX identifier to set. + * + * Returns: 0 on success, or a negative error code. */ int iio_device_set_clock(struct iio_dev *indio_dev, clockid_t clock_id) { @@ -275,6 +285,8 @@ EXPORT_SYMBOL(iio_device_set_clock); /** * iio_device_get_clock() - Retrieve current timestamping clock for the device * @indio_dev: IIO device structure containing the device + * + * Returns: Clock ID of the current timestamping clock for the device. */ clockid_t iio_device_get_clock(const struct iio_dev *indio_dev) { @@ -287,6 +299,8 @@ EXPORT_SYMBOL(iio_device_get_clock); /** * iio_get_time_ns() - utility function to get a time stamp for events etc * @indio_dev: device + * + * Returns: Timestamp of the event in nanoseconds. */ s64 iio_get_time_ns(const struct iio_dev *indio_dev) { @@ -593,7 +607,7 @@ EXPORT_SYMBOL_GPL(iio_show_mount_matrix); * If device is assigned no mounting matrix property, a default 3x3 identity * matrix will be filled in. * - * Return: 0 if success, or a negative error code on failure. + * Returns: 0 if success, or a negative error code on failure. */ int iio_read_mount_matrix(struct device *dev, struct iio_mount_matrix *matrix) { @@ -691,9 +705,9 @@ static ssize_t __iio_format_value(char *buf, size_t offset, unsigned int type, * @vals: Pointer to the values, exact meaning depends on the * type parameter. * - * Return: 0 by default, a negative number on failure or the - * total number of characters written for a type that belongs - * to the IIO_VAL_* constant. + * Returns: + * 0 by default, a negative number on failure or the total number of characters + * written for a type that belongs to the IIO_VAL_* constant. */ ssize_t iio_format_value(char *buf, unsigned int type, int size, int *vals) { @@ -846,8 +860,8 @@ static ssize_t iio_read_channel_info_avail(struct device *dev, * @fract: The fractional part of the number * @scale_db: True if this should parse as dB * - * Returns 0 on success, or a negative error code if the string could not be - * parsed. + * Returns: + * 0 on success, or a negative error code if the string could not be parsed. */ static int __iio_str_to_fixpoint(const char *str, int fract_mult, int *integer, int *fract, bool scale_db) @@ -916,8 +930,8 @@ static int __iio_str_to_fixpoint(const char *str, int fract_mult, * @integer: The integer part of the number * @fract: The fractional part of the number * - * Returns 0 on success, or a negative error code if the string could not be - * parsed. + * Returns: + * 0 on success, or a negative error code if the string could not be parsed. */ int iio_str_to_fixpoint(const char *str, int fract_mult, int *integer, int *fract) @@ -1629,7 +1643,10 @@ const struct device_type iio_device_type = { * iio_device_alloc() - allocate an iio_dev from a driver * @parent: Parent device. * @sizeof_priv: Space to allocate for private structure. - **/ + * + * Returns: + * Pointer to allocated iio_dev on success, NULL on failure. + */ struct iio_dev *iio_device_alloc(struct device *parent, int sizeof_priv) { struct iio_dev_opaque *iio_dev_opaque; @@ -1679,7 +1696,7 @@ EXPORT_SYMBOL(iio_device_alloc); /** * iio_device_free() - free an iio_dev from a driver * @dev: the iio_dev associated with the device - **/ + */ void iio_device_free(struct iio_dev *dev) { if (dev) @@ -1700,7 +1717,7 @@ static void devm_iio_device_release(void *iio_dev) * Managed iio_device_alloc. iio_dev allocated with this function is * automatically freed on driver detach. * - * RETURNS: + * Returns: * Pointer to allocated iio_dev on success, NULL on failure. */ struct iio_dev *devm_iio_device_alloc(struct device *parent, int sizeof_priv) @@ -1727,8 +1744,8 @@ EXPORT_SYMBOL_GPL(devm_iio_device_alloc); * @filp: File structure for iio device used to keep and later access * private data * - * Return: 0 on success or -EBUSY if the device is already opened - **/ + * Returns: 0 on success or -EBUSY if the device is already opened + */ static int iio_chrdev_open(struct inode *inode, struct file *filp) { struct iio_dev_opaque *iio_dev_opaque = @@ -1761,7 +1778,7 @@ static int iio_chrdev_open(struct inode *inode, struct file *filp) * @inode: Inode structure pointer for the char device * @filp: File structure pointer for the char device * - * Return: 0 for successful release + * Returns: 0 for successful release. */ static int iio_chrdev_release(struct inode *inode, struct file *filp) { @@ -1800,7 +1817,7 @@ static long iio_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) mutex_lock(&iio_dev_opaque->info_exist_lock); - /** + /* * The NULL check here is required to prevent crashing when a device * is being removed while userspace would still have open file handles * to try to access this device. @@ -1978,7 +1995,7 @@ EXPORT_SYMBOL(__iio_device_register); /** * iio_device_unregister() - unregister a device from the IIO subsystem * @indio_dev: Device structure representing the device. - **/ + */ void iio_device_unregister(struct iio_dev *indio_dev) { struct iio_dev_opaque *iio_dev_opaque = to_iio_dev_opaque(indio_dev); @@ -2029,7 +2046,7 @@ EXPORT_SYMBOL_GPL(__devm_iio_device_register); * * Use with iio_device_release_direct_mode() * - * Returns: 0 on success, -EBUSY on failure + * Returns: 0 on success, -EBUSY on failure. */ int iio_device_claim_direct_mode(struct iio_dev *indio_dev) {