From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753850AbcBJLYE (ORCPT ); Wed, 10 Feb 2016 06:24:04 -0500 Received: from mga09.intel.com ([134.134.136.24]:25710 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753239AbcBJLYB (ORCPT ); Wed, 10 Feb 2016 06:24:01 -0500 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.22,425,1449561600"; d="scan'208";a="881143609" Date: Wed, 10 Feb 2016 13:23:57 +0200 From: Heikki Krogerus To: Oliver Neukum Cc: Greg KH , Felipe Balbi , Mathias Nyman , linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org Subject: Re: [PATCH 1/3] usb: USB Type-C Connector Class Message-ID: <20160210112357.GE5270@kuha.fi.intel.com> References: <1455037283-106479-1-git-send-email-heikki.krogerus@linux.intel.com> <1455037283-106479-2-git-send-email-heikki.krogerus@linux.intel.com> <1455101342.8878.5.camel@suse.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1455101342.8878.5.camel@suse.com> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Oliver, > > +static ssize_t alternate_mode_store(struct device *dev, > > + struct device_attribute *attr, > > + const char *buf, size_t size) > > +{ > > + struct typec_port *port = to_typec_port(dev); > > + struct typec_alt_mode alt_mode; > > + int ret; > > + > > + if (!port->cap->set_alt_mode) { > > + dev_warn(dev, "entering Alternate Modes not supported\n"); > > + return -EOPNOTSUPP; > > + } > > + > > + if (!port->connected) > > + return -ENXIO; > > Doesn't this need locking? Yes, I need to fix the locking. > And why wouldn't user space want to preselect a mode? That is tricky, as we would need to keep a list of the preselected modes and for all SVIDs the connector supports. I don't think it would be practical to do from this file as we would then use it differently when connected and not connected, so the preselected modes would probable be better to give from a separate file. That is certainly doable, but is it really useful? I not really against adding that support, but I would like to keep this interface as simple as possible. Thanks, -- heikki