Received: by 10.213.65.68 with SMTP id h4csp245494imn; Fri, 23 Mar 2018 03:49:32 -0700 (PDT) X-Google-Smtp-Source: AG47ELsq4fJuYZpG8rQLTuqz9goZG/JyBGrqBwFJx2MNSgw3HzB7b+lZ0r9q7zSeb0JyAzbpWCss X-Received: by 2002:a17:902:6b02:: with SMTP id o2-v6mr29517229plk.334.1521802172399; Fri, 23 Mar 2018 03:49:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521802172; cv=none; d=google.com; s=arc-20160816; b=r/Eh/kZLsG2qKj+YeGWfJtSEubfDx9oLuSWb+EzoE3m5uIxPrBzxJGBFCBi3roRiub JUnHEaZ591y682NeaJtmrFcjVn77oPxuuTBTlRXxctwfeFKVTfYk4APt1IxXyu39wOin j7YANeqBgCibConfyrmM5XK6xMiAMJaNE3OFEG9YdDHGjFJzvQ+04gY7969f+bEW7YLs 5gC5OHYr/bnO2pohS4jZ4xzCU05oU/RLIeDW5ih9Bg47634VR3QGrzbsc2BYB/hz4N67 eptzDhGfH4vXWRWolmjDKyPWYmLZKOkEcwnrpWztOYcETH/CmTgnBi5MHl7gwLJiAa5J Hhyw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=M/zHva4BOPF2rqgJO7kQkNQs42RdwtLuemZyDe6G3pM=; b=LSM8jqvhD1Xm6z0WHA8o8uUJdn7xS84tFgc1WgHYfclcT+14OOgDmV07rGfGirH0Gt i3+Mu2eY4FJjlBSU6wLUUrm4OCY+mnVmQZMm7bHcZlnyqA0SHPZ7swfpkzAeswy63djH jw9cNtYoGeDlJ8RZYBdBv0Ps1U9zZHr14KwmdksL9er6rroMWkFnCKmTHK1ChQtyiKXc 0+hS+/fkCzFTs6/Fc7ISx5lCDSfVYzEt6Ow3wmi9E580m8DRgQsWizrePz0QIcnMeTrc ZIqOrRw0mq2JGgxCmMlfL7sBlRBIyxzyNhMOvpZljP/dzlAolM3+eyuFmaUlGoXUT4In rOAg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p33-v6si8508701pld.106.2018.03.23.03.49.17; Fri, 23 Mar 2018 03:49:32 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756031AbeCWKOz (ORCPT + 99 others); Fri, 23 Mar 2018 06:14:55 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:45402 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752413AbeCWKOv (ORCPT ); Fri, 23 Mar 2018 06:14:51 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 430ED1260; Fri, 23 Mar 2018 10:14:51 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jonathan Cameron , Linus Walleij , Sasha Levin Subject: [PATCH 4.4 46/97] iio: st_pressure: st_accel: Initialise sensor platform data properly Date: Fri, 23 Mar 2018 10:54:33 +0100 Message-Id: <20180323094200.211751647@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180323094157.535925724@linuxfoundation.org> References: <20180323094157.535925724@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Shrirang Bagul [ Upstream commit 7383d44b84c94aaca4bf695a6bd8a69f2295ef1a ] This patch fixes the sensor platform data initialisation for st_pressure and st_accel device drivers. Without this patch, the driver fails to register the sensors when the user removes and re-loads the driver. 1. Unload the kernel modules for st_pressure $ sudo rmmod st_pressure_i2c $ sudo rmmod st_pressure 2. Re-load the driver $ sudo insmod st_pressure $ sudo insmod st_pressure_i2c Signed-off-by: Jonathan Cameron Acked-by: Linus Walleij Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/iio/accel/st_accel_core.c | 7 ++++--- drivers/iio/pressure/st_pressure_core.c | 8 ++++---- 2 files changed, 8 insertions(+), 7 deletions(-) --- a/drivers/iio/accel/st_accel_core.c +++ b/drivers/iio/accel/st_accel_core.c @@ -628,6 +628,8 @@ static const struct iio_trigger_ops st_a int st_accel_common_probe(struct iio_dev *indio_dev) { struct st_sensor_data *adata = iio_priv(indio_dev); + struct st_sensors_platform_data *pdata = + (struct st_sensors_platform_data *)adata->dev->platform_data; int irq = adata->get_irq_data_ready(indio_dev); int err; @@ -652,9 +654,8 @@ int st_accel_common_probe(struct iio_dev &adata->sensor_settings->fs.fs_avl[0]; adata->odr = adata->sensor_settings->odr.odr_avl[0].hz; - if (!adata->dev->platform_data) - adata->dev->platform_data = - (struct st_sensors_platform_data *)&default_accel_pdata; + if (!pdata) + pdata = (struct st_sensors_platform_data *)&default_accel_pdata; err = st_sensors_init_sensor(indio_dev, adata->dev->platform_data); if (err < 0) --- a/drivers/iio/pressure/st_pressure_core.c +++ b/drivers/iio/pressure/st_pressure_core.c @@ -436,6 +436,8 @@ static const struct iio_trigger_ops st_p int st_press_common_probe(struct iio_dev *indio_dev) { struct st_sensor_data *press_data = iio_priv(indio_dev); + struct st_sensors_platform_data *pdata = + (struct st_sensors_platform_data *)press_data->dev->platform_data; int irq = press_data->get_irq_data_ready(indio_dev); int err; @@ -464,10 +466,8 @@ int st_press_common_probe(struct iio_dev press_data->odr = press_data->sensor_settings->odr.odr_avl[0].hz; /* Some devices don't support a data ready pin. */ - if (!press_data->dev->platform_data && - press_data->sensor_settings->drdy_irq.addr) - press_data->dev->platform_data = - (struct st_sensors_platform_data *)&default_press_pdata; + if (!pdata && press_data->sensor_settings->drdy_irq.addr) + pdata = (struct st_sensors_platform_data *)&default_press_pdata; err = st_sensors_init_sensor(indio_dev, press_data->dev->platform_data); if (err < 0)