Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp2485133pxv; Sat, 3 Jul 2021 10:09:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy9eSrQ+KeNXk3yCoUXW2DKoCWJqovKGbThcO1VattDh6kGOQOMuaP8gHcTd2YIvNp9twtT X-Received: by 2002:a17:907:3d86:: with SMTP id he6mr5597419ejc.440.1625332182890; Sat, 03 Jul 2021 10:09:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625332182; cv=none; d=google.com; s=arc-20160816; b=epUPZkDkIWfk/DyLym2/fGOvDDmTZPjOmKtEyylcO6onZSDJuTPT/ETuaGjhDjQPO2 VPM80uN1pZl1b1HXozIa/awmwzjhTHkJWvz6/Por1iYN/AKUX4dX8VMzEY5tJj1ooJv9 as9IvyDwriYn+fAoIUrfAw5f1G2Rx/ytYO3EQaSdoK4wYnXhJjXJ2PtrJNtBHYcdOXf1 Gvh1Q2d03U0GNImLH4/Na8MC53oMmcheZ+LeZn/ibPf10b9cctnj64peV37o7wVWMlFn Ot1JJv/FOYOdG2wMM6NlowdyNDj2ZouOQjBzobHXqc7d/4rEKtHs4m9uNXm3kH3z5XdB 03/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date; bh=42AvGbuYf3mRzPJSvvvQtcCVStIcew/vmuBsPC5k6y8=; b=L4laaPTywqGSaq5YcuSNed3rXQ0OubYjUjUKjUFfmsx88gxwZ/pGa75enZMxAFDahn pPTjJ5whEY/p2neYzoEf+fyrZ/A2vQbfcQXhRGIJbuf2Vg2nzZZ9znZRQL7Nfti1SgaG mu6pPuCN6FObTpddjyWBuKFm80oXPQsRcRb0lhgnIkaL7b8r1eXsBBxvIo+SZTPuJpEJ lTPy6swhdI86soJ7rrkmmvW+uTJ8NuGb7Uab3CQGByTg91z2+gwAt/p2SMynMBYN2q7x jPMZ967ynuJTOUEmx9MLMrx025B2KioLNHeeBA0asqpOThFQDH7Y+ewJpN3NHcNdbgCi quVw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c14si6277979ede.189.2021.07.03.10.09.19; Sat, 03 Jul 2021 10:09:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229561AbhGCRKy (ORCPT + 99 others); Sat, 3 Jul 2021 13:10:54 -0400 Received: from mail.kernel.org ([198.145.29.99]:51164 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229463AbhGCRKw (ORCPT ); Sat, 3 Jul 2021 13:10:52 -0400 Received: from jic23-huawei (cpc108967-cmbg20-2-0-cust86.5-4.cable.virginm.net [81.101.6.87]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 966E961930; Sat, 3 Jul 2021 17:08:16 +0000 (UTC) Date: Sat, 3 Jul 2021 18:10:39 +0100 From: Jonathan Cameron To: Alexandru Ardelean Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, srinivas.pandruvada@linux.intel.com, jikos@kernel.org Subject: Re: [PATCH] iio: hid-sensors: bind IIO channels alloc to device object Message-ID: <20210703181039.2e468029@jic23-huawei> In-Reply-To: <20210630123029.759609-1-aardelean@deviqon.com> References: <20210630123029.759609-1-aardelean@deviqon.com> X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 30 Jun 2021 15:30:29 +0300 Alexandru Ardelean wrote: > Some HID drivers use devm_kmemdup() already to clone the template IIO > channels information and update it. > However, there are still some drivers that kmemdup() and kfree() the > channels. > > This change converts them to use devm_kmemdup() and bind the life-time of > this allocated object to the parent device object (in these drivers). > > Signed-off-by: Alexandru Ardelean All look good to me, plus it's the same thing already done in hid-sensors-magn-3d so should be fine :) Srinivas, if you have time to sanity check that would be great. No huge rush given we are in the merge window. Thanks, Jonathan > --- > drivers/iio/accel/hid-sensor-accel-3d.c | 10 ++++------ > drivers/iio/gyro/hid-sensor-gyro-3d.c | 11 ++++------- > drivers/iio/light/hid-sensor-als.c | 11 ++++------- > drivers/iio/light/hid-sensor-prox.c | 11 ++++------- > drivers/iio/orientation/hid-sensor-incl-3d.c | 11 ++++------- > drivers/iio/pressure/hid-sensor-press.c | 11 ++++------- > 6 files changed, 24 insertions(+), 41 deletions(-) > > diff --git a/drivers/iio/accel/hid-sensor-accel-3d.c b/drivers/iio/accel/hid-sensor-accel-3d.c > index 55cdca818b3b..a2def6f9380a 100644 > --- a/drivers/iio/accel/hid-sensor-accel-3d.c > +++ b/drivers/iio/accel/hid-sensor-accel-3d.c > @@ -367,7 +367,8 @@ static int hid_accel_3d_probe(struct platform_device *pdev) > dev_err(&pdev->dev, "failed to setup common attributes\n"); > return ret; > } > - indio_dev->channels = kmemdup(channel_spec, channel_size, GFP_KERNEL); > + indio_dev->channels = devm_kmemdup(&pdev->dev, channel_spec, > + channel_size, GFP_KERNEL); > > if (!indio_dev->channels) { > dev_err(&pdev->dev, "failed to duplicate channels\n"); > @@ -378,7 +379,7 @@ static int hid_accel_3d_probe(struct platform_device *pdev) > hsdev->usage, accel_state); > if (ret) { > dev_err(&pdev->dev, "failed to setup attributes\n"); > - goto error_free_dev_mem; > + return ret; > } > > indio_dev->info = &accel_3d_info; > @@ -391,7 +392,7 @@ static int hid_accel_3d_probe(struct platform_device *pdev) > &accel_state->common_attributes); > if (ret < 0) { > dev_err(&pdev->dev, "trigger setup failed\n"); > - goto error_free_dev_mem; > + return ret; > } > > ret = iio_device_register(indio_dev); > @@ -416,8 +417,6 @@ static int hid_accel_3d_probe(struct platform_device *pdev) > iio_device_unregister(indio_dev); > error_remove_trigger: > hid_sensor_remove_trigger(indio_dev, &accel_state->common_attributes); > -error_free_dev_mem: > - kfree(indio_dev->channels); > return ret; > } > > @@ -431,7 +430,6 @@ static int hid_accel_3d_remove(struct platform_device *pdev) > sensor_hub_remove_callback(hsdev, hsdev->usage); > iio_device_unregister(indio_dev); > hid_sensor_remove_trigger(indio_dev, &accel_state->common_attributes); > - kfree(indio_dev->channels); > > return 0; > } > diff --git a/drivers/iio/gyro/hid-sensor-gyro-3d.c b/drivers/iio/gyro/hid-sensor-gyro-3d.c > index bc63c2a34c5e..8f0ad022c7f1 100644 > --- a/drivers/iio/gyro/hid-sensor-gyro-3d.c > +++ b/drivers/iio/gyro/hid-sensor-gyro-3d.c > @@ -303,8 +303,8 @@ static int hid_gyro_3d_probe(struct platform_device *pdev) > return ret; > } > > - indio_dev->channels = kmemdup(gyro_3d_channels, > - sizeof(gyro_3d_channels), GFP_KERNEL); > + indio_dev->channels = devm_kmemdup(&pdev->dev, gyro_3d_channels, > + sizeof(gyro_3d_channels), GFP_KERNEL); > if (!indio_dev->channels) { > dev_err(&pdev->dev, "failed to duplicate channels\n"); > return -ENOMEM; > @@ -315,7 +315,7 @@ static int hid_gyro_3d_probe(struct platform_device *pdev) > HID_USAGE_SENSOR_GYRO_3D, gyro_state); > if (ret) { > dev_err(&pdev->dev, "failed to setup attributes\n"); > - goto error_free_dev_mem; > + return ret; > } > > indio_dev->num_channels = ARRAY_SIZE(gyro_3d_channels); > @@ -329,7 +329,7 @@ static int hid_gyro_3d_probe(struct platform_device *pdev) > &gyro_state->common_attributes); > if (ret < 0) { > dev_err(&pdev->dev, "trigger setup failed\n"); > - goto error_free_dev_mem; > + return ret; > } > > ret = iio_device_register(indio_dev); > @@ -354,8 +354,6 @@ static int hid_gyro_3d_probe(struct platform_device *pdev) > iio_device_unregister(indio_dev); > error_remove_trigger: > hid_sensor_remove_trigger(indio_dev, &gyro_state->common_attributes); > -error_free_dev_mem: > - kfree(indio_dev->channels); > return ret; > } > > @@ -369,7 +367,6 @@ static int hid_gyro_3d_remove(struct platform_device *pdev) > sensor_hub_remove_callback(hsdev, HID_USAGE_SENSOR_GYRO_3D); > iio_device_unregister(indio_dev); > hid_sensor_remove_trigger(indio_dev, &gyro_state->common_attributes); > - kfree(indio_dev->channels); > > return 0; > } > diff --git a/drivers/iio/light/hid-sensor-als.c b/drivers/iio/light/hid-sensor-als.c > index 2ff252c75c03..5a1a625d8d16 100644 > --- a/drivers/iio/light/hid-sensor-als.c > +++ b/drivers/iio/light/hid-sensor-als.c > @@ -294,8 +294,8 @@ static int hid_als_probe(struct platform_device *pdev) > return ret; > } > > - indio_dev->channels = kmemdup(als_channels, > - sizeof(als_channels), GFP_KERNEL); > + indio_dev->channels = devm_kmemdup(&pdev->dev, als_channels, > + sizeof(als_channels), GFP_KERNEL); > if (!indio_dev->channels) { > dev_err(&pdev->dev, "failed to duplicate channels\n"); > return -ENOMEM; > @@ -306,7 +306,7 @@ static int hid_als_probe(struct platform_device *pdev) > HID_USAGE_SENSOR_ALS, als_state); > if (ret) { > dev_err(&pdev->dev, "failed to setup attributes\n"); > - goto error_free_dev_mem; > + return ret; > } > > indio_dev->num_channels = > @@ -321,7 +321,7 @@ static int hid_als_probe(struct platform_device *pdev) > &als_state->common_attributes); > if (ret < 0) { > dev_err(&pdev->dev, "trigger setup failed\n"); > - goto error_free_dev_mem; > + return ret; > } > > ret = iio_device_register(indio_dev); > @@ -346,8 +346,6 @@ static int hid_als_probe(struct platform_device *pdev) > iio_device_unregister(indio_dev); > error_remove_trigger: > hid_sensor_remove_trigger(indio_dev, &als_state->common_attributes); > -error_free_dev_mem: > - kfree(indio_dev->channels); > return ret; > } > > @@ -361,7 +359,6 @@ static int hid_als_remove(struct platform_device *pdev) > sensor_hub_remove_callback(hsdev, HID_USAGE_SENSOR_ALS); > iio_device_unregister(indio_dev); > hid_sensor_remove_trigger(indio_dev, &als_state->common_attributes); > - kfree(indio_dev->channels); > > return 0; > } > diff --git a/drivers/iio/light/hid-sensor-prox.c b/drivers/iio/light/hid-sensor-prox.c > index 1621530f5f61..f10fa2abfe72 100644 > --- a/drivers/iio/light/hid-sensor-prox.c > +++ b/drivers/iio/light/hid-sensor-prox.c > @@ -253,8 +253,8 @@ static int hid_prox_probe(struct platform_device *pdev) > return ret; > } > > - indio_dev->channels = kmemdup(prox_channels, sizeof(prox_channels), > - GFP_KERNEL); > + indio_dev->channels = devm_kmemdup(&pdev->dev, prox_channels, > + sizeof(prox_channels), GFP_KERNEL); > if (!indio_dev->channels) { > dev_err(&pdev->dev, "failed to duplicate channels\n"); > return -ENOMEM; > @@ -265,7 +265,7 @@ static int hid_prox_probe(struct platform_device *pdev) > HID_USAGE_SENSOR_PROX, prox_state); > if (ret) { > dev_err(&pdev->dev, "failed to setup attributes\n"); > - goto error_free_dev_mem; > + return ret; > } > > indio_dev->num_channels = ARRAY_SIZE(prox_channels); > @@ -279,7 +279,7 @@ static int hid_prox_probe(struct platform_device *pdev) > &prox_state->common_attributes); > if (ret) { > dev_err(&pdev->dev, "trigger setup failed\n"); > - goto error_free_dev_mem; > + return ret; > } > > ret = iio_device_register(indio_dev); > @@ -304,8 +304,6 @@ static int hid_prox_probe(struct platform_device *pdev) > iio_device_unregister(indio_dev); > error_remove_trigger: > hid_sensor_remove_trigger(indio_dev, &prox_state->common_attributes); > -error_free_dev_mem: > - kfree(indio_dev->channels); > return ret; > } > > @@ -319,7 +317,6 @@ static int hid_prox_remove(struct platform_device *pdev) > sensor_hub_remove_callback(hsdev, HID_USAGE_SENSOR_PROX); > iio_device_unregister(indio_dev); > hid_sensor_remove_trigger(indio_dev, &prox_state->common_attributes); > - kfree(indio_dev->channels); > > return 0; > } > diff --git a/drivers/iio/orientation/hid-sensor-incl-3d.c b/drivers/iio/orientation/hid-sensor-incl-3d.c > index c0079e2c8807..ba5b581d5b25 100644 > --- a/drivers/iio/orientation/hid-sensor-incl-3d.c > +++ b/drivers/iio/orientation/hid-sensor-incl-3d.c > @@ -326,8 +326,8 @@ static int hid_incl_3d_probe(struct platform_device *pdev) > return ret; > } > > - indio_dev->channels = kmemdup(incl_3d_channels, > - sizeof(incl_3d_channels), GFP_KERNEL); > + indio_dev->channels = devm_kmemdup(&pdev->dev, incl_3d_channels, > + sizeof(incl_3d_channels), GFP_KERNEL); > if (!indio_dev->channels) { > dev_err(&pdev->dev, "failed to duplicate channels\n"); > return -ENOMEM; > @@ -339,7 +339,7 @@ static int hid_incl_3d_probe(struct platform_device *pdev) > incl_state); > if (ret) { > dev_err(&pdev->dev, "failed to setup attributes\n"); > - goto error_free_dev_mem; > + return ret; > } > > indio_dev->num_channels = ARRAY_SIZE(incl_3d_channels); > @@ -353,7 +353,7 @@ static int hid_incl_3d_probe(struct platform_device *pdev) > &incl_state->common_attributes); > if (ret) { > dev_err(&pdev->dev, "trigger setup failed\n"); > - goto error_free_dev_mem; > + return ret; > } > > ret = iio_device_register(indio_dev); > @@ -379,8 +379,6 @@ static int hid_incl_3d_probe(struct platform_device *pdev) > iio_device_unregister(indio_dev); > error_remove_trigger: > hid_sensor_remove_trigger(indio_dev, &incl_state->common_attributes); > -error_free_dev_mem: > - kfree(indio_dev->channels); > return ret; > } > > @@ -394,7 +392,6 @@ static int hid_incl_3d_remove(struct platform_device *pdev) > sensor_hub_remove_callback(hsdev, HID_USAGE_SENSOR_INCLINOMETER_3D); > iio_device_unregister(indio_dev); > hid_sensor_remove_trigger(indio_dev, &incl_state->common_attributes); > - kfree(indio_dev->channels); > > return 0; > } > diff --git a/drivers/iio/pressure/hid-sensor-press.c b/drivers/iio/pressure/hid-sensor-press.c > index 10c52b8df2ba..dcd593c426b4 100644 > --- a/drivers/iio/pressure/hid-sensor-press.c > +++ b/drivers/iio/pressure/hid-sensor-press.c > @@ -259,8 +259,8 @@ static int hid_press_probe(struct platform_device *pdev) > return ret; > } > > - indio_dev->channels = kmemdup(press_channels, sizeof(press_channels), > - GFP_KERNEL); > + indio_dev->channels = devm_kmemdup(&pdev->dev, press_channels, > + sizeof(press_channels), GFP_KERNEL); > if (!indio_dev->channels) { > dev_err(&pdev->dev, "failed to duplicate channels\n"); > return -ENOMEM; > @@ -271,7 +271,7 @@ static int hid_press_probe(struct platform_device *pdev) > HID_USAGE_SENSOR_PRESSURE, press_state); > if (ret) { > dev_err(&pdev->dev, "failed to setup attributes\n"); > - goto error_free_dev_mem; > + return ret; > } > > indio_dev->num_channels = > @@ -286,7 +286,7 @@ static int hid_press_probe(struct platform_device *pdev) > &press_state->common_attributes); > if (ret) { > dev_err(&pdev->dev, "trigger setup failed\n"); > - goto error_free_dev_mem; > + return ret; > } > > ret = iio_device_register(indio_dev); > @@ -311,8 +311,6 @@ static int hid_press_probe(struct platform_device *pdev) > iio_device_unregister(indio_dev); > error_remove_trigger: > hid_sensor_remove_trigger(indio_dev, &press_state->common_attributes); > -error_free_dev_mem: > - kfree(indio_dev->channels); > return ret; > } > > @@ -326,7 +324,6 @@ static int hid_press_remove(struct platform_device *pdev) > sensor_hub_remove_callback(hsdev, HID_USAGE_SENSOR_PRESSURE); > iio_device_unregister(indio_dev); > hid_sensor_remove_trigger(indio_dev, &press_state->common_attributes); > - kfree(indio_dev->channels); > > return 0; > }