Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp1020731imd; Sat, 3 Nov 2018 15:51:06 -0700 (PDT) X-Google-Smtp-Source: AJdET5eEe7ADanH9AHVWy7Xz9/1JN/0fmNEqHj/gMIaPjdzpp5Z0IeF1gpSs0ob+bEGHjOA0Zxzi X-Received: by 2002:a62:b09:: with SMTP id t9-v6mr16846766pfi.36.1541285466029; Sat, 03 Nov 2018 15:51:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1541285466; cv=none; d=google.com; s=arc-20160816; b=kba/sYQKLh8l3OyKiTgjNsDw6UglKWoE/5nxXQ/GgIW6E+NTk/WjbRgl6Bkq8Pz2qY ru1xCon7/IU9rDkUO/HZmEZAGXeeL6Ie/6yUN7KuqKxmZ2Lj+nxJZghh38bk+A7z0423 J2/i4avcteagLnUlRhdkfZJPdHxVXi2glR/2HsfEvVkZqZ+a7hLBgT+JOZa3oy1WRk9J vpev605pe8fLv/SUMUoK84xUSqKSkY8yEEJCK9kt5E6luuCZ9LXWiF170NbHzAtPonXL SQIWMlAqZmLGpyE/0oyC9x/a2X1qS/Bl4mBlW+9EIpx174g49GrmnbsroxzD+kBtA8cA 8Blg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=GD4vVE0HPom8l9DS59ZCy1DA4DKNmflT3aSJsaYUcgA=; b=zGoY2IZT6bNOGIdVjLOCqFeA6yd8ewTv4t9Q6KVk1oBGKP3zTNozvxgbjdJQ2OKV+r VRM5UeBcgv2VVmiRSIRCavp/Z7IkfI6FduQr21Syh28Sb6r9TadLox/wGhTa3u3/lTmI QjreUU+YFmbVvTJeh0yxhRREC3esp9KWM+/o2qresc7utim38pJAVo4kZ5EYNmoMmZLd kRbhuMj0hGrh88yIqApihq5SX5rBRfoLfRjPc9wKNMpgLjuWx7MUP/lG4FOWt0n+3Q+C JGru5NP1RhZoMeJEdBrx3lnjSSEXvnG/p6tXqPC81Iy3Z300fa3bBkABOHQEfEGqfSIE q70A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@usp-br.20150623.gappssmtp.com header.s=20150623 header.b=GUubobDb; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=usp.br Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e32-v6si25157704pge.546.2018.11.03.15.50.51; Sat, 03 Nov 2018 15:51:05 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@usp-br.20150623.gappssmtp.com header.s=20150623 header.b=GUubobDb; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=usp.br Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728790AbeKDIDA (ORCPT + 99 others); Sun, 4 Nov 2018 03:03:00 -0500 Received: from mail-qk1-f196.google.com ([209.85.222.196]:41411 "EHLO mail-qk1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726954AbeKDIC7 (ORCPT ); Sun, 4 Nov 2018 03:02:59 -0500 Received: by mail-qk1-f196.google.com with SMTP id 189so8946076qkj.8 for ; Sat, 03 Nov 2018 15:50:19 -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=GD4vVE0HPom8l9DS59ZCy1DA4DKNmflT3aSJsaYUcgA=; b=GUubobDbcf/zDkYhIxxdggdX5hJks+0xN50pfmTtNVPHJ/FsxiA37fzyP7ZUQFQXKZ XzKqgVBBVFS6abh6HRkRZYMjN7nr+U6nWU7NcwP/lkaojZlhWmiQ4P33MfOqGCjMVTZA 70ZnLGQg90J7uWn5E9GM4/A7KLkwxnnrDTvKOXckH3UqGO3uQKdw4Q6U/tHi1Y7efaTh jr78V2ovjPRAN4ecvL1Vfs0UwZZHkZuM7m1OwxPiXu1k9VdT07nIWAImtGDVUvVI1n9G BeAyPXxh+gzhcFDkiyj6lpI29neTAcVbx+aeKVWA8IPl+ugesdmkbUPHjJ7FmtH4VAcf +wkg== 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=GD4vVE0HPom8l9DS59ZCy1DA4DKNmflT3aSJsaYUcgA=; b=hzeX+7pg9gk89P0CB/1XovYUPAtlvpE2DOZJjRAlOHbjC1xfJ8ARicHocU3R1m8xHA 5lAV7dAyTuMRRj1cI9pnQAvIQkHPmJilvphcEy4we4k86E0bHqvijhCjS9ZD1Jc7nkqT E81RYBcNM6GcgG6xylyogQ4xjZhZSmc8i8od84sMhNoR4OQ+8Ru73R4fYPdkHapDTk8B aqz8yz1bFx5/Hk4qEjMTPMeOqbtWTlEMi5XFXYnpoSYeo/c8MU6PCb8Zc2B1fEUHRk+h z36c63OuSqIUoY510mjMEUrbrd83D2tPFDRBTz7P8Mdr7iY/1p5rvkkAFldL0kYo0xHQ 4hNA== X-Gm-Message-State: AGRZ1gJcmn4tmqBlgmyhGCQkTibOK7hk7pPDNvgTUA2jTMo9oN3rfShu 0acvBZay+3MO0GI3vn0AH0tgcA== X-Received: by 2002:ac8:6104:: with SMTP id a4-v6mr10478328qtm.350.1541285418902; Sat, 03 Nov 2018 15:50:18 -0700 (PDT) Received: from mango.spo.virtua.com.br ([2804:14c:81:942d::1]) by smtp.gmail.com with ESMTPSA id 35-v6sm27550924qtu.69.2018.11.03.15.50.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 03 Nov 2018 15:50:18 -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 v3 4/6] staging:iio:ad2s90: Move device registration to the end of probe Date: Sat, 3 Nov 2018 19:49:46 -0300 Message-Id: <20181103224948.31014-5-matheus.bernardino@usp.br> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20181103224948.31014-1-matheus.bernardino@usp.br> References: <20181103224948.31014-1-matheus.bernardino@usp.br> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 54ad85bd9dc6..8f79cccf4814 100644 --- a/drivers/staging/iio/resolver/ad2s90.c +++ b/drivers/staging/iio/resolver/ad2s90.c @@ -79,10 +79,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; @@ -93,7 +89,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[] = { -- 2.18.0