Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp3017579ybd; Fri, 28 Jun 2019 01:15:07 -0700 (PDT) X-Google-Smtp-Source: APXvYqwFk1dOFZkgBKiDvX+LBsPjuVnGHCpgfagbgt+9ukjqsCYa3GcRsAG1FaBD//h6t0gV8Rz1 X-Received: by 2002:a17:902:102c:: with SMTP id b41mr9835213pla.204.1561709707169; Fri, 28 Jun 2019 01:15:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561709707; cv=none; d=google.com; s=arc-20160816; b=yJwSctl3zHz/CCItUilyPUxJX2A/1Ahr+U2tDeccVlYflZ5uHxwTAIjrIAC5VHyypH swMl8tAKc9ESJeHGenw+IW4lZmC2IOfCqsRHPApGsiMlv4ii3IbjvfiAN79X8lmNAawL R0du7C2Ugh+EARHfkPUS5AILO8dhLeDx1qcWcaPNngaDqqcT5SKo2ygf8AjhWPV1dEJQ XmfXv9M2OVMGYXza+DA1SnQhNHZxaArGvY+KLmj93L2zwhrcW444sioa/7jNnXokT5Ex dzCit5q+15yeOovog/ci/XE+GsG9cwakC2jOS+vKRjozuXypJnoy5DRcUywZ2kd3wsVn 9/MA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=9nEX3QPkFO4Gadm7eTqR9PBiRvdkGckSs4RCDEyP6LE=; b=SRWZ6J7f1q17FM6mUpQ8Qbfvs8Bpy3W0Js44n1NmvJAppNPqPtZtJ66YSL3cB01Mxd kVFbX8Kyr1Ho+5dljf3AVc4VLyBfiK9kxVHfg7238IysqsHFSacX0BB0SjzKfCUE/QdZ keWVkZ1NYWhm+0tQW+s1b+MNaHjc0Md3oZhKLsN6stCn2fijBZXwNk7Kxqo1ypm57mEC HY4OkgRmZ0xZiefTlpHokaybJk8axuAHydObw807VEFCTSeCXj9xdwcxdI4/lSd+49MP FILlMnJfPe2p5p7iGP8vef0DIS+wslCXqlrHP7ztAc4PJb6MXSBaUZB6nbCKusUWKCIu OsoA== 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 v18si1466715ply.276.2019.06.28.01.14.51; Fri, 28 Jun 2019 01:15:07 -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 S1726657AbfF1INB (ORCPT + 99 others); Fri, 28 Jun 2019 04:13:01 -0400 Received: from mail.steuer-voss.de ([85.183.69.95]:40430 "EHLO mail.steuer-voss.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725873AbfF1INB (ORCPT ); Fri, 28 Jun 2019 04:13:01 -0400 X-Virus-Scanned: Debian amavisd-new at mail.steuer-voss.de Received: from pc-niv.weinmann.com (localhost [127.0.0.1]) by mail.steuer-voss.de (Postfix) with ESMTP id B6AF643EAA; Fri, 28 Jun 2019 10:12:57 +0200 (CEST) From: Nikolaus Voss To: Heikki Krogerus , Greg Kroah-Hartman Cc: Nikolaus Voss , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, nv@vosn.de Subject: [PATCH] drivers/usb/typec/tps6598x.c: fix two bugs Date: Fri, 28 Jun 2019 10:12:35 +0200 Message-Id: <20190628081235.19205-1-nikolaus.voss@loewensteinmedical.de> X-Mailer: git-send-email 2.17.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 1. Portinfo bit field is 3 bits wide, not 2 bits. This led to a wrong driver configuration for some tps6598x configurations. 2. Writing 4CC commands with tps6598x_write_4cc() already has a pointer arg, don't reference it when using as arg to tps6598x_block_write(). Correcting this enforces the constness of the pointer to propagate to tps6598x_block_write(), so add the const qualifier there to avoid the warning. Signed-off-by: Nikolaus Voss --- drivers/usb/typec/tps6598x.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/usb/typec/tps6598x.c b/drivers/usb/typec/tps6598x.c index c674abe3cf99..a38d1409f15b 100644 --- a/drivers/usb/typec/tps6598x.c +++ b/drivers/usb/typec/tps6598x.c @@ -41,7 +41,7 @@ #define TPS_STATUS_VCONN(s) (!!((s) & BIT(7))) /* TPS_REG_SYSTEM_CONF bits */ -#define TPS_SYSCONF_PORTINFO(c) ((c) & 3) +#define TPS_SYSCONF_PORTINFO(c) ((c) & 7) enum { TPS_PORTINFO_SINK, @@ -127,7 +127,7 @@ tps6598x_block_read(struct tps6598x *tps, u8 reg, void *val, size_t len) } static int tps6598x_block_write(struct tps6598x *tps, u8 reg, - void *val, size_t len) + const void *val, size_t len) { u8 data[TPS_MAX_LEN + 1]; @@ -173,7 +173,7 @@ static inline int tps6598x_write64(struct tps6598x *tps, u8 reg, u64 val) static inline int tps6598x_write_4cc(struct tps6598x *tps, u8 reg, const char *val) { - return tps6598x_block_write(tps, reg, &val, sizeof(u32)); + return tps6598x_block_write(tps, reg, val, 4); } static int tps6598x_read_partner_identity(struct tps6598x *tps) -- 2.17.1