From patchwork Fri Apr 2 17:49:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 12181363 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=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,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 17F12C433ED for ; Fri, 2 Apr 2021 17:49:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DD21A6113E for ; Fri, 2 Apr 2021 17:49:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235649AbhDBRtC (ORCPT ); Fri, 2 Apr 2021 13:49:02 -0400 Received: from mga04.intel.com ([192.55.52.120]:17691 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234488AbhDBRtC (ORCPT ); Fri, 2 Apr 2021 13:49:02 -0400 IronPort-SDR: g5i2wSmf22gD10LloUMFeJDRVjwAxVdGtfdp4Q4A//DnefRSCYLqmBJEBnPfynAIDp9FYM6vdT AMwKyEqZ4OsQ== X-IronPort-AV: E=McAfee;i="6000,8403,9942"; a="190278002" X-IronPort-AV: E=Sophos;i="5.81,300,1610438400"; d="scan'208";a="190278002" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Apr 2021 10:49:00 -0700 IronPort-SDR: YWno7GKDwlS5K0URHqz6OiC8DPP806DO5xT5nrf4+SR9Vq6m35yVlBPwW34WZIN8pGmrPBcb2F OLsep7SJvfFQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.81,300,1610438400"; d="scan'208";a="439702770" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga004.fm.intel.com with ESMTP; 02 Apr 2021 10:48:59 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 4305022B; Fri, 2 Apr 2021 20:49:13 +0300 (EEST) From: Andy Shevchenko To: Jonathan Cameron , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Jonathan Cameron , Lars-Peter Clausen , Andy Shevchenko Subject: [PATCH v2 1/2] iio: trigger: Replace explicit casting and wrong specifier with proper one Date: Fri, 2 Apr 2021 20:49:10 +0300 Message-Id: <20210402174911.44408-1-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org By unknown reason device name is set with an index casted from int to unsigned long while at the same time with "%ld" specifier. Both parts seems wrong to me, thus replace replace explicit casting and wrong specifier with proper one, i.e. "%d". Signed-off-by: Andy Shevchenko --- v2: used %d which is really correct one drivers/iio/industrialio-trigger.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/iio/industrialio-trigger.c b/drivers/iio/industrialio-trigger.c index 32ac1bec25e3..78e30f0f915c 100644 --- a/drivers/iio/industrialio-trigger.c +++ b/drivers/iio/industrialio-trigger.c @@ -75,8 +75,7 @@ int __iio_trigger_register(struct iio_trigger *trig_info, return trig_info->id; /* Set the name used for the sysfs directory etc */ - dev_set_name(&trig_info->dev, "trigger%ld", - (unsigned long) trig_info->id); + dev_set_name(&trig_info->dev, "trigger%d", trig_info->id); ret = device_add(&trig_info->dev); if (ret) From patchwork Fri Apr 2 17:49:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 12181365 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=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,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 1F949C433B4 for ; Fri, 2 Apr 2021 17:49:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F416661103 for ; Fri, 2 Apr 2021 17:49:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235938AbhDBRtE (ORCPT ); Fri, 2 Apr 2021 13:49:04 -0400 Received: from mga04.intel.com ([192.55.52.120]:17691 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235836AbhDBRtC (ORCPT ); Fri, 2 Apr 2021 13:49:02 -0400 IronPort-SDR: 3Ioe8XTko4Lnm3kgz5QttT6PRNroz/RlxbD3y9FiFwIdFyjWhqZimvcGq5K9Fx1J7e1uUhxvP4 mgwzVm8p+hxA== X-IronPort-AV: E=McAfee;i="6000,8403,9942"; a="190278005" X-IronPort-AV: E=Sophos;i="5.81,300,1610438400"; d="scan'208";a="190278005" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Apr 2021 10:49:01 -0700 IronPort-SDR: j5s1BPlZdyePNVg2hcTS5FTsJBRILEsx1hDEf/0tZ4uXMSFEiYbIu9RAzLwa4YPHfV/MPmnmog /CvlIJ1GCTiA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.81,300,1610438400"; d="scan'208";a="439702772" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga004.fm.intel.com with ESMTP; 02 Apr 2021 10:48:59 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 04EF12E4; Fri, 2 Apr 2021 20:49:14 +0300 (EEST) From: Andy Shevchenko To: Jonathan Cameron , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Jonathan Cameron , Lars-Peter Clausen , Andy Shevchenko Subject: [PATCH v2 2/2] iio: trigger: Fix strange (ladder-type) indentation Date: Fri, 2 Apr 2021 20:49:11 +0300 Message-Id: <20210402174911.44408-2-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210402174911.44408-1-andriy.shevchenko@linux.intel.com> References: <20210402174911.44408-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org In some cases indentation looks a bit weird with starting from = sign and being in a ladder-type style. Unify it across the module. While at it, add blank line after definition block where it needed, Signed-off-by: Andy Shevchenko --- v2: fixed typo in the commit message (tupe->type) drivers/iio/industrialio-trigger.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/drivers/iio/industrialio-trigger.c b/drivers/iio/industrialio-trigger.c index 78e30f0f915c..ec72ff04b38d 100644 --- a/drivers/iio/industrialio-trigger.c +++ b/drivers/iio/industrialio-trigger.c @@ -211,6 +211,7 @@ EXPORT_SYMBOL(iio_trigger_notify_done); static int iio_trigger_get_irq(struct iio_trigger *trig) { int ret; + mutex_lock(&trig->pool_lock); ret = bitmap_find_free_region(trig->pool, CONFIG_IIO_CONSUMERS_PER_TRIGGER, @@ -239,9 +240,9 @@ static void iio_trigger_put_irq(struct iio_trigger *trig, int irq) int iio_trigger_attach_poll_func(struct iio_trigger *trig, struct iio_poll_func *pf) { + bool notinuse = + bitmap_empty(trig->pool, CONFIG_IIO_CONSUMERS_PER_TRIGGER); int ret = 0; - bool notinuse - = bitmap_empty(trig->pool, CONFIG_IIO_CONSUMERS_PER_TRIGGER); /* Prevent the module from being removed whilst attached to a trigger */ __module_get(pf->indio_dev->driver_module); @@ -290,11 +291,10 @@ int iio_trigger_attach_poll_func(struct iio_trigger *trig, int iio_trigger_detach_poll_func(struct iio_trigger *trig, struct iio_poll_func *pf) { + bool no_other_users = + bitmap_weight(trig->pool, CONFIG_IIO_CONSUMERS_PER_TRIGGER) == 1; int ret = 0; - bool no_other_users - = (bitmap_weight(trig->pool, - CONFIG_IIO_CONSUMERS_PER_TRIGGER) - == 1); + if (trig->ops && trig->ops->set_trigger_state && no_other_users) { ret = trig->ops->set_trigger_state(trig, false); if (ret) @@ -312,6 +312,7 @@ int iio_trigger_detach_poll_func(struct iio_trigger *trig, irqreturn_t iio_pollfunc_store_time(int irq, void *p) { struct iio_poll_func *pf = p; + pf->timestamp = iio_get_time_ns(pf->indio_dev); return IRQ_WAKE_THREAD; } @@ -498,18 +499,16 @@ static const struct device_type iio_trig_type = { static void iio_trig_subirqmask(struct irq_data *d) { struct irq_chip *chip = irq_data_get_irq_chip(d); - struct iio_trigger *trig - = container_of(chip, - struct iio_trigger, subirq_chip); + struct iio_trigger *trig = container_of(chip, struct iio_trigger, subirq_chip); + trig->subirqs[d->irq - trig->subirq_base].enabled = false; } static void iio_trig_subirqunmask(struct irq_data *d) { struct irq_chip *chip = irq_data_get_irq_chip(d); - struct iio_trigger *trig - = container_of(chip, - struct iio_trigger, subirq_chip); + struct iio_trigger *trig = container_of(chip, struct iio_trigger, subirq_chip); + trig->subirqs[d->irq - trig->subirq_base].enabled = true; } @@ -695,7 +694,7 @@ EXPORT_SYMBOL(iio_trigger_using_own); * device, -EINVAL otherwise. */ int iio_trigger_validate_own_device(struct iio_trigger *trig, - struct iio_dev *indio_dev) + struct iio_dev *indio_dev) { if (indio_dev->dev.parent != trig->dev.parent) return -EINVAL;