From patchwork Sat Oct 27 02:00:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matheus Tavares X-Patchwork-Id: 10658031 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EC26414DE for ; Sat, 27 Oct 2018 02:01:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DE9FB2C19F for ; Sat, 27 Oct 2018 02:01:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CFAAF2C7CE; Sat, 27 Oct 2018 02:01:06 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 766682C19F for ; Sat, 27 Oct 2018 02:01:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727793AbeJ0KkI (ORCPT ); Sat, 27 Oct 2018 06:40:08 -0400 Received: from mail-qt1-f193.google.com ([209.85.160.193]:38099 "EHLO mail-qt1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727792AbeJ0KkI (ORCPT ); Sat, 27 Oct 2018 06:40:08 -0400 Received: by mail-qt1-f193.google.com with SMTP id r22-v6so3417727qtm.5 for ; Fri, 26 Oct 2018 19:00:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=usp-br.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Z2LHH9F5OJ0rvYdq5SDRuLDudXHduK0q/J3//KKhqZw=; b=ruL+ahgQTt8IWvavSx0G9329AhPM1OKdSqIdK5LK4YJrghthI+Mxz8SKeL1a2HmvwE e+H8ERDXOenJ0kDdhwWl5ZzlyxcyE8fq7yPMzC+2CaOQ5ThT1l07yxH5xV8CocAG5Dd4 EcxXmBJtqpMEoeGHZ+Ep5upwQZIVMbtf50EV4WOHWVb9yJwm7RSDkJF9SWwCSFtjMtLt 89zeRKq2r/0N94tkWj5W1U1lj/jdW0jTasEg/z+gfUHkXKiPdIpVa+/QPgM2Y1SNYg/A elSCW4CxeYOYH80QZLawAO8LUgKhcH4EdK8mzCy3fZNYK5+QIOxyznh821RxaXKX/CM+ lIqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Z2LHH9F5OJ0rvYdq5SDRuLDudXHduK0q/J3//KKhqZw=; b=RtDL9MizBlFv05P/5IoQ4DnLDMtFaCR0GirQROa5QGzmqeUCiO+1/tN6RBo0RmhSra 3p4nUJL0f6WHon58zvcRAQ9ZR46HMqmDeNmiwjYAx3zdGlvlrS8BJsSx197HBXInUb0E fKYQKXX/Nmseg2t/Yl9hAGc4G0TxAztkjJ+zG5VPOSkWX3W7OuBEt8nPKIgQ4qlUb1yu qcqko/G5rGb3RFM7SFvaFP2o0msG7eajOb0rYkLKa7itrxycKFyiPS6t4I1HhqWoec24 PG+i+IKWafkRv6mtCDNHTTeLjYmspClmclYC0yHikhV4zf0/lMc2FmhlIEn1JI16k/+J 51jA== X-Gm-Message-State: AGRZ1gKPQPXeYqZduX6HjgJWnaa5rF1+ea1Kg47LYgEJUw40/HMjEEnx kKUQpq/3ey8vdd0/BpV14aIw9w== X-Google-Smtp-Source: AJdET5cu1/HMNJwpQhcKHquey8ibfvg93sjyy2N490xuju8SYMqryd7dFoZAwVoD34W9ac9yYlF6hg== X-Received: by 2002:ac8:701d:: with SMTP id x29-v6mr5458721qtm.161.1540605647110; Fri, 26 Oct 2018 19:00:47 -0700 (PDT) Received: from mango.spo.virtua.com.br ([2804:14c:81:942d::1]) by smtp.gmail.com with ESMTPSA id h67-v6sm8499777qkf.32.2018.10.26.19.00.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 26 Oct 2018 19:00:46 -0700 (PDT) From: Matheus Tavares To: Lars-Peter Clausen , Michael Hennerich , Jonathan Cameron , Hartmut Knaack , Peter Meerwald-Stadler , Greg Kroah-Hartman Cc: linux-iio@vger.kernel.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, kernel-usp@googlegroups.com Subject: [PATCH v2 4/6] staging:iio:ad2s90: Move device registration to the end of probe Date: Fri, 26 Oct 2018 23:00:03 -0300 Message-Id: <20181027020005.3140-5-matheus.bernardino@usp.br> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20181027020005.3140-1-matheus.bernardino@usp.br> References: <20181027020005.3140-1-matheus.bernardino@usp.br> Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Previously, devm_iio_device_register was being called before the spi_setup call and the spi_device's max_speed_hz and mode assignments. This could lead to a race condition since the driver was still being set up after it was already made ready to use. To fix it, this patch moves the device registration to the end of ad2s90_probe. Signed-off-by: Matheus Tavares --- drivers/staging/iio/resolver/ad2s90.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/staging/iio/resolver/ad2s90.c b/drivers/staging/iio/resolver/ad2s90.c index c20d37dc065a..b4a6a89c11b0 100644 --- a/drivers/staging/iio/resolver/ad2s90.c +++ b/drivers/staging/iio/resolver/ad2s90.c @@ -81,10 +81,6 @@ static int ad2s90_probe(struct spi_device *spi) indio_dev->num_channels = 1; indio_dev->name = spi_get_device_id(spi)->name; - ret = devm_iio_device_register(indio_dev->dev.parent, indio_dev); - if (ret) - return ret; - /* need 600ns between CS and the first falling edge of SCLK */ spi->max_speed_hz = 830000; spi->mode = SPI_MODE_3; @@ -95,7 +91,7 @@ static int ad2s90_probe(struct spi_device *spi) return ret; } - return 0; + return devm_iio_device_register(indio_dev->dev.parent, indio_dev); } static const struct spi_device_id ad2s90_id[] = {