From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752723AbaEGWWS (ORCPT ); Wed, 7 May 2014 18:22:18 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:58012 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751744AbaEGWWO (ORCPT ); Wed, 7 May 2014 18:22:14 -0400 Date: Wed, 7 May 2014 15:22:13 -0700 From: Andrew Morton To: Alan Cox Cc: Raghavendra Ganiga , a.zummo@towertech.it, rtc-linux@googlegroups.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH] rtc: add support for maxim dallas rtc ds1343 and ds1344 Message-Id: <20140507152213.f7eaf5644ccbb8c6059739f4@linux-foundation.org> In-Reply-To: <20140507231529.4a3810e5@www.etchedpixels.co.uk> References: <1399403036-11377-1-git-send-email-ravi23ganiga@gmail.com> <20140507144248.cf3d5e7411186e2cd616ded8@linux-foundation.org> <20140507231529.4a3810e5@www.etchedpixels.co.uk> X-Mailer: Sylpheed 3.2.0beta5 (GTK+ 2.24.10; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 7 May 2014 23:15:29 +0100 Alan Cox wrote: > On Wed, 7 May 2014 14:42:48 -0700 > Andrew Morton wrote: > > > On Wed, 7 May 2014 00:33:56 +0530 Raghavendra Ganiga wrote: > > > > > This is a patch to add support for > > > maxim dallas rtc ds1343 and ds1344 > > > > > > ... > > > > > > +static int ds1343_ioctl(struct device *dev, unsigned int cmd, unsigned long arg) > > > +{ > > > + switch (cmd) { > > > +#ifdef RTC_SET_CHARGE > > > + case RTC_SET_CHARGE: > > > + { > > > + int val; > > > + > > > + if (copy_from_user(&val, (int __user *)arg, sizeof(int))) > > > + return -EFAULT; > > > + > > > + return regmap_write(priv->map, DS1343_TRICKLE_REG, val); > > > + } > > > + break; > > > +#endif > > > + } > > > > Why is RTC_SET_CHARGE defined only for m32r? It seems pretty generic? > > > > > + return -ENOIOCTLCMD; > > > +} > > > > It's possible that this should be -ENOTTY. I always forget the rule, > > but Alan never forgets anything ;) > > I forget lots 8) > > -ENOTTY if it will be returned to user space, -ENOIOCTLCMD is used by > some core code internally as a way for the sub drivers to tell the core > "I didn't handle this, maybe you have a default method ?" Ah OK, thanks. drivers/rtc/rtc-dev.c does default: /* Finally try the driver's ioctl interface */ if (ops->ioctl) { err = ops->ioctl(rtc->dev.parent, cmd, arg); if (err == -ENOIOCTLCMD) err = -ENOTTY; } else err = -ENOTTY; so ENOIOCTLCMD is appropriate here. Even though rtc is upside down - it prioritises the core's ioctl parsing ahead of the drivers'.