From patchwork Sun Feb 19 18:29:17 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Frank_Sch=C3=A4fer?= X-Patchwork-Id: 9581717 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 5B51A6043A for ; Sun, 19 Feb 2017 18:29:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4ADFA286BD for ; Sun, 19 Feb 2017 18:29:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3BACC286CD; Sun, 19 Feb 2017 18:29:09 +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.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM 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 B1140286BD for ; Sun, 19 Feb 2017 18:29:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751534AbdBSS3H (ORCPT ); Sun, 19 Feb 2017 13:29:07 -0500 Received: from mail-wm0-f68.google.com ([74.125.82.68]:35460 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751208AbdBSS3G (ORCPT ); Sun, 19 Feb 2017 13:29:06 -0500 Received: by mail-wm0-f68.google.com with SMTP id u63so10765027wmu.2 for ; Sun, 19 Feb 2017 10:29:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=na9YLytMrtAhScN/XANTWb0xBBjLQHO6zWE0ffhSt6Y=; b=nkZrgKK+mkBSLOwYOlutLJWXvkOkJgE8VWoqGxYjMpszfYmJ8kKuVxb8TLWjK9sP34 BTygTI6AncLFvEp2VkaDGCslc76QhhjMRFXfCWRg5y6XHHR067GJWUao0HRM7z/9148y b93dZcabpxpUDAAyJyjpUZWUS4tp8K7WCyvdgRz7cWcKJ7EERIG8c4jqXocBdiCCjwJ6 VdehMyuLi+1+F0rblCmpyGQ3aaVAu4495Cp1yWLiAXXWUtjuWXGRSe3crzSwRQs8ICuD 4MQeff+P8jrxzmJFVmQr8Cf8sFa7XJTdd90aInqhgs0pQLKhvJvO8jevuQbg/rpGL04L Tlmw== 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:mime-version :content-transfer-encoding; bh=na9YLytMrtAhScN/XANTWb0xBBjLQHO6zWE0ffhSt6Y=; b=f+5bv+ka2nKLFnPYM6vrJ6UkMAJ5Ugg8PCy2ysFCxp7i9GDSscTga8eO4lmA8sP1c5 e4hUq86NVpUIU294VIDsoBloDjEC9xwHf3k5B2EeUFeQQvs+4NAXOLNtxIZAMf4Kfh/h e5hBXzoJcKqs0F7voqWUb9vvZVjSa8CX9fw+alGSpSSfofn2s+edsQBqv8TnFVOQPHd6 +ROBUSN4ipYZaeVMTbCkvo3Zt2OEq7hqTDYRuD0215pKOPYXq7gOs7Nj9dveNKd/dzMC ODrIzNvnesJC4BO7Cagi9zqNQsTbONEraQ8BsnqHd/k77ICH0/hs0paJhtaDUNHtWH5N 4EOA== X-Gm-Message-State: AMke39lBNx6gTakUStJZQCpzQWTL1nyQ5+MjlL6FK7Xci4ajXnNk1BVTw4AYoamxZTzuhQ== X-Received: by 10.28.46.73 with SMTP id u70mr14097537wmu.54.1487528944705; Sun, 19 Feb 2017 10:29:04 -0800 (PST) Received: from Athlon64X2-5000.lan (ip-94-114-163-233.unity-media.net. [94.114.163.233]) by smtp.googlemail.com with ESMTPSA id u68sm10466940wrb.65.2017.02.19.10.29.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 19 Feb 2017 10:29:03 -0800 (PST) From: =?UTF-8?q?Frank=20Sch=C3=A4fer?= To: linux-media@vger.kernel.org Cc: mchehab@kernel.org, arnd@arndb.de, =?UTF-8?q?Frank=20Sch=C3=A4fer?= Subject: [PATCH 1/2] em28xx: reduce stack usage in sensor probing functions Date: Sun, 19 Feb 2017 19:29:17 +0100 Message-Id: <20170219182918.4978-1-fschaefer.oss@googlemail.com> X-Mailer: git-send-email 2.11.0 MIME-Version: 1.0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP It's no longer necessary to keep the i2c_client in the device struct unmodified until a sensor is found, so reduce stack usage in em28xx_probe_sensor_micron() and em28xx_probe_sensor_omnivision() by using a pointer to the client instead of a local copy. Reported-by: Arnd Bergmann Signed-off-by: Frank Schäfer --- drivers/media/usb/em28xx/em28xx-camera.c | 42 +++++++++++++++----------------- 1 file changed, 20 insertions(+), 22 deletions(-) diff --git a/drivers/media/usb/em28xx/em28xx-camera.c b/drivers/media/usb/em28xx/em28xx-camera.c index 89c890ba7dd6..7b4129ab1cf9 100644 --- a/drivers/media/usb/em28xx/em28xx-camera.c +++ b/drivers/media/usb/em28xx/em28xx-camera.c @@ -110,44 +110,44 @@ static int em28xx_probe_sensor_micron(struct em28xx *dev) __be16 id_be; u16 id; - struct i2c_client client = dev->i2c_client[dev->def_i2c_bus]; + struct i2c_client *client = &dev->i2c_client[dev->def_i2c_bus]; dev->em28xx_sensor = EM28XX_NOSENSOR; for (i = 0; micron_sensor_addrs[i] != I2C_CLIENT_END; i++) { - client.addr = micron_sensor_addrs[i]; + client->addr = micron_sensor_addrs[i]; /* NOTE: i2c_smbus_read_word_data() doesn't work with BE data */ /* Read chip ID from register 0x00 */ reg = 0x00; - ret = i2c_master_send(&client, ®, 1); + ret = i2c_master_send(client, ®, 1); if (ret < 0) { if (ret != -ENXIO) dev_err(&dev->intf->dev, "couldn't read from i2c device 0x%02x: error %i\n", - client.addr << 1, ret); + client->addr << 1, ret); continue; } - ret = i2c_master_recv(&client, (u8 *)&id_be, 2); + ret = i2c_master_recv(client, (u8 *)&id_be, 2); if (ret < 0) { dev_err(&dev->intf->dev, "couldn't read from i2c device 0x%02x: error %i\n", - client.addr << 1, ret); + client->addr << 1, ret); continue; } id = be16_to_cpu(id_be); /* Read chip ID from register 0xff */ reg = 0xff; - ret = i2c_master_send(&client, ®, 1); + ret = i2c_master_send(client, ®, 1); if (ret < 0) { dev_err(&dev->intf->dev, "couldn't read from i2c device 0x%02x: error %i\n", - client.addr << 1, ret); + client->addr << 1, ret); continue; } - ret = i2c_master_recv(&client, (u8 *)&id_be, 2); + ret = i2c_master_recv(client, (u8 *)&id_be, 2); if (ret < 0) { dev_err(&dev->intf->dev, "couldn't read from i2c device 0x%02x: error %i\n", - client.addr << 1, ret); + client->addr << 1, ret); continue; } /* Validate chip ID to be sure we have a Micron device */ @@ -197,7 +197,6 @@ static int em28xx_probe_sensor_micron(struct em28xx *dev) dev_info(&dev->intf->dev, "sensor %s detected\n", name); - dev->i2c_client[dev->def_i2c_bus].addr = client.addr; return 0; } @@ -213,30 +212,30 @@ static int em28xx_probe_sensor_omnivision(struct em28xx *dev) char *name; u8 reg; u16 id; - struct i2c_client client = dev->i2c_client[dev->def_i2c_bus]; + struct i2c_client *client = &dev->i2c_client[dev->def_i2c_bus]; dev->em28xx_sensor = EM28XX_NOSENSOR; /* NOTE: these devices have the register auto incrementation disabled * by default, so we have to use single byte reads ! */ for (i = 0; omnivision_sensor_addrs[i] != I2C_CLIENT_END; i++) { - client.addr = omnivision_sensor_addrs[i]; + client->addr = omnivision_sensor_addrs[i]; /* Read manufacturer ID from registers 0x1c-0x1d (BE) */ reg = 0x1c; - ret = i2c_smbus_read_byte_data(&client, reg); + ret = i2c_smbus_read_byte_data(client, reg); if (ret < 0) { if (ret != -ENXIO) dev_err(&dev->intf->dev, "couldn't read from i2c device 0x%02x: error %i\n", - client.addr << 1, ret); + client->addr << 1, ret); continue; } id = ret << 8; reg = 0x1d; - ret = i2c_smbus_read_byte_data(&client, reg); + ret = i2c_smbus_read_byte_data(client, reg); if (ret < 0) { dev_err(&dev->intf->dev, "couldn't read from i2c device 0x%02x: error %i\n", - client.addr << 1, ret); + client->addr << 1, ret); continue; } id += ret; @@ -245,20 +244,20 @@ static int em28xx_probe_sensor_omnivision(struct em28xx *dev) continue; /* Read product ID from registers 0x0a-0x0b (BE) */ reg = 0x0a; - ret = i2c_smbus_read_byte_data(&client, reg); + ret = i2c_smbus_read_byte_data(client, reg); if (ret < 0) { dev_err(&dev->intf->dev, "couldn't read from i2c device 0x%02x: error %i\n", - client.addr << 1, ret); + client->addr << 1, ret); continue; } id = ret << 8; reg = 0x0b; - ret = i2c_smbus_read_byte_data(&client, reg); + ret = i2c_smbus_read_byte_data(client, reg); if (ret < 0) { dev_err(&dev->intf->dev, "couldn't read from i2c device 0x%02x: error %i\n", - client.addr << 1, ret); + client->addr << 1, ret); continue; } id += ret; @@ -309,7 +308,6 @@ static int em28xx_probe_sensor_omnivision(struct em28xx *dev) dev_info(&dev->intf->dev, "sensor %s detected\n", name); - dev->i2c_client[dev->def_i2c_bus].addr = client.addr; return 0; }