Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752676AbdIBMAA (ORCPT ); Sat, 2 Sep 2017 08:00:00 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39164 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751652AbdIBL76 (ORCPT ); Sat, 2 Sep 2017 07:59:58 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 268FF4E4D4 Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=hdegoede@redhat.com Subject: Re: [PATCH 03/11] mux: consumer.h: Add MUX_USB_* state constant defines To: Andy Shevchenko Cc: MyungJoo Ham , Chanwoo Choi , Guenter Roeck , Heikki Krogerus , Darren Hart , Andy Shevchenko , Peter Rosin , Mathias Nyman , Platform Driver , devel@driverdev.osuosl.org, Kuppuswamy Sathyanarayanan , Sathyanarayanan Kuppuswamy Natarajan , "linux-kernel@vger.kernel.org" , Greg Kroah-Hartman , USB References: <20170901214845.7153-1-hdegoede@redhat.com> <20170901214845.7153-4-hdegoede@redhat.com> From: Hans de Goede Message-ID: Date: Sat, 2 Sep 2017 13:59:53 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Sat, 02 Sep 2017 11:59:58 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1556 Lines: 38 Hi, On 02-09-17 12:10, Andy Shevchenko wrote: > On Sat, Sep 2, 2017 at 12:48 AM, Hans de Goede wrote: >> Add MUX_USB_* state constant defines, which can be used by USB >> device/host and Type-C polarity/role/altmode mux drivers and consumers >> to ensure that they agree on the meaning of the mux_control_select() >> state argument. > >> +/* >> + * Mux state values for USB muxes, used for both USB device/host role muxes >> + * as well as for Type-C polarity/role/altmode muxes. >> + * >> + * MUX_USB_POLARITY_INV may be or-ed together with any other mux-state as >> + * inverted-polarity (Type-C plugged in upside down) can happen with any >> + * other mux-state. >> + */ >> +#define MUX_USB_POLARITY_INV BIT(0) /* Polarity inverted bit */ >> +#define MUX_USB_NONE (1 << 1) /* Mux open / not connected */ >> +#define MUX_USB_DEVICE (2 << 1) /* USB device mode */ >> +#define MUX_USB_HOST (3 << 1) /* USB host mode */ >> +#define MUX_USB_HOST_AND_DP_SRC (4 << 1) /* USB host + 2 lanes Display Port */ >> +#define MUX_USB_DP_SRC (5 << 1) /* 4 lanes Display Port source */ >> +#define MUX_USB_STATES (6 << 1) > > I would put OR'ed bits higher. > > Like allocate 4 (8) bits for states and start special flags from bit > 8 and so on. That is not an option because the mux framework expects a mux to declare how much states it has (which is where the MUX_USB_STATES define comes in) and any attemp to set a state higher then max_states will return with -EINVAL. Regards, Hans