From patchwork Thu Feb 9 21:25:08 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 9565513 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2DA7C60236 for ; Thu, 9 Feb 2017 21:25:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 096CC28540 for ; Thu, 9 Feb 2017 21:25:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F0F2028551; Thu, 9 Feb 2017 21:25:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 66B5F28540 for ; Thu, 9 Feb 2017 21:25:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932117AbdBIVZg (ORCPT ); Thu, 9 Feb 2017 16:25:36 -0500 Received: from mail-pg0-f68.google.com ([74.125.83.68]:33157 "EHLO mail-pg0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932086AbdBIVZf (ORCPT ); Thu, 9 Feb 2017 16:25:35 -0500 Received: by mail-pg0-f68.google.com with SMTP id 194so1269595pgd.0; Thu, 09 Feb 2017 13:25:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :user-agent; bh=Y92inGwmuplM/N+v+sjwXYz9RjzWnWP6MkViwfddOyA=; b=htmHsBzGWCvOm9HvRwyl4YgYTYPFQh4rQFq+tDZ7YbsCgPZQVZe8qYiZmoyVDqkz2d c0QCI4PWPHlxRpCF7KiDkmCqAx8Ska3KKU57qgRmSV6twgebb31vjXrPxmTt6b9Vy32d Un4SlyKPk6PYqBg3zCRmLbPetgWzyDmm21dsyDttEDsX3RJd5kxuYxxb/bZgSchvp7/y sCFQVRUKUz++AV83EteJL+PK2KPQ334CQBNzGZLQwxEF9HClKbQvabbBiTtO7T1AuctU QJv4cXlpA0S3OCGLP0fRdQhTLC8bENyGA4shfAFoIrl6fpBOoMefnT05i1yDV8ln7h8E lfRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:user-agent; bh=Y92inGwmuplM/N+v+sjwXYz9RjzWnWP6MkViwfddOyA=; b=h0n1b+n6pSPmf3VH5HBGBHBMw++MA2MykPFZbmbC1mBelO/ti7XUi/f5a9PSBYwx/N mG11yWA5ENIcevCxERzonfZbPTsm1aHe4FJstT6GhABt8XDpd4rhDlaDKZ+aWR3vLTS9 O/8qWD2w5ixPijazDpcOHPqCFaFO9jdkoEuDe47iIkxSIuLvlPzwWAc6vN5FJ6yJuHJk o7DDnm9VBi/tRtSPfYKW7Ps/u2vatjUmAjY2UCji54OWPrk6jB9NrWfR3COBzRHIKLD8 LwLwEo57fVb4V4exIp56joVfM5eWpQClVfxWPq4ZZRAHTq9Tpw6SBXjunfpIQtbp8Bg8 A/bQ== X-Gm-Message-State: AMke39mDKg8wIknETa7x5ivsDKxBl9CGZ5fGTvegGW2r+A3vlDUP3fg5Ns7ItTi1FceVwA== X-Received: by 10.98.23.207 with SMTP id 198mr6030106pfx.103.1486675511108; Thu, 09 Feb 2017 13:25:11 -0800 (PST) Received: from dtor-ws ([2620:0:1000:1311:823:78f2:9247:f8e6]) by smtp.gmail.com with ESMTPSA id u75sm31390004pgc.31.2017.02.09.13.25.10 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Thu, 09 Feb 2017 13:25:10 -0800 (PST) Date: Thu, 9 Feb 2017 13:25:08 -0800 From: Dmitry Torokhov To: linux-input@vger.kernel.org Cc: Benjamin Tissoires , Andrew Duggan , Nick Dyer , Christopher Heiny , linux-kernel@vger.kernel.org Subject: [PATCH] Input: synaptics-rmi4 - create firmware update sysfs attribute in F34 Message-ID: <20170209212508.GA24684@dtor-ws> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP There is no need to create sysfs attributes in the main driver core, let F34 implementation do that. Signed-off-by: Dmitry Torokhov --- drivers/input/rmi4/rmi_driver.c | 5 --- drivers/input/rmi4/rmi_driver.h | 14 ------- drivers/input/rmi4/rmi_f34.c | 87 +++++++++++++++++++++++------------------ 3 files changed, 50 insertions(+), 56 deletions(-) diff --git a/drivers/input/rmi4/rmi_driver.c b/drivers/input/rmi4/rmi_driver.c index d64fc92858f2..d9cfe4ec93fa 100644 --- a/drivers/input/rmi4/rmi_driver.c +++ b/drivers/input/rmi4/rmi_driver.c @@ -1001,7 +1001,6 @@ static int rmi_driver_remove(struct device *dev) rmi_disable_irq(rmi_dev, false); - rmi_f34_remove_sysfs(rmi_dev); rmi_free_function_list(rmi_dev); return 0; @@ -1215,10 +1214,6 @@ static int rmi_driver_probe(struct device *dev) if (retval) goto err; - retval = rmi_f34_create_sysfs(rmi_dev); - if (retval) - goto err; - if (data->input) { rmi_driver_set_input_name(rmi_dev, data->input); if (!rmi_dev->xport->input) { diff --git a/drivers/input/rmi4/rmi_driver.h b/drivers/input/rmi4/rmi_driver.h index f1a2a2266022..1ada14d7d005 100644 --- a/drivers/input/rmi4/rmi_driver.h +++ b/drivers/input/rmi4/rmi_driver.h @@ -120,20 +120,6 @@ static inline int rmi_f03_overwrite_button(struct rmi_function *fn, static inline void rmi_f03_commit_buttons(struct rmi_function *fn) {} #endif -#ifdef CONFIG_RMI4_F34 -int rmi_f34_create_sysfs(struct rmi_device *rmi_dev); -void rmi_f34_remove_sysfs(struct rmi_device *rmi_dev); -#else -static inline int rmi_f34_create_sysfs(struct rmi_device *rmi_dev) -{ - return 0; -} - -static inline void rmi_f34_remove_sysfs(struct rmi_device *rmi_dev) -{ -} -#endif /* CONFIG_RMI_F34 */ - extern struct rmi_function_handler rmi_f01_handler; extern struct rmi_function_handler rmi_f03_handler; extern struct rmi_function_handler rmi_f11_handler; diff --git a/drivers/input/rmi4/rmi_f34.c b/drivers/input/rmi4/rmi_f34.c index 425fe140e9df..d4d5297d5a8b 100644 --- a/drivers/input/rmi4/rmi_f34.c +++ b/drivers/input/rmi4/rmi_f34.c @@ -509,33 +509,21 @@ static struct attribute_group rmi_firmware_attr_group = { .attrs = rmi_firmware_attrs, }; -static int rmi_f34_probe(struct rmi_function *fn) +static int rmi_f34v5_probe(struct f34_data *f34) { - struct f34_data *f34; - unsigned char f34_queries[9]; + struct rmi_function *fn = f34->fn; + u8 f34_queries[9]; bool has_config_id; - u8 version = fn->fd.function_version; - int ret; - - f34 = devm_kzalloc(&fn->dev, sizeof(struct f34_data), GFP_KERNEL); - if (!f34) - return -ENOMEM; - - f34->fn = fn; - dev_set_drvdata(&fn->dev, f34); - - /* v5 code only supported version 0, try V7 probe */ - if (version > 0) - return rmi_f34v7_probe(f34); + int error; f34->bl_version = 5; - ret = rmi_read_block(fn->rmi_dev, fn->fd.query_base_addr, - f34_queries, sizeof(f34_queries)); - if (ret) { - dev_err(&fn->dev, "%s: Failed to query properties\n", - __func__); - return ret; + error = rmi_read_block(fn->rmi_dev, fn->fd.query_base_addr, + f34_queries, sizeof(f34_queries)); + if (error) { + dev_err(&fn->dev, "%s: Failed to query properties: %d\n", + __func__, error); + return error; } snprintf(f34->bootloader_id, sizeof(f34->bootloader_id), @@ -548,8 +536,8 @@ static int rmi_f34_probe(struct rmi_function *fn) f34->v5.fw_blocks = get_unaligned_le16(&f34_queries[5]); f34->v5.config_blocks = get_unaligned_le16(&f34_queries[7]); f34->v5.ctrl_address = fn->fd.data_base_addr + F34_BLOCK_DATA_OFFSET + - f34->v5.block_size; - has_config_id = f34_queries[2] & (1 << 2); + f34->v5.block_size; + has_config_id = f34_queries[2] & BIT(2); rmi_dbg(RMI_DEBUG_FN, &fn->dev, "Bootloader ID: %s\n", f34->bootloader_id); @@ -561,11 +549,11 @@ static int rmi_f34_probe(struct rmi_function *fn) f34->v5.config_blocks); if (has_config_id) { - ret = rmi_read_block(fn->rmi_dev, fn->fd.control_base_addr, - f34_queries, sizeof(f34_queries)); - if (ret) { + error = rmi_read_block(fn->rmi_dev, fn->fd.control_base_addr, + f34_queries, sizeof(f34_queries)); + if (error) { dev_err(&fn->dev, "Failed to read F34 config ID\n"); - return ret; + return error; } snprintf(f34->configuration_id, sizeof(f34->configuration_id), @@ -580,21 +568,46 @@ static int rmi_f34_probe(struct rmi_function *fn) return 0; } -int rmi_f34_create_sysfs(struct rmi_device *rmi_dev) +static int rmi_f34_probe(struct rmi_function *fn) { - return sysfs_create_group(&rmi_dev->dev.kobj, &rmi_firmware_attr_group); + struct f34_data *f34; + u8 version = fn->fd.function_version; + int error; + + f34 = devm_kzalloc(&fn->dev, sizeof(struct f34_data), GFP_KERNEL); + if (!f34) + return -ENOMEM; + + f34->fn = fn; + dev_set_drvdata(&fn->dev, f34); + + /* v5 code only supported version 0 */ + error = version > 0 ? rmi_f34v7_probe(f34) : rmi_f34v5_probe(f34); + if (error) + return error; + + error = sysfs_create_group(&fn->rmi_dev->dev.kobj, + &rmi_firmware_attr_group); + if (error) { + dev_err(&fn->dev, "%s: Failed to create sysfs attributes: %d\n", + __func__, error); + return error; + } + + return 0; } -void rmi_f34_remove_sysfs(struct rmi_device *rmi_dev) +static void rmi_f34_remove(struct rmi_function *fn) { - sysfs_remove_group(&rmi_dev->dev.kobj, &rmi_firmware_attr_group); + sysfs_remove_group(&fn->rmi_dev->dev.kobj, &rmi_firmware_attr_group); } struct rmi_function_handler rmi_f34_handler = { - .driver = { - .name = "rmi4_f34", + .driver = { + .name = "rmi4_f34", }, - .func = 0x34, - .probe = rmi_f34_probe, - .attention = rmi_f34_attention, + .func = 0x34, + .probe = rmi_f34_probe, + .remove = rmi_f34_remove, + .attention = rmi_f34_attention, };