local_irq_disable(); 
rtc_ioctl(struct inode *inode, struct file *file, unsigned int cmd,	  unsigned long arg) {        unsigned long flags;	switch(cmd) {		case RTC_RD_TIME:	/* read the time/date from RTC	*/		{			struct rtc_time rtc_tm;									memset(&rtc_tm, 0, sizeof (struct rtc_time));			get_rtc_time(&rtc_tm);									if (copy_to_user((struct rtc_time*)arg, &rtc_tm, sizeof(struct rtc_time)))				return -EFAULT;				return 0;		}		case RTC_SET_TIME:	/* set the RTC */		{			struct rtc_time rtc_tm;			unsigned char mon, day, hrs, min, sec, leap_yr;			unsigned int yrs;			if (!capable(CAP_SYS_TIME))				return -EPERM;			if (copy_from_user(&rtc_tm, (struct rtc_time*)arg, sizeof(struct rtc_time)))				return -EFAULT;    				yrs = rtc_tm.tm_year + 1900;			mon = rtc_tm.tm_mon + 1;   /* tm_mon starts at zero */			day = rtc_tm.tm_mday;			hrs = rtc_tm.tm_hour;			min = rtc_tm.tm_min;			sec = rtc_tm.tm_sec;									if ((yrs < 1970) || (yrs > 2069))				return -EINVAL;			leap_yr = ((!(yrs % 4) && (yrs % 100)) || !(yrs % 400));			if ((mon > 12) || (day == 0))				return -EINVAL;			if (day > (days_in_mo[mon] + ((mon == 2) && leap_yr)))				return -EINVAL;						if ((hrs >= 24) || (min >= 60) || (sec >= 60))				return -EINVAL;			if (yrs >= 2000)				yrs -= 2000;	/* RTC (0, 1, ... 69) */			else				yrs -= 1900;	/* RTC (70, 71, ... 99) */			BIN_TO_BCD(sec);			BIN_TO_BCD(min);			BIN_TO_BCD(hrs);			BIN_TO_BCD(day);			BIN_TO_BCD(mon);			BIN_TO_BCD(yrs);			local_irq_save(flags);			local_irq_disable();			CMOS_WRITE(yrs, RTC_YEAR);			CMOS_WRITE(mon, RTC_MONTH);			CMOS_WRITE(day, RTC_DAY_OF_MONTH);			CMOS_WRITE(hrs, RTC_HOURS);			CMOS_WRITE(min, RTC_MINUTES);			CMOS_WRITE(sec, RTC_SECONDS);			local_irq_restore(flags);			/* Notice that at this point, the RTC is updated but			 * the kernel is still running with the old time.			 * You need to set that separately with settimeofday			 * or adjtimex.			 */			return 0;		}		case RTC_SET_CHARGE: /* set the RTC TRICKLE CHARGE register */		{			int tcs_val;                        			if (!capable(CAP_SYS_TIME))				return -EPERM;						if(copy_from_user(&tcs_val, (int*)arg, sizeof(int)))				return -EFAULT;			tcs_val = RTC_TCR_PATTERN | (tcs_val & 0x0F);			ds1302_writereg(RTC_TRICKLECHARGER, tcs_val);			return 0;		}		case RTC_VLOW_RD:		{			/* TODO:			 * Implement voltage low detection support			 */			printk(KERN_WARNING "DS1302: RTC Voltage Low detection"			       " is not supported\n");			return 0;		}		case RTC_VLOW_SET:		{			/* TODO:			 * Nothing to do since Voltage Low detection is not supported			 */			return 0;		}		default:			return -ENOIOCTLCMD;	}}
4520	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4520/7e9204265b4ec6680fad9abc7a78b94087983916/ds1302.c/clean/arch/cris/arch-v10/drivers/ds1302.c