Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp832954imd; Fri, 26 Oct 2018 19:01:36 -0700 (PDT) X-Google-Smtp-Source: AJdET5ftvN5nW6T7zlRI2/LtrQ3EhrNKI46Gi5+syg4QZr0Dct0p6GDAotyTZh7qCuoeaJc6fB6P X-Received: by 2002:a63:6302:: with SMTP id x2mr5651615pgb.183.1540605696658; Fri, 26 Oct 2018 19:01:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540605696; cv=none; d=google.com; s=arc-20160816; b=IgtwT6If8xPQAWsEqdWwyVsYr2clvPln3Zq7uzzIQsjiJ+C7Wsj4ylcQY1W58SoBap dty5MwAFhLm5k6JnDlsnB+ISu7tyhyPf9XMl+/vkcF8FszdH/wvJqY6kqvh4OPGRDsiZ v/WV45sFXA4k6PsGosedciY6yeE07txHCwaagSkVIyjQYxKeHXD7b4XG0BQjf1WO+n9F NxVCZoFuccn9KOSWuKTDtsizsUsRtVevhbMs6uws8p5zOYwr/jgzBAZFZWjz17gTZii/ c3K9WL3v5O6KHoXx8Zu+FTCOfrAnNME4q24NzIbXhyGG0hZ5cL+Re1sIj1Ij4Z6E/0z+ i+sw== 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=Z2LHH9F5OJ0rvYdq5SDRuLDudXHduK0q/J3//KKhqZw=; b=O0HoMGJwlWqmHz0wnVGKpmecPDCLFVdH8/8VYZm+qX/QDNdzlu6JuZuvB3auS+Ctk2 x0n958j/a5tyZ5FAhyWkJeNbtHVK7fYJA67LUJhZhGx+zAzbzMrkSVAOY21FNBEZ5p5E ca7w1bb8enSMLQi8VLx+3vUFdk6Vtc9C3crqWl6Bv+T9nkTVtB1EhjghQnn8I6tFdpM+ rQSB5XXpiwD+drQB2jSP3XZQLJju0gji4+kraogj9zFrPY4kXt73JppB1OWIgXuSgJzT O8KZhacoQnqY1bxSdp/HT36OLLl/ryBxjFDVef2Azp2IqEagZjxNpjfNUwov85u4P4dO qI+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@usp-br.20150623.gappssmtp.com header.s=20150623 header.b=ruL+ahgQ; 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 r19-v6si13396117pgj.438.2018.10.26.19.01.19; Fri, 26 Oct 2018 19:01:36 -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=ruL+ahgQ; 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 S1727832AbeJ0KkI (ORCPT + 99 others); Sat, 27 Oct 2018 06:40:08 -0400 Received: from mail-qt1-f194.google.com ([209.85.160.194]:34196 "EHLO mail-qt1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727659AbeJ0KkH (ORCPT ); Sat, 27 Oct 2018 06:40:07 -0400 Received: by mail-qt1-f194.google.com with SMTP id z2-v6so3441382qts.1 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=tuolyA7VNTx3yo3cRoc9ieYQLRFx0eOzQCA14up6Zd/8KQGlV+G/sWaaVr57hcNtbN R/9nWMpikchhoZ3Eyzn19uYvWFXUH7S53Z32TpdUvtgWWKGhitGBuP7R0Py0pA/TrvX9 6GgewMsfdJw5FtH851NSckgIXaAzq07G9zuGpmY7vxD8MCa0u9328KwkgnUje1bGBVZ1 LD88+qpNUsAWBeAx5nd230G+Ue9/Ld5J/bDQWaaf1oRtt2UubMEoFNmSstLWQX+pXMXx ndyLZqnFGjhtg/3cFsIHCJorFmeKSrbdOl2BXEZ8MSNGOVfunim1fkH2sVcev9tCBYIE s4bg== X-Gm-Message-State: AGRZ1gJwnhpait+izs4bmJWOL7qjG6gfrI1yAZhO+aBztnmUUJ/YSVE7 pRMT7Fp5sz3+FethgqyURZrdng== 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-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 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[] = { -- 2.18.0