Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp3125780imw; Mon, 18 Jul 2022 02:36:08 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sRj/jI1MdzYYY8PkyJxLIG9yeh1vEZNZZ77Q634n1TXS5VNhuvtLQCJZuhPyk/M3xFMH2j X-Received: by 2002:aa7:c784:0:b0:43a:caa8:75b9 with SMTP id n4-20020aa7c784000000b0043acaa875b9mr35045504eds.311.1658136967858; Mon, 18 Jul 2022 02:36:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658136967; cv=none; d=google.com; s=arc-20160816; b=L50/zF01zu3z7WHcC6IviNAEmtsWDe/yCMd84E5VSUIIo/oOYailvk5RRlcK8mj+3i BTq87j4jrgL02LxgsFjO6gREj8b1moXtgtthYJcrmyBlEOnnWVWuxIuqhJdreN1y1+KV bJZPNy2+W084+UL6XYWWSFQaGrnQygr7ksTZs8IHD5uSLw5V3yXk4dmhxGfm5QfQFSaH bG0EQLoGO3B603B7YxqDYl6AlgLp5zhsXzzoraHB7BtCTBavTcDn4DU8jHhTvoLJEi0g gL4lCiTR/LOohx8sCQ8ZNMN582vJM1qM81ASVWNyV52XH5oZA9+2C7tnKW4qmvHokfPT LIEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:message-id:references :in-reply-to:subject:cc:to:from:date:mime-version; bh=CEC2cGRS53hEVrkUBzRnQFIfxGN/TO0ypejIgHGQl4I=; b=LsPvfkK2X47NwizxQV5xyV6mcIVDndhyOqhP5IN53rBck+iZPWOEe4ES5mcPjrxsZo m+hXGApbd4PxVXMfGb0ymfWxP6jgV0TCweGqh/YKclJlE/4I9lqiKuDZC2lMnkRzZuIy ujZnlwAaxHqw0YlMz5MDznWIrOkzBgw+IQkEmZuqpk+G8cFIIcG9extbZMh+B27u/MH5 OEth8ewXgunpkXCcTMdi26vIpQJuKuNpuys6mgZxsqGEe6TVLmi5pv3/go3VNy5J0zBA CnYpUNejbHEt7z29Hf2ooTjpNh2Sw41hKc/W1xKOM/y6DZe6Zt2Uf/S0ePKzFL0Ogi7K A1+Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f24-20020a056402329800b0043a897d1de2si15014408eda.128.2022.07.18.02.35.42; Mon, 18 Jul 2022 02:36:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233962AbiGRJZV (ORCPT + 99 others); Mon, 18 Jul 2022 05:25:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51028 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233663AbiGRJZT (ORCPT ); Mon, 18 Jul 2022 05:25:19 -0400 Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [217.70.183.199]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CAC9F19025; Mon, 18 Jul 2022 02:25:16 -0700 (PDT) Received: (Authenticated sender: contact@artur-rojek.eu) by mail.gandi.net (Postfix) with ESMTPA id 23266FF80B; Mon, 18 Jul 2022 09:25:12 +0000 (UTC) MIME-Version: 1.0 Date: Mon, 18 Jul 2022 11:25:12 +0200 From: Artur Rojek To: Dmitry Torokhov Cc: Jonathan Cameron , linux-kernel@vger.kernel.org, linux-input@vger.kernel.org Subject: Re: [PATCH] Input: adc-joystick - fix ordering in adc_joystick_probe() In-Reply-To: References: Message-ID: X-Sender: contact@artur-rojek.eu Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2022-07-09 06:35, Dmitry Torokhov wrote: > We should register the IIO buffer before we register the input device, > because as soon as the device is registered input handlers may attach > to > it, resulting in a call to adc_joystick_open() which makes use of the > said > buffer. > > Signed-off-by: Dmitry Torokhov > --- > > Not tested on hardware... Hi Dmitry, nice catch, thanks! I will verify the operation on hardware some time over the weekend. Small nitpick inline. With that changed: Acked-by: Artur Rojek > > drivers/input/joystick/adc-joystick.c | 15 ++++++++------- > 1 file changed, 8 insertions(+), 7 deletions(-) > > diff --git a/drivers/input/joystick/adc-joystick.c > b/drivers/input/joystick/adc-joystick.c > index 78ebca7d400a..e0cfdc84763f 100644 > --- a/drivers/input/joystick/adc-joystick.c > +++ b/drivers/input/joystick/adc-joystick.c > @@ -222,13 +222,6 @@ static int adc_joystick_probe(struct > platform_device *pdev) > if (error) > return error; > > - input_set_drvdata(input, joy); > - error = input_register_device(input); > - if (error) { > - dev_err(dev, "Unable to register input device\n"); > - return error; > - } > - > joy->buffer = iio_channel_get_all_cb(dev, adc_joystick_handle, joy); > if (IS_ERR(joy->buffer)) { > dev_err(dev, "Unable to allocate callback buffer\n"); > @@ -241,6 +234,14 @@ static int adc_joystick_probe(struct > platform_device *pdev) > return error; > } > > + input_set_drvdata(input, joy); > + > + error = input_register_device(input); > + if (error) { > + dev_err(dev, "Unable to register input device\n"); > + return error; > + } > + > return 0; Since this is now the last thing the function does, we can simplify the code a bit: ``` error = input_register_device(input); if (error) dev_err(dev, "Unable to register input device\n"); return error; ``` Cheers, Artur > } > > -- > 2.37.0.144.g8ac04bfd2-goog